Use macro to get maximum value and coordinate position

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

Use macro to get maximum value and coordinate position

xiaoleiwang
Hi all,

Now I try use macro to get maximum values and corresponding coordinate positions of many objects in one image. But now I have one problem. The code is posted below.

nMaxima = 50;
run("Point Tool...", "mark=0 label selection=blue");
run("Clear Results");
run("Find Maxima...","noise=50 output=[Single Points]");
getSelectionCoordinates(xx, yy);
xx = Array.trim(xx, nMaxima);
yy = Array.trim(yy, nMaxima);
makeSelection("point",xx, yy);
run("Set Measurements...", " mean");
run("Measure");

I used the "Blobs" samples in ImageJ to test the code. When I run it, there is warning: Selection required in line 5, getSelectionCoordinates(xx, yy<)>;. I don't understand what that mean? Would someone please to help me about this?
Thanks,
Xiaolei
Reply | Threaded
Open this post in threaded view
|

Re: Use macro to get maximum value and coordinate position

Michael Schmid
Hi Xiaolei,

to create a selection, you need output=[Point Selection], not [Single Points] in run("Find Maxima...", ...)

You can easily see this if you use Plugins>Macros>Record and do it manually.

Michael
________________________________________________________________
On Feb 28, 2014, at 16:52, xiaoleiwang wrote:

> Hi all,
>
> Now I try use macro to get maximum values and corresponding coordinate
> positions of many objects in one image. But now I have one problem. The code
> is posted below.
>
> nMaxima = 50;
> run("Point Tool...", "mark=0 label selection=blue");
> run("Clear Results");
> run("Find Maxima...","noise=50 output=[Single Points]");
> getSelectionCoordinates(xx, yy);
> xx = Array.trim(xx, nMaxima);
> yy = Array.trim(yy, nMaxima);
> makeSelection("point",xx, yy);
> run("Set Measurements...", " mean");
> run("Measure");
>
> I used the "Blobs" samples in ImageJ to test the code. When I run it, there
> is warning: Selection required in line 5, getSelectionCoordinates(xx,
> yy<)>;. I don't understand what that mean? Would someone please to help me
> about this?
> Thanks,
> Xiaolei

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Use macro to get maximum value and coordinate position

xiaoleiwang
Hi Michael,
Thank you for your information.
Actually, I want to create selection, and output single points image at same time. So would you please tell me how to change the macro code?
Thanks again.

Xiaolei
Reply | Threaded
Open this post in threaded view
|

Re: Use macro to get maximum value and coordinate position

Michael Schmid
On Feb 28, 2014, at 18:15, xiaolei wang wrote:

> Actually, I want to create selection, and output single points image at same
> time. So would you please tell me how to change the macro code?
> Thanks again.

Hi Xiaolei,

either run 'Find Maxima' twice with diffeent output or generate one type of output from the other.
E.g. if you have the multi-point selection, Edit>Selection>Create Mask gives you the image with the single points.

Note that no image named 'Mask' may be open when you run Edit>Selection>Create Mask, otherwise you add the points to the previous Mask.

Michael

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