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

조회 수: 8 (최근 30일)
Mohannad Nasir
Mohannad Nasir 2018년 9월 16일
편집: Image Analyst 2018년 9월 16일
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

채택된 답변

Rik
Rik 2018년 9월 16일
편집: Rik 2018년 9월 16일
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);

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 9월 16일
편집: Image Analyst 2018년 9월 16일
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(:));

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by