RBG matrices but images shows doesn't show the intended colour.

12 views (last 30 days)
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?

Accepted Answer

Image Analyst
Image Analyst on 10 Jan 2016
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, []);

More Answers (0)

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!