rgbImage = imread('image.jpeg');
subplot(2, 1, 1);
imshow(rgbImage);
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
yellowMask = redChannel > 128 & greenChannel > 128;
whiteMask = redChannel > 128 & greenChannel > 128 & blueChannel > 128;
redChannel(yellowMask) = 0;
greenChannel(yellowMask) = 255;
blueChannel(yellowMask) = 0;
redChannel(whiteMask) = 0;
greenChannel(whiteMask) = 0;
blueChannel(whiteMask) = 255;
rgbImage2 = cat(3, redChannel, greenChannel, blueChannel);
subplot(2, 1, 2);
imshow(rgbImage2);
2 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/508250-how-to-put-or-replace-color-in-rgb-greyscale-picture#comment_803770
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/508250-how-to-put-or-replace-color-in-rgb-greyscale-picture#comment_803770
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/508250-how-to-put-or-replace-color-in-rgb-greyscale-picture#comment_803787
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/508250-how-to-put-or-replace-color-in-rgb-greyscale-picture#comment_803787
Sign in to comment.