numeric polygon selection tool?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

numeric polygon selection tool?

g.bachelier
Hello,

how can I select polygons in pixel
x,y-coordinates numerically like

P1: 20, 30
P2: 221, 30
P3: 121, 204

I want to select geometrical exact polygons
like an equilateral triangle in batch jobs.


thank you for your help
Günter
Reply | Threaded
Open this post in threaded view
|

Re: numeric polygon selection tool?

Bo de Lange
Günter Bachelier wrote:

> Hello,
>
> how can I select polygons in pixel
> x,y-coordinates numerically like
>
> P1: 20, 30
> P2: 221, 30
> P3: 121, 204
>
> I want to select geometrical exact polygons
> like an equilateral triangle in batch jobs.
>
>
> thank you for your help
> Günter
>  
Use the macro recorder to obtain syntax.
Open an image.
Run the Macro Recorder (Plugins:Macro:Record),
select the polygon tool, make one and
see the correct macro language required:

setTool(2);
makePolygon(26,61,36,122,103,144,186,156,218,124,230,75,196,57,119,43,63,46);

The first line sets the polygon tool (when not already selected),
the second line describes each point sequentially: x,y,x,y,x,y etc.

Run this macro to see how it works:

run("Blobs (25K)");
setTool(2);
makePolygon(1,1,256,1,128,254,1,1);

There is in fact no need to for the last x,y to be the same as the
first. If you leave out the last ,1,1 you'll get the same polygon: it
closes automatically

Bo
Reply | Threaded
Open this post in threaded view
|

unsubscribe

Gary Winans
In reply to this post by g.bachelier
i would like to be taken off the list temporarily
Reply | Threaded
Open this post in threaded view
|

Re: numeric polygon selection tool?

g.bachelier
In reply to this post by Bo de Lange
Hello Bo de Lange,


> Run the Macro Recorder (Plugins:Macro:Record),
> select the polygon tool, make one


in the recorder window "setTool(2);" is shown in the
first line but after I made the selection no "makePolygon(...)"
is shown. But it works with the other tools like

setTool(1);
makeOval(...);


In the tool window the active pixel is also
not shown with pixel coordinate but with inches. How can
this be changed?


However after typing "makePolygon(20,30,221,30,121,204)"
in the second line, saving and running the macro I get the
error message

undefined identifier in line 2 <makePolygon>(20,30,221,30,121,204);

First I thought this is because of the pixel vs. inches coordinates
and I tried "makePolygon(1.07,0.24,2.59,0.24,1.52,1.556);
but I get an equivalent error message.


Günter





Bo de Lange wrote:

> Use the macro recorder to obtain syntax.
> Open an image.
> Run the Macro Recorder (Plugins:Macro:Record),
> select the polygon tool, make one and
> see the correct macro language required:
>
> setTool(2);
> makePolygon(26,61,36,122,103,144,186,156,218,124,230,75,196,57,119,43,63,46);
>
> The first line sets the polygon tool (when not already selected),
> the second line describes each point sequentially: x,y,x,y,x,y etc.
>
> Run this macro to see how it works:
>
> run("Blobs (25K)");
> setTool(2);
> makePolygon(1,1,256,1,128,254,1,1);
>
> There is in fact no need to for the last x,y to be the same as the
> first. If you leave out the last ,1,1 you'll get the same polygon: it
> closes automatically
>
> Bo
Reply | Threaded
Open this post in threaded view
|

Re: numeric polygon selection tool?

Wayne Rasband
> Hello Bo de Lange,
>
>> Run the Macro Recorder (Plugins:Macro:Record),
>> select the polygon tool, make one
>
> in the recorder window "setTool(2);" is shown in the
> first line but after I made the selection no "makePolygon(...)"
> is shown. But it works with the other tools like
>
> setTool(1);
> makeOval(...);

It sounds like you need to upgrade. Search the release notes at
<http://rsb.info.nih.gov/ij/notes.html> for "makePolygon" and you will
see that this function was added in ImageJ 1.35b. You can upgrade to
ImageJ 1.37e by downloading the file "ij.jar" from
<http://rsb.info.nih.gov/ij/upgrade/> and copying it into the ImageJ
folder.

> In the tool window the active pixel is also
> not shown with pixel coordinate but with inches.
> How can this be changed?

Open the Analyze>Set Scale dialog and set "Distance in Pixels" to 0.

-wayne