MATLAB Answers


for extracting red color alone of a color image input, i used the following code.




whether my code is doubt and if yes, why red color is not visible


3 Answers

Image Analyst
Answer by Image Analyst
on 9 Apr 2012
 Accepted answer

You extracted the red channel of a color image. Each color channel is simply a 2D image with an intensity. Essentially each one is a monochrome image, and those are displayed in gray scale by default. You can apply a colormap if you want to each to make it appear in it's original shade as explained in;jsessionid=523e8fb9a5651ebf4a0434578bbb but it's not really necessary and not usually done, or convert back to a color image again like Razvan did.


Answer by Razvan
on 9 Apr 2012

v contains only one color plane, so imshow(v) treats it as a grayscale image. You have there the actual red intensities.

If you want to show the image as red, you need to do something like

v = zeros(size(i));
v(:,:,1) = i(:,:,1);


Thanks Razvan


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!