How can I convert the red color in the image to white?

4 ビュー (過去 30 日間)
Usman Mahmood
Usman Mahmood 2018 年 2 月 22 日
コメント済み: Image Analyst 2018 年 2 月 24 日
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

回答 (1 件)

Image Analyst
Image Analyst 2018 年 2 月 22 日
編集済み: Image Analyst 2018 年 2 月 23 日
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 件のコメント
Usman Mahmood
Usman Mahmood 2018 年 2 月 24 日
I intend to repaint my apparatus to red or any other color, so I can try separating the noise later.
Image Analyst
Image Analyst 2018 年 2 月 24 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by