How do i find the coordinates of point given its intensity ??
8 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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);
0 个评论
更多回答(1 个)
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(:));
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!