How to get profile coordinates x,y after using improfile
Show older comments
I want to use improfile command to ask user to select a line on the image where he wants a profile intensity and then i want to also get coordinates x and y of this line.
improfile only give me intensity values along the line i trace.
i also know [x,y] = ginput to get pixels positions from mouse click but it doesn't draw a line between 2 positions clicking so it's hard to know which line i will study with improfile(I,xi,yi).
Here is an example of a picture i want to study:

Thanks !
4 Comments
benjamin gorin
on 11 Apr 2020
Edited: benjamin gorin
on 11 Apr 2020
Image Analyst
on 11 Apr 2020
You have cx and cy. Which do you want for the x axis?
Or do you want the distance from the leftmost point? If so, do this:
% Plot lines and markers like he want:
plot(cx(1), cy(1), 'g.', 'MarkerSize', 25); % Green spot.
hold on
plot(cx(end), cy(end), 'rs', 'MarkerSize', 25); % Red Square.
plot(cx, cy, 'r-', 'LineWidth', 2); % Red line.
% Get distance from left-most point.
[xLeft, index] = min(cx);
yLeft = cy(index);
distance = sqrt((cx-xLeft).^2 + (cy - yLeft) .^ 2);
% Now plot with distance as the x-axis.
plot(distance, c, 'b.-');
grid on;
title('Intensity Profile', 'FontSize', 15);
xlabel('Distance from left point', 'FontSize', 15);
ylabel('Gray Level', 'FontSize', 15);
You could also do distance from the peak, if you'd rather have that.
benjamin gorin
on 11 Apr 2020
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

