Function to draw a rubberband line and return the start and end points. Usage: [p1,p2]=rbline; or [p1,p2]=rbline(h); where h is an axis handle. Click the mouse in the plot to define the start point. A rubberband line is drawn between the start point and the current point until the mouse is clicked again. The start point, p1, and the end point, p2, are returned. The figure UserData is not available while this function is running but is restored after it ends.
Nice. I had a problem where, after drawing the rubberband line, subsequently plotted figures would not paint over the previous figure. Adding "hold off" to the end of the code seems to have fixed this.
07 Mar 2007
Very simple if you remember to input the axes and not the image. Works great and easily outputs the endpoints. Code is simple to adjust to your needs.
29 Nov 2006
nice routine. I was trying to find something like that, it seems there's a similar routine at least in Matlab 7, it's called gline. You may find it useful as well.
17 Mar 2006
I have added "drawnow" in the callback function, cuz it seems Matlab 7 does not redraw when erasemode is "normal". Or, you can change the erasemode of the line to "xor" without adding "drawnow".
05 Jan 2005
Wonderful! Just what I was looking for! I modified it for interactive region growing, thanks! (also added drawnow at the end)
07 Sep 2004
Had a problem with the line drawing in R14 on a XP machine. added drawnow; at the end of wbmf function and works well now
13 Aug 2004
Just what I needed! I have modified it to show a rectangle using the two points as opposing corners instead of connecting the dots. THANKS!!!
01 Feb 2004
11 Jun 2003
I was about to try and figure out how to write this then I thought I would check here first. Even used the name I would have used. Works very well. The window motion function is very clever.
08 May 2003
simple program, easy to use, taught me something new. easily made mods to work in my app. thanks!