Hi All, I was trying to isolate the RGB components from a given image.I wrote the following code and i am getting the red and blue components but for the green component i am getting a Black image.Can some one guide what is going wrong.Also when i try to take the histogram of the image using Imhist i have a problem because its a JPEG image.can anyone tell me how to over come it. Thanks in Advance. Regards, Aditya close all clear all A=imread('images.jpg'); B=double(A); redimage=A; redimage(:,:,2:3)=0; figure(1) title('red image') imagesc(redimage) blueimage=A; blueimage(:,:,1:2)=0; figure(2) title('blueimage') greenimage=A; greenimage(:,:,1:3)=0; figure(3) title('greenimage') __________________________________ |
|
Color Images
Started by ●October 31, 2003
Reply by ●October 31, 20032003-10-31
Try this code .... close all clear all A=imread('images.jpg'); B=double(A); redimage=A; redimage=A(:,:,1); figure(1);itle('red image') imagesc(redimage) blueimage=A; blueimage=A(:,:,3); figure(2) &title('blueimage') greenimage=A; greenimage=A(:,:,2); figure(3) title('greenimage') > Hi All, > I was trying to isolate the RGB components from a > given image.I wrote the following code and i am > getting the red and blue components but for the green > component i am getting a Black image.Can some one > guide what is going wrong.Also when i try to take the > histogram of the image using Imhist i have a problem > because its a JPEG image.can anyone tell me how to > over come it. > Thanks in Advance. > Regards, > Aditya > > __________________________________ > > > _____________________________________ > Note: If you do a simple "reply" with your email client, > only the author of this message will receive your answer. > You need to do a "reply all" if you want your answer to > be distributed to the entire group. > > _____________________________________ > About this discussion group: > > To Join: > > To Post: > > To Leave: > > Archives: http://www.yahoogroups.com/group/matlab > > More DSP-Related Groups: http://www.dsprelated.com/groups.php3 > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service. |
Reply by ●October 31, 20032003-10-31
hi aditya, you are getting a black image because, 1:3 in greenimage(:,:,1:3)= 0; means that all values with third dimension from 1 to 3 should be made zero. hence the above statement makes the matrix greenimage a zero matrix, which represents a black image. hence to extract the green component one way is, greenimage(:,:,1) = 0; greenimage(:,:,3) = 0; hope this solves your problem. - Harish --- aditya <> wrote: --------------------------------- Hi All, I was trying to isolate the RGB components from a given image.I wrote the following code and i am getting the red and blue components but for the green component i am getting a Black image.Can some one guide what is going wrong.Also when i try to take the histogram of the image using Imhist i have a problem because its a JPEG image.can anyone tell me how to over come it. Thanks in Advance. Regards, Aditya close all clear all A=imread('images.jpg'); B=double(A); redimage=A; redimage(:,:,2:3)=0; figure(1) title('red image') imagesc(redimage) blueimage=A; blueimage(:,:,1:2)=0; figure(2) title('blueimage') greenimage=A; greenimage(:,:,1:3)=0; figure(3) title('greenimage') __________________________________ _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: To Post: To Leave: Archives: http://www.yahoogroups.com/group/matlab More DSP-Related Groups: http://www.dsprelated.com/groups.php3 ________________________________________________________________________ Yahoo! India Matrimony: Find your partner online. Go to http://yahoo.shaadi.com |
Reply by ●October 31, 20032003-10-31
> greenimage(:,:,1:3)=0; you should use 'greenimage(:,:,[1,3])' in the above line. 1:3 is 1,2,3. Navan. --- aditya <> wrote: > Hi All, > I was trying to isolate the RGB components from a > given image.I wrote the following code and i am > getting the red and blue components but for the > green > component i am getting a Black image.Can some one > guide what is going wrong.Also when i try to take > the > histogram of the image using Imhist i have a problem > because its a JPEG image.can anyone tell me how to > over come it. > Thanks in Advance. > Regards, > Aditya > > > close all > clear all > A=imread('images.jpg'); > B=double(A); > redimage=A; > redimage(:,:,2:3)=0; > figure(1) > title('red image') > imagesc(redimage) > blueimage=A; > blueimage(:,:,1:2)=0; > figure(2) > title('blueimage') > greenimage=A; > greenimage(:,:,1:3)=0; > figure(3) > title('greenimage') __________________________________ |