File Exchange

image thumbnail

Rubberband Line

version 1.0 (1.13 KB) by

Draws a rubber band line and returns the x y coordinates of the end points.

4.72727
11 Ratings

6 Downloads

Updated

No License

[p1,p2]=rbline(varargin)

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.

Comments and Ratings (11)

Great code!

Matt J

Matt J (view profile)

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.

Jared Goor

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.

Bill Korpsus

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.

Calvin Mao

Excellent work!
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".

Markus Karlsson

Wonderful! Just what I was looking for! I modified it for interactive region growing, thanks! (also added drawnow at the end)

John Petty

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

Sam Richardson

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!!!

manbir sodhi

Brian Katz

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.

Chuck Hayden

simple program, easy to use, taught me something new. easily made mods to work in my app. thanks!

MATLAB Release
MATLAB 6.0 (R12)
Acknowledgements

Inspired: Muscle fascicle tracking - Ultrasound

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video