Login  Register

Re: macro problem

Posted by Michael Schmid on Jan 07, 2019; 1:58pm
URL: http://imagej.273.s1.nabble.com/macro-problem-tp5021600p5021601.html

Hi Martin,

you don't need the run("Measure") command, and anyhow you would have to
measure after the user has selected the points (after the waitForUser
statement).

The following five lines
    getSelectionCoordinates(xpoints, ypoints);
    count = xpoints.length;
    row = nResults;
    setResult("Label", row, getTitle());
    setResult("Count", row, count);
should go into the loop, after the "wait for user".
The code in this lines writes the name of the image and the number of
points selected by the user to the Results table.

By the way, there is a semicolon missing at the end of line 2, "h = 2160".

Michael
________________________________________________________________
On 06.01.19 11:16, Braekevelt Martin wrote:

> Dear all,
>
> I am struggling with this macro, to just open images one by one, closing them after a point count and get the results in exell format from the count results from each image.
> I included thee macro code with some adjustments from Michael, but some things are not working :
> I don't get the counts/image and the results file doesn't get saved on my desktop.
>
> w = 4096;
> h = 2160
>    dir = getDirectory("Choose Source Directory ");
>    list = getFileList(dir);
>    for (i=0; i<list.length; i++) {
>       showProgress(i+1, list.length);
>       open(dir+list[i]);
>       run("Set Measurements...", "display redirect=None decimal=0");
>       run("Canvas Size...", "width=&w height=&h position=Center zero");
>       run("Maximize");
>       setLocation(0,0);
>       run("Unsharp Mask...", "radius=1 mask=0.60");
>                 run("Grid...", "grid=Crosses area=85700 color=green bold center");
>       run("Set... ", "zoom=50");
>       setTool("multipoint");
>       run("Point Tool...", "type=Dot color=Red size=[Extra Large] label show counter=0");
>       run("Measure");
>       waitForUser("Your Action Required", "Double click when point is inside,\n one click when on     border or on doubt.\nThen press OK");
>      close();
>    }
> getSelectionCoordinates(xpoints, ypoints);
>     count = xpoints.length;
> row = nResults;
>     setResult("Label", row, getTitle());
>     setResult("Count", row, count);
> saveAs("Results", "C:/Users/Martin.Braekevelt/Desktop/Results.xls");
>
> I would appreciate it very much if someone could help me to get this macro working.
> I also made an icon to get it into the ImageJ GUI, I would also like some help for that.
> This is the code below
> macro "myTool Tool - C3f0D34D36D45D94DacDf0C0f0D02D04D11D18D25D26D27D28D30D31D41D64D6dD78D87D8dDc2Dc9DceDe1DffCff0D01D08D0bD0cD0dD0eD10D12D14D15D16D17D19D1aD1dD21D23D2bD2cD32D39D3aD3bD3eD3fD44D47D4aD4cD4dD50D51D52D53D54D56D58D5bD63D66D67D69D6aD6eD6fD71D73D74D76D79D7cD7eD82D89D91D93D96D97D99D9aD9dDa0Da8DadDaeDafDb0Db1Db2Db3Db5Db6DbaDbcDbdDbeDc0Dc1Dc4DcaDcdDd0Dd1Dd2Dd3Dd4Dd5DdcDddDdfDe0De4De5De6De7De8DedDeeDefDf2Df4Df6Df8DfaDfbDfdCcf0D35D38D48D4bD5dD65D7aDa4DcfCf90D03D07D0fD1cD1eD20D6cD7bD7dD81D85D8bD95D9eDa5Da6Da7DaaDb4Db7DbfDc5Dd6Dd7Dd9DeaDecDfcC7f0D2dD40D60D6bD77Cf20D13D29D33D4fD57D70D8aD9bDa9Dc3"{
>
> }
>
> Thank you very much in advance.
> Kindest regards,
> Martin

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