4.875

4.9 | 8 ratings Rate this file 140 downloads (last 30 days) File Size: 2.2 KB File ID: #7347

freehanddraw

by Brett Shoelson

 

01 Apr 2005 (Updated 06 Oct 2005)

Code covered by BSD License  

Draw smooth lines freehand on images or plots; return the handle and xy data of the line object.

Download Now | Watch this File

File Information
Description

[LINEOBJ,XS,YS] = FREEHANDDRAW(ax_handle,line_options)

Draw a smooth freehand line object on the current axis (default),or on the axis specified by handle in the first input argument. Left-click once to begin drawing, right-click to terminate, or double-click to close contour and terminate.
 

INPUT ARGUMENTS: First: axis handle (optional)
                 Additional: valid line property/value pairs

OUTPUT ARGUMENTS: 1) Handle to line object
                  2) x-data
                  3) y-data
(Note that output args 2 & 3 can also be extracted from the first output argument.)

Ex: [myobj,xs,ys] = freehanddraw(gca,'color','r','linewidth',3);
freehanddraw('linestyle','--');

Written by Brett Shoelson, PhD
shoelson@helix.nih.gov
3/29/05. Modified 10/05/06 to allow double-click contour closure.

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements Tested successfully in R12.1 through R14.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
13 Jul 2005 Felix Bollenbeck

very usefull!

02 Oct 2005 Niv Peled

Very good!

07 Mar 2007 Jared Goor

Works great. This saved me a ton of coding. I turned it into an eraser by making a mask of the points, dilating them, and applying the mask to the image. The only drawback with my application of this program is that the tool drops points if you move it too fast so you don't get perfectly continuous lines. Regardless, great program. Don't forget to input the axes you are working with, NOT the image. Easy mistake for NBs like me.

26 Jul 2007 Ian Howat

Great, easy to use tool, thanks!

03 Apr 2009 Arthur

useful tool!

31 May 2009 Aaron DeBattista

Very good work works very nicely !!!
Has anyone managed to merge the line object to the actual image one is drawing upon.... i.e change the value of the actual image pixels .. Thanks

11 Sep 2009 Paul Groot

Very nice work!
Noticed a small issue, which may only occur in recent (R2009a) releases: The DoubleBuffer property seems not always present in the oldvals structure at line 82. This could be solved by moving it to a separate line:

if isfield(oldvals, 'DoubleBuffer')
    set(gcf,'doublebuffer',oldvals.DoubleBuffer);
end

20 Oct 2009 Image Analyst

I had been using this with R2008b and discovered that it's still "broken" in R2009b, but thanks to Paul Groot's helpful comment, it's now working again. However, now that the Image Processing Toolbox has imfreehand(), maybe you could use that instead.

Please login to add a comment or rating.
Updates
06 Apr 2005

Mistakenly cited ability to draw in 3D. Function returns xy- data, NOT xyz data.

06 Oct 2005

Now allows double-click closure of contours.

Tag Activity for this File
Tag Applied By Date/Time
annotation Brett Shoelson 22 Oct 2008 07:44:50
customization Brett Shoelson 22 Oct 2008 07:44:50
freehand Brett Shoelson 22 Oct 2008 07:44:50
draw Brett Shoelson 22 Oct 2008 07:44:50
line Brett Shoelson 22 Oct 2008 07:44:50
freeform Brett Shoelson 22 Oct 2008 07:44:50
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com