If you have a uint8 image with values in the range [1 255] you can try to use the imhist function with the parameter n=256 (see the matlab help) In this way every luminance value of your image is "counted". [counts,x] = imhist(I,256)
then the last values of x [u]x(end)[/u] is the maximum value of the image (you have to check that the corresponding count is not null) and [u]counts(end)[/u] is the number of pixels with that value. Then, if you want to find the positions of this values in your image: pos=find(Image==x(end));
Then you can loop this procedure checking [u]x(end-1)[/u], [u]x(end-2)[/u], etc. Always checking if the corresponding count is not null.
Comments
In this way every luminance value of your image is "counted".
[counts,x] = imhist(I,256)
then the last values of x [u]x(end)[/u] is the maximum value of the image (you have to check that the corresponding count is not null) and [u]counts(end)[/u] is the number of pixels with that value. Then, if you want to find the positions of this values in your image:
pos=find(Image==x(end));
Then you can loop this procedure checking [u]x(end-1)[/u], [u]x(end-2)[/u], etc. Always checking if the corresponding count is not null.