Login  Register

Re: Polygon surrounding multiple point selections

Posted by Paul van Schayck on Sep 17, 2014; 12:05pm
URL: http://imagej.273.s1.nabble.com/Background-subtraction-tp5009655p5009666.html

Hey Richard,

Are you looking for the convex hull command?

http://imagejdocu.tudor.lu/doku.php?id=gui:edit:selection#convex_hull

Kind regards,

Paul

On Wed, Sep 17, 2014 at 12:08 PM, Richard Mort <[hidden email]>
wrote:

> Hello list,
>
> Before I go through the effort of trying to solve this problem I thought
> I'd see if somene else has already done the same. I have a spatial pattern
> composed of lots of xy positions (see attached plot). I can find the
> bounding box for these positions using the code pasted at the end. How can
> I find a polygon that joins all the points at the edge of the pattern?
>
> Best
> R
>
> //Find bounding box of multiple xy positions
>
>
> run("Analyze Particles...", "display");
>
> //some variables
> max_x = 0;
> max_y = 0;
> min_x = 0;
> min_y = 0;
>
> //Max value in "XM" column
> for (a=0; a<nResults(); a++) {
>     if (getResult("XM",a)>max_x)
>     {
>      max_x = getResult("XM",a);
>         }
>         else{};
> }
>
> //Min value in "XM" column (note: requires max value)
> min_x=max_x;
> for (b=0; b<nResults(); b++) {
>     if (getResult("XM",b)<min_x)
>     {
>      min_x = getResult("XM",b);
>         }
>         else{};
> }
>
>
> //Max value in "YM" column
> for (c=0; c<nResults(); c++) {
>     if (getResult("YM",c)>max_y)
>     {
>      max_y = getResult("YM",c);
>         }
>         else{};
> }
>
> //Min value in "YM" column (note: requires max value)
> min_y=max_y;
> for (d=0; d<nResults(); d++) {
>     if (getResult("YM",d)<min_y)
>     {
>      min_y = getResult("YM",d);
>         }
>         else{};
> }
>
> print(min_x);
> print(max_x);
> print(min_y);
> print(max_y);
>
> makeRectangle(min_x, min_y, max_x-min_x, max_y-min_y);
>
> //end
>
> --
> Dr Richard Mort
> MRC Human Genetics Unit
> MRC IGMM
> University of Edinburgh
> Western General Hospital
> Crewe Road
> Edinburgh.
> EH4 2XU, UK
>
> Tel: +44 (0)131 332 2471
> Fax: +44 (0)131 467 8456
>
>
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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