Login  Register

Re: draw lines in image

Posted by Yuekan Jiao-2 on Jul 31, 2013; 10:49pm
URL: http://imagej.273.s1.nabble.com/draw-lines-in-image-tp5004213p5004251.html

Hi,

If you are doing plugin programming, you may use the following code I
posted a while ago:

Overlay overlay = new Overlay();
Roi roi = new Line(startX, startY, endX, endY);
overlay.add(roi);
imp.setOverlay(overlay);
Cheers

Yuekan Jiao


On Wed, Jul 31, 2013 at 11:04 AM, Glen MacDonald
<[hidden email]>wrote:

> hello Francisco,
> Help>Macro Functions, searching for 'line':
>
>  lineTo(x, y)
> Draws a line from current location to (x,y) . See also: Overlay.lineTo.
>
> makeLine(x1, y1, x2, y2)
> Creates a new straight line selection. The origin (0,0) is assumed to be
> the upper left corner of the image. Coordinates are in pixels. You can
> create segmented line selections by specifying more than two coordinate
> pairs, for examplemakeLine(25,34,44,19,69,30,71,56).
>
> makeLine(x1, y1, x2, y2, lineWidth)
> Creates a straight line selection with the specified width. See also:
> getLine.
>
> drawLine(x1, y1, x2, y2)
> Draws a line between (x1, y1) and (x2, y2). Use setColor() to specify the
> color of the line and setLineWidth() to vary the line width. See also:
> Overlay.drawLine.
>
> and, depending on what you are trying to do:
> getCursorLoc(x, y, z, modifiers)
> Returns the cursor location in pixels and the mouse event modifier flags.
> The zcoordinate is zero for 2D images. For stacks, it is one less than the
> slice number. UsetoScaled(x,y) to scale the coordinates. For examples, see
> the GetCursorLocDemo and the GetCursorLocDemoTool macros.
>
>
> Glen MacDonald
>         Core for Communication Research
> Virginia Merrill Bloedel Hearing Research Center
>         Cellular Morphology Core
> Center on Human Development and Disability
> Box 357923
> University of Washington
> Seattle, WA 98195-7923  USA
> (206) 616-4156
> [hidden email]
>
>
>
>
>
>
>
> On Jul 31, 2013, at 10:06 AM, Francisco Soto <[hidden email]>
> wrote:
>
> > Hi!
> >
> >   Thanks for the answers, but i'm trying to draw lines from the code.
> With
> > your help i'm trying to search the function to draw lines automatically
> > from my code.
> >
> > Best!
> >
> >
> > 2013/7/31 Straatman, Kees R. (Dr.) <[hidden email]>
> >
> >> Hi Francisco,
> >>
> >> In addition to this if you right mouse click on this line tool you can
> >> select the type of line you want to use; straight line, segmented line,
> >> freehand or arrow.
> >>
> >> Kees
> >>
> >> -----Original Message-----
> >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> >> Curtis Rueden
> >> Sent: 30 July 2013 16:00
> >> To: [hidden email]
> >> Subject: Re: draw lines in image
> >>
> >> Hi Francisco,
> >>
> >>> I want to draw lines in my result image.
> >>
> >> Click the line tool (fifth from left in the toolbar), draw a line on the
> >> image by clicking and dragging with the mouse, then run Edit > Draw to
> make
> >> it permanent on the image.
> >>
> >> In a macro, the code is something like:
> >>
> >> makeLine(216, 14, 35, 91);
> >> setForegroundColor(255, 255, 255);
> >> run("Draw");
> >>
> >> I found this code easily by running Plugins > Macros > Record... to
> launch
> >> the Macro Recorder, then repeating the manual steps I mentioned above.
> >>
> >> HTH,
> >> Curtis
> >>
> >>
> >> On Tue, Jul 30, 2013 at 8:57 AM, Francisco Soto <
> >> [hidden email]> wrote:
> >>
> >>> Hello!
> >>>
> >>>  This is my first post. I want to know how can I draw a line in the
> >>> images. I'm opening an image (.jpg) and apply my algorithm (hough), so
> >>> finally I want to draw lines in my result image. Can anyone help me
> >>> with this. I've been several hours in this.
> >>>
> >>>
> >>> Best!
> >>>
> >>>
> >>> Francisco.
> >>>
> >>> --
> >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html