How do i find the coordinates of point given its intensity ??

8 Ansichten (letzte 30 Tage)
Mohannad Nasir
Mohannad Nasir am 16 Sep. 2018
Bearbeitet: Image Analyst am 16 Sep. 2018
Hello, I'm working on my senior design project with image processing , but i have an issue that i have an image and i want to find the pixel that have maximum intensity ... i already did that but i don't know how to find the coordinate of this maximum intensity pixel... also is there other way to find pixel that have maximum intensity and its coordinates ??
thanks in advance

Akzeptierte Antwort

Rik
Rik am 16 Sep. 2018
Bearbeitet: Rik am 16 Sep. 2018
The second output of max returns a linear index, which you can convert to subscripts with ind2sub.
[maxval,maxind]=max(IM(:));
[r,c]=ind2sub(size(IM),maxind);
You can also use the fact that max normally operates on 1 dimension:
[vec,r_vec]=max(IM,[],1);
[maxval,c]=max(vec,[],2);
r=r_vec(c);

Weitere Antworten (1)

Image Analyst
Image Analyst am 16 Sep. 2018
Bearbeitet: Image Analyst am 16 Sep. 2018
Use find(), not max():
v = randi(10, 5, 30) % Create small image.
[maxValue, indexes] = max(v(:)) % Does not show ALL maxima locations.
[rows, columns] = find(v == max(v(:))) % Shows ALL maxima locations.
So, find() works. The horrendous help for max says:
[M,I] = max(_) finds the indices of the maximum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. If the maximum value occurs more than once, then max returns the index corresponding to the first occurrence.
So what the first sentence promised, the second sentence takes away. It does not return all maxima locations, only the first one per column.
Alternatively, you can also get the max locations as a binary image
binaryImage = grayImage == max(grayImage(:));

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by