#019 - Manual polyline tool

In 2019 Matlab added region-of-interest (ROI) features. The function drawpolyline used here is an illusion though, it calls the ROI object images.roi.Polyline (one of many in the toolkit) while keeping the main script runtime going. A neat feature is that the most recently added vertex can be removed by pressing backspace. The function redraws the line from the previous vertex, and it can even backtrack to the very first vertex drawn!

To use it, paste the following code directly after a figure, with a runtime stop at h to set-up the figure canvas before drawing.

 

h=drawpolyline();

X=h.Position(:,1);
Y=h.Position(:,2);
S=cat(2,X,Y);

figure('Position',[20,20,1200,800],'Resize','on');
plot3(S(:,1),S(:,2),1:length(S),'-r');