From: Jeprol on
dear all,

could anyone can explain to me what is coding below do?

vb = imread('1.jpg');
X = im2double(v2);
misc = (X(:,:,1)+X(:,:,2)+X(:,:,3));
misc(misc==0) = 0.7;
X(:,:,1) = X(:,:,1)./misc;
X(:,:,2) = X(:,:,2)./misc;

Thank you.
From: Rob Campbell on

> could anyone can explain to me what is coding below do?
>
Not without knowing what the variables are! Nonetheless, it appears to do:

> vb = imread('1.jpg');
imread reads the jpg into ram. The number of rows and columns in the matrix correspond to the number of pixels along x and y in your image. The matrix has a length of 3 along the third dimension, corresponding to red, green, and blue pixel intensities.


> X = im2double(v2);
Variable 'v2' is presumably some image or it's a typo and v2 is actually vb (since you do nothing with vb having read it in and v2 comes from nowhere).


> misc = (X(:,:,1)+X(:,:,2)+X(:,:,3));
You then sum along the 3rd dimension. This would be better done:
misc=sum(X,3);

> misc(misc==0) = 0.7;
And now set all zeros to have a value of 0.7. I don't know why you choose 0.7 but the next step is a division so presumably you want to avoid infinities .


> X(:,:,1) = X(:,:,1)./misc;
> X(:,:,2) = X(:,:,2)./misc;
Now you do an element-wise division of the red and green channels in the image by the values you calculated in misc. Again, don't know why because we don't know what these variables are. Don't know why you're dividing by the sum and not the mean.
From: ImageAnalyst on
Rob's correct. The only other interpretation I might offer is that it
appears to want to work with "normalized RGB" arrays. Search the
newsgroup for "Dave Robinson" - he's a big proponent of using them (in
appropriate situations), and has discussed them many times before.
Generally they're used for color classification/segmentation (i.e.
finding objects of a certain color while being somewhat robust as to
the lighting level).
From: Jeprol on
"Rob Campbell" <matlab(a)robertREMOVEcampbell.removethis.co.uk> wrote in message <hogjp9$enb$1(a)fred.mathworks.com>...
>
> > could anyone can explain to me what is coding below do?
> >
> Not without knowing what the variables are! Nonetheless, it appears to do:
>
> > vb = imread('1.jpg');
> imread reads the jpg into ram. The number of rows and columns in the matrix correspond to the number of pixels along x and y in your image. The matrix has a length of 3 along the third dimension, corresponding to red, green, and blue pixel intensities.
>
>
> > X = im2double(v2);
> Variable 'v2' is presumably some image or it's a typo and v2 is actually vb (since you do nothing with vb having read it in and v2 comes from nowhere).
>
>
> > misc = (X(:,:,1)+X(:,:,2)+X(:,:,3));
> You then sum along the 3rd dimension. This would be better done:
> misc=sum(X,3);
>
> > misc(misc==0) = 0.7;
> And now set all zeros to have a value of 0.7. I don't know why you choose 0.7 but the next step is a division so presumably you want to avoid infinities .
>
>
> > X(:,:,1) = X(:,:,1)./misc;
> > X(:,:,2) = X(:,:,2)./misc;
> Now you do an element-wise division of the red and green channels in the image by the values you calculated in misc. Again, don't know why because we don't know what these variables are. Don't know why you're dividing by the sum and not the mean.

yes. it's typo. v2 actually vb. the value of 0.7 actually is 0.001. i change it to big value because i want to know the changes. i using this code to normalize the rgb image. what is the different using dividing by the sum or dividing the mean? is dividing mean is more accurate?