Any suggestions to measure the distance between two lines or regions (the dip represents low intensity)

2 views (last 30 days)
Here I plotted the centre of gravity between two regions, then I would like to measure the distance between these two line using gridline or region of interest, maybe , any suggestions?

Answers (1)

Varun
Varun on 1 Sep 2023
Hello!
As per my understanding, you want to measure the distance between two lines that have been plotted in the figure. There are multiple ways to go about it:
  1. Using the “drawline function: The “drawline” function lets you create a customizable region-of-interest. So, in the figure window, you can measure the distance between the lines by connecting the lines using “drawline”, by placing one end-point on each line. The line’s Position properties can be used to get the coordinates of its endpoints, using which the Euclidean distance can be calculated. Example:
h1 = drawline();
distance=sqrt((h1.Position(1,1)-h1.Position(2,1))^2 + (h1.Position(1,2)-h1.Position(2,2))^2);
You may refer to the following documentation to learn more aboutdrawline”: https://www.mathworks.com/help/images/ref/drawline.html
2. Using the “ginput” function: The “ginput” function lets you identify axes coordinates in a Figure window. So, “ginput” can be used to pick two points, one lying on each line. Using the coordinates of these points, the Euclidean distance can be calculated. Example:
disp('Select a point on Line 1:');
[x1_point, y1_point] = ginput(1);
scatter(x1_point, y1_point)
% Select points on Line 2
disp('Select a point on Line 2:');
[x2_point, y2_point] = ginput(1);
scatter(x2_point, y2_point);
% Calculate the distance between the selected points
distance = sqrt((x2_point - x1_point^2 + (y2_point- y1_point)^2);
You may refer to the following documentation to learn more about “ginput”: https://www.mathworks.com/help/matlab/ref/ginput.html
Hope this helps!
Thanks,
Varun

Categories

Find more on Visual Exploration in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!