From: Oliver Warlow on
I am using impoint to digitise a number of points in an image. I want to digitise an unknown number of points, then continue with the rest of the m-file fater this has been done. I would like to the user to be able to push a button or keyboard to continue. My current method uses a while loop, but I cannot figure out how to break out of this loop once the user has finished digitising the points.
Oli
From: Matthew Whitaker on
"Oliver Warlow" <oli.warlow(a)gmail.com> wrote in message <hmqrih$shm$1(a)fred.mathworks.com>...
> I am using impoint to digitise a number of points in an image. I want to digitise an unknown number of points, then continue with the rest of the m-file fater this has been done. I would like to the user to be able to push a button or keyboard to continue. My current method uses a while loop, but I cannot figure out how to break out of this loop once the user has finished digitising the points.
> Oli

Oliver ,
you might want to look at ginput for your needs but if you want to use impoint you can use its wait property. Here is a demo of how you might approach it.

function impointDigitizeDemo
figure;
hIm = imshow('pout.tif');
hAx = get(hIm,'Parent');
title(hAx,'Click on Image to place digitizer point');
p = impoint(hAx,[]);
title(hAx,'Drag Point to digitize, double click point to continue');
drawnow;
digitizedPoints = p.getPosition;
% Construct boundary constraint function
fcn = makeConstrainToRectFcn('impoint',get(hAx,'XLim'),get(hAx,'YLim'));
p.setPositionConstraintFcn(fcn);
callbackID= p.addNewPositionCallback(@digitizePoints);
finalPoint =wait(p);
p.removeNewPositionCallback(callbackID);
digitizedPoints = [digitizedPoints;finalPoint];
h2 = figure;
axes('Parent',h2);
digitizedPoints = unique(digitizedPoints,'rows');
plot(digitizedPoints(:,1),digitizedPoints(:,2),'.');


function digitizePoints(newPos)
digitizedPoints = [digitizedPoints;newPos];
end %digitizePoints

end %impointDigitizeDemo


Hope this helps
Matt W