Google: getting red component of rgb image in matlab http://stackoverflow.com/questions/131844 !
/wh"#i#dont#get#the#channel#blue# green#or#red#with#this#short#code#in#matlab
rgb $ imread%&peppers.png&'( imshow%rgb%:):)1''( When i put this the image is grey, not green or blue or red. Why is that? Am I doing something wrong?
3 Answers
activeoldestvotes
up vote down vote
accepted
The image is grey because you are looking at values for only one color, AT!A" sees values for a color, but there is no way for it to know what color it is, which is why it displays grey. As an e#ample, what color is the value $5%? When you pass &ust a matri# of values into imshow it will show it in grey scale. imshow%rgb%:):)1''( *+hows the values of the red component of the image in gre" rgb $ imread%&peppers.png&'( r $ rgb( r%:):) :3' $ ,( * -he red component without the other components g $ rgb( g%:):)1: :3' $ ,( * -he green component without the other components b $ rgb( b%:):)1: ' $ ,( * -he blue component without the other components figure%'( imshow%r'( figure%'( imshow%g'( figure%'( imshow%b'( 'oing the above will allow you to see the representation of the magnitudes of the colors in their own color value.
(o, i supose that i need to specified map of colors. I need to say to him tha that i need to post other +uestion how to do that. ,.o Thankyou -user$./*%*0 1o that2s incorrect...wait $ minute and I2ll post a note on th I thought this because if a made im34,4,*456 7 )8 imshow3im68 this is show 1 colors. I supose... 9 user$./*%*0 1ov $ 2$* at *)4$) -user$./*%*0 :ou2re correct, I must not have understood your first comm the r, g, and b images 3in their respective colors6. 9 1omin(im add comment
up vote down vote
If you want to only display one color channel, set the other color channels to ;ero4 peppers $ imread%&peppers.png&'( onl"red.peppers $ peppers( onl"red.peppers%:):) :3'$,( imshow%onl"red.peppers'(
If you feed imshow only peppers%:):)1', you2re giving it &ust a /0101 matri#, which is interpreted by imshow as grayscale, see here. If you really want, you can change the colormap to change the grayscale image to redscale4 imshow%peppers%:):)1''( cm.red $ 2linspace%,)1) !3'& 4eros% !3) '5( colormap%cm.red'( which will give you the same image as above. If you also want to scale the color span in the image you load to use the full available span 3)<$ = )<*556, you can do that with4 red.scaled.peppers $ peppers%:):)1'( red.scaled.peppers $ double%red.scaled.peppers'/double%ma0%re d.scaled.peppers%:'''( imshow%red.scaled.peppers'( colormap%2linspace%,)1) !3'& 4eros% !3) '5'( which makes no difference, because in this case, red channel color span is already ma#ed out.
thank you, but i know that. I &ust dont know if because the map of colors or that i supose Im &ust waiting for his note. Thank you 9 user$./*%*0 look at my last remark, I2ll also add something about changing the colormap yes i figureout this solution too. "ut the problem of use colormap is that you colormap3>>)4$=*554$?2, ;eros3*50,$6, ;eros3*50,$6?6 (o my step of color is $ green or red has color with a diference less than $=*55. 9 that depends on the image you load, type double will assume channel inten @or this reason alone &ust working on the original image is best. I think you a span to use the total available scale, ie if the image contains color values )<* that 86 9 Aunther (truyf 1ov $ 2$* at *$45. add comment
The BA" color model represents color by Cmi#ingC the red, green and blue colors in some vote do proportion. All you need to know is a color is represented by 5 numbers. wn vote Therefore, your rgb image is represented by 5 matrices where rgb%:):)1' represents the red layer. 1ow, if you looked at rgb%:):)1' you2d see a bunch of numbers 3probably between ) < *55 or ) < $6. (o element rgb%i)6)1' represents the red component at pi#el %i)6'. Therefore, displaying the matri# rgb%:):)1' merely displays a matri# with a bunch of values which is displayed as grayscale 3where ) 7 black and *55 7 white6. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$ Google: combining red green and blue components to get rgb image
up
http://www.mathworks.in/matlabcentral/answers/17,83
combining RGB to get a full image
Asked by prem preet on 23 Oct 2011
image_RGB cat!2"final_red"final_green"final_blue# ims$o%!image_RGB#& can anyone suggest me t$at t$is code is correct for combining RGB components for getting full image as soon as possible
0 Comments
0 votes Tags
matlab code
Products
'mage (rocessing )oolbo*
2 Answers
Ans%er by +ayne ,ing on 23 Oct 2011
-i" .ou don/t %ant to concatenate along t$e column dimension0 An RGB image $as 3 dimensions0 .ou %ant to concatenate along t$e 3rd dimension0 imdata = imread('ngc6543a.jpg'); RC = imdata(:,:,1); GC = imdata(:,:,2); BC = imdata(:,:,3); im = cat(3,RC,GC,BC); i e!"a#(imdata,im) im $%&(im)
5 Comments
1$o% 2 older comments +ayne ,ing on 23 Oct 2011 2ink
please post t$e e*act error message
prem preet on 23 Oct 2011 2ink
333 4ndefined function or variable /redc$annel/0
prem preet on 23 Oct 2011 2ink
t$is error occured for all 3 above functions 0000 ims$o%!redc$annel#&00000 plss rply fast00
0 votes 2ink Ans%er by 'mage Analyst on 23 Oct 2011
'5(OR)A6) 6O)78 5A)2AB is case sensitive0 redc$annel is different t$an red9$annel0 't looks like you/ve taken code '/ve posted many times and tried to adapt it8 ' ()tract t$e indi*id"a# red, green, and +#"e c%#%r c$anne# . redC$anne# = rg+,mage(:, :, 1); greenC$anne# = rg+,mage(:, :, 2); +#"eC$anne# = rg+,mage(:, :, 3); ' Rec%m+ine eparate c%#%r c$anne# int% an RGB image.
rg+,mage = cat(3, redC$anne#, greenC$anne#, +#"eC$anne#); ' call t$em :c$annels: because t$at is t$e terminology ($otos$op uses0 .ou $ave to c$ange t$e name of t$e arrays from red9$annel to %$at yours are called0 After you split apart your color c$annels and reprocessed t$em you $ave final_red0 )$is" 6O) red9$annel" is %$at you need to use0 .ou also need to not c$ange from dimension 3 !%$ic$ ' $ad# to dimension 20 1o t$e final code %ould be ' Rec%m+ine eparate c%#%r c$anne# int% an RGB image. rg+,mage = cat(3, -ina#.red,-ina#.green,-ina#.+#"e);
3 Comments
prem preet on 23 Oct 2011 2ink
t$anks sir " i gonna try t$is00
1$aila parvin on 2; <un 2013 2ink
rgb'mage cat!3" final_red"final_green"final_blue#& +$at %ill $appen if ' %rite 2=1=;=somet$ing else in place of 30 ' mean8 rgb'mage cat!1" final_red"final_green"final_blue#&
)itus 7del$ofer on 2; <un 2013 2ink
't %ill most likely fail8 t$e 3 is denoting t$e 3rd dimension0 >or RGB images8 10 and 20 dimension give t$e si?e in pi*els" t$e 30 dimension is t$e color0