MATLAB: RBG matrices but images shows doesn’t show the intended colour.

rgb

Hi, I just found the code to extract an image to 3 separate channels. Correct me if I'm wrong.
red = img(:,:,1); green = img(:,:,2); blue = img(:,:,3).
But when I imshow() the image, the sperated images does not show the actual colur. For instance, the images shows approximately the same colour as the original one, just the blue one seems to be a bit darker. My impression is that the red image only shows red colour of varying intensity, as the same for the other two. Why is that?

Best Answer

Those are three gray scale images. If they're uint8, they should use the original values. To be sure, you can use [0,255] in imshow
imshow(red, [0,255]);
imshow(green, [0,255]);
imshow(blue, [0,255]);
They will show up as grayscale. If you want them in their "original" colors, you have to either apply a colormap or convert them to an RGB image in the appropriate plane.
If you want to scale each image from its own min to its own max, use []:
imshow(red, []);
imshow(green, []);
imshow(blue, []);
Related Question