How to extract corresponding x axis value in improfile.

9 views (last 30 days)
How to extract the values of x axis in improfile? I'm using
t=improfile(I,p1,p2) ;
where p1 and p2 are the x,y coordinates for the profile, which is I'm assigning. t gives me the intensity value in [nx1] matrix. How do I extract corresponding x axis values?
  1 Comment
dpb
dpb on 24 Jul 2022
Read the doc improfile -- there are other optional output arguments to return the coordinates and two more beyond those for the line endpoints as well.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 24 Jul 2022
Try this (using an example from the improfile documentation) —
I = imread('liftingbody.png');
x = [19 427 416 77];
y = [96 462 37 33];
figure
improfile(I,x,y)
grid on
Ax = gca;
Lines = findobj(Ax, 'Type','line');
x = Lines.XData
x = 1×1173
19.0000 19.8335 20.6669 21.5004 22.3339 23.1674 24.0008 24.8343 25.6678 26.5013 27.3347 28.1682 29.0017 29.8352 30.6686 31.5021 32.3356 33.1691 34.0025 34.8360 35.6695 36.5029 37.3364 38.1699 39.0034 39.8368 40.6703 41.5038 42.3373 43.1707
y = Lines.YData
y = 1×1173
96.0000 96.7477 97.4953 98.2430 98.9907 99.7384 100.4860 101.2337 101.9814 102.7291 103.4767 104.2244 104.9721 105.7198 106.4674 107.2151 107.9628 108.7105 109.4581 110.2058 110.9535 111.7012 112.4488 113.1965 113.9442 114.6919 115.4395 116.1872 116.9349 117.6826
z = Lines.ZData
z = 1×1173
147 146 149 148 148 149 148 148 150 146 146 145 139 139 137 139 141 138 139 133 134 138 138 141 141 145 143 148 147 142
See if this approach works in your application.
NOTE — I did not return an output from improfile here. This may not work correctly if you do.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!