Code covered by the BSD License  

Highlights from
Interactive Spline Region of Interest

image thumbnail

Interactive Spline Region of Interest

by

 

17 Mar 2009 (Updated )

An interactive, closed spline

exampleScript.m
clear
clear classes
close all

%% create a new splineroi and add a node to it.
r=splineroi; % creates a splineroi object with no nodes
r.addNode; % create the first node

%% and several nodes using ginput
uiwait(msgbox('now add more points to the spline'))
btn = 1;
while ~isempty(btn)
    [x,y,btn]=ginput(1);
    if ~isempty(btn)
        r.addNode([x,y]);
    end
end



%% delete one node

uiwait(msgbox('now delete 2 nodes by clicking on the closest node'))

r.deleteNode

r.deleteNode


%% get spline points
sPoints = r.calcSpline;

%% create a mask
mask = poly2mask(sPoints(1,:),sPoints(2,:),256,256);

Contact us