Using the drawline function to get distance and intensities between endpoints
조회 수: 7 (최근 30일)
이전 댓글 표시
I am using this function https://www.mathworks.com/help/images/ref/drawline.html to draw a line across an image. My goal is to get the distance between the endpoints and get the intensity across the line.
disp('Please draw a line from the anterior edge of the patient to the center of the prostate');
anteriorLine = drawline(fh.CurrentAxes,'Color','r');
% Calculate the length of the line in physical units
% anteriorLine.Position
Distance = anteriorLine.Position;
x1 = Distance(1,1); y1 = Distance(1,2); x2 = Distance(2,1); y2 = Distance(2,2);
% Interpolate the intensities allong the line in increments of 0.1 mm
% Plot intensities allong line
I am having trouble with the position code in the link I shared above and I don't even know where to start with interpolating the intensities across the line. I would greatly appreciate a starting point or some help, thank you.
답변 (1개)
Image Analyst
2022년 9월 23일
Try this:
grayImage = imread('moon.tif');
subplot(2, 1, 1);
imshow(grayImage);
drawnow;
uiwait(helpdlg('Left click the first point and right click the second point.'))
[xLine, yLine, intensities] = improfile;
hold on;
plot(xLine, yLine, 'b-', 'LineWidth', 2)
subplot(2, 1, 2);
plot(intensities, 'b-', 'LineWidth', 2)
grid on;
xlabel('Distance')
ylabel('Gray Level')
댓글 수: 2
Image Analyst
2022년 9월 23일
You probably changes it, like you don't have the line
plot(xLine, yLine)
Attach your code if you still want help with it.
참고 항목
카테고리
Help Center 및 File Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!