How to find z coordinate while having only x and y coordinates on images?

26 views (last 30 days)
Nasiruddin Zh
Nasiruddin Zh on 15 Jun 2022
Commented: Nasiruddin Zh on 21 Jun 2022
Hi, im looking a z-coordinate on an 2D image that I already use a mesh to find diameter on 3D graph. Here i attach my codes that i try on this link.
I = imread ("01_manual1.gif");
edtImage = 2 * bwdist(~I);
skel = bwmorph(I, 'skel', Inf);
diameterImage = edtImage .* double(skel);
mesh (diameterImage);
Next, i already have x and y coordinate but i have to get the z coordinate without referring to the graph which is automatically find the z.
Here my x and y coordinates.
x y
78 198
145 238
26 268
94 198
35 292
111 202
138 294
57 205
49 307
50 210
68 318
136 221
37 223
147 246
149 258
29 280
97 320
86 321
i want to find the z coordinate to plot a point on the 3d graph sing plot3. I hope anyone can help me or suggest me a better method. Thank you.

Answers (2)

KSSV
KSSV on 15 Jun 2022
Edited: KSSV on 15 Jun 2022
Read about interp2
  2 Comments
Nasiruddin Zh
Nasiruddin Zh on 21 Jun 2022
hi, thank you for your suggestion. i already got the data by using this.
z = interp2(diameterImage, x, y);

Sign in to comment.


Image Analyst
Image Analyst on 15 Jun 2022
If you have x and y (as you said) then you can get the diameter (Z) by
diameterZ = diameterImage (y, x);
  1 Comment
Nasiruddin Zh
Nasiruddin Zh on 15 Jun 2022
if im using that i will get 18 * 18 matrix.
let say im adding this.
mesh (diameterImage);
hold on; plot(x,y,'+k','MarkerSize',10,'Color','r','LineWidth',1.5);
hold off
diameterZ = diameterImage (x,y);
i want the z coordinate only at 18*1 matrix from the x and y above.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!