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

조회 수: 2 (최근 30일)
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?

답변 (1개)

Varun
Varun 2023년 9월 1일
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

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by