Using the drawline function to get distance and intensities between endpoints
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
2 Kommentare
Antworten (1)
Image Analyst
am 23 Sep. 2022
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 Kommentare
Image Analyst
am 23 Sep. 2022
You probably changes it, like you don't have the line
plot(xLine, yLine)
Attach your code if you still want help with it.
Siehe auch
Kategorien
Mehr zu Recognition, Object Detection, and Semantic Segmentation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!