How do I get coordinate from 2D image ?

11 ビュー (過去 30 日間)
Alon Mazri
Alon Mazri 2022 年 9 月 1 日
編集済み: DGM 2022 年 9 月 1 日
figure
h=imagesc(phi,theta, Z)
im = imagemodel(h)
maxval = getMaxIntensity(im)
i get the max intensity, but i need the [X Y] coordinate of this point.
in 1D i used in findpeaks
now i have a problem
help me

採用された回答

DGM
DGM 2022 年 9 月 1 日
編集済み: DGM 2022 年 9 月 1 日
What's wrong with just finding the maxima of the inputs themselves?
% you have z as a function of x and y
[x y z] = peaks(100);
% find the maximum z-value and its coordinates in the given space
[maxvalue idx] = max(z(:));
maxlocation = [x(idx) y(idx)]
maxlocation = 1×2
-0.0303 1.6061
% plot z and indicate calculated maxima
surf(x,y,z); hold on
plot3(maxlocation(1),maxlocation(2),maxvalue,'*','markersize',15,'linewidth',2)
I will note that imagesc() does not actually use the full vector/matrix inputs for the x,y arguments. It only uses the extrema of those arrays and assumes that the space is linear inbetween. If imagesc() is called more concisely with 2-element range inputs for x and y, then this indexing approach won't work. If that's the case, we can cross that bridge if necessary. (hint: find the index of the maxima and use ind2sub() and a set of linear vectors for x and y)
If the sample spacing isn't constant in x and y, then replicating the behavior of image()/imagesc() will be counterproductive.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by