Maximums Intensities of an Image - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Maximums Intensities of an Image

Posts: 18Member
Hi to all!

If I want to find the maximum intensity of an image I write

max_int = max(Image(:))

If I want to find the second maximum intensity of an image (or the third, fourth etc. ) how can I write it?

Thank you in advance

• Posts: 217Member
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.

• Posts: 18Member
thank you!