MATLAB: How to change white color to red red white I have an image and I would like to turn all white pixels to red. How can I do this? Thanks Best Answer Let me guess what your image is:img = uint8(rand(640, 480, 3) * 255);R = img(:, :, 1);G = img(:, :, 2);B = img(:, :, 3);isWhite = R == 255 & B == 255 & G == 255;G(isWhite) = 0;B(isWhite) = 0;newImg = cat(3, R, G, B);I do not like this solution. Is there an "inplace" method which does not duplicate the data? Related SolutionsMATLAB: How to create a white image Try this to create a grayscale image:whiteImage = 255 * ones(N, M, 'uint8');imshow(whiteImage);To create an RGB image, try this:whiteImage = 255 * ones(480, 640, 3, 'uint8');imshow(whiteImage); MATLAB: How to extract RGB information from an segmented image excluded white background. Get a mask of where white is, then extract pixels from where it's not white% Extract the individual red, green, and blue color channels.redChannel = rgbImage(:, :, 1);greenChannel = rgbImage(:, :, 2);blueChannel = rgbImage(:, :, 3);whiteMask = redChannel == 255 & greenChannel == 255 & blueChannel == 255;redValues = redChannel(~whiteMask);greenValues = greenChannel(~whiteMask);blueValues = blueChannel(~whiteMask); Related QuestionHow to do summation pixel by pixelHow to NaN selected threshold values of red,green and blue using matlab code
Best Answer