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?