How can I convert the red color in the image to white?
2 views (last 30 days)
Show older comments

I need to remove the noise (red color) from this image. I need help in performing two operations: 1. Convert the red color in the image to white. 2. Considering the image is array of pixels in 2D. What I need to do is ask the program to check which pixel values are white, and then give it a value of a non-white adjacent pixel.
Can this be done in MATLAB?
This is how the final product should look like

0 Comments
Answers (1)
Image Analyst
on 22 Feb 2018
Edited: Image Analyst
on 23 Feb 2018
Try this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
redMask = redChannel >= 200 & greenChannel <= 50 & blueChannel <= 50;
greenChannel(redMask) = 255;
blueChannel(redMask) = 255;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
8 Comments
Image Analyst
on 24 Feb 2018
OK good luck. When you paint over it, it would be good if you used pure red (255,0,0) instead of whatever similar color you used, or at least know exactly what color you used so you can put those values in to the algorithm.
Next, never use JPG images for image analysis because this will change the values. That's probably why there was still a little bit of red around the perimeter. The jpeg process blurred out the image.
See Also
Categories
Find more on Detection in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!