MATLAB: Satellite image color problem

image analysisimage processingImage Processing Toolboximage segmentationmaskingMATLAB and Simulink Student Suite

Hello
I have a black and white image and I want the white area to be displayed in red. I have a code but badly the zone in black is displayed in red. I just want to change the code to have my result,
and thanks in advance and thanks for Image Analyst
I have attached the image.
rgbImage = imread('C1fig.jpg');
whos rgbImage
subplot(2, 1, 1);
imshow(rgbImage);
title('Original RGB image C1fig.jpg');
axis('on', 'image');
impixelinfo
mask = rgbImage(:, :, 1) == 0;
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
redChannel(mask) = 255;
greenChannel(mask) = 0;
blueChannel(mask) = 0;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
subplot(2, 1, 2);
imshow(rgbImage);
axis('on', 'image');
impixelinfo
title('Altered RGB image');

Best Answer

This is a duplicate question. I already answered it here: in your duplicate post
Like I already said, essentially you just define the mask to find white pixels instead of black pixels:
mask = rgbImage(:, :, 1) > 250; % or whatever value you want.
Why did that not work for you, such that you had to post a duplicate question on it???