Login  Register

Re: Analyze Particles Overlay problems

Posted by Wayne Rasband-2 on Dec 14, 2018; 7:24am
URL: http://imagej.273.s1.nabble.com/Analyze-Particles-Overlay-problems-tp5021557p5021570.html

> On Dec 13, 2018, at 5:01 AM, Stein Rørvik <[hidden email]> wrote:
>
> Thanks, this works great!
>
> Overlay.setFontSize is not mentioned in the macro documentation.
>
> How can I change the label color as well?
> A corresponding Overlay.setFontColor function could be useful.

The latest daily build adds an Overlay.setLabelColor() function. There are two versions, one that sets the label color and another that sets both the label and background color. This function, and other new functions, are in the macro documentation at

   http://wsr.imagej.net/developer/macro/functions.html

Here is an updated version of the example macro:

  run("T1 Head (2.4M, 16-bits)");
  setThreshold(150, 65535);
  setSlice(60);
  run("Analyze Particles...", "size=400 show=Overlay slice");
  setThreshold(250, 65535);
  setSlice(62);
  run("Analyze Particles...", "size=400 show=Overlay slice");
  resetThreshold;
  Roi.remove;
  Overlay.setStrokeColor("red");
  Overlay.setStrokeWidth(1);
  Overlay.setLabelFontSize(12, "bold scale");
  Overlay.setLabelColor("cyan","black");
  run("In [+]"); run("In [+]”);

-wayne

> -----Original Message-----
> From: ImageJ Interest Group <[hidden email]> On Behalf Of Wayne Rasband
> Sent: 13. desember 2018 03:39
> To: [hidden email]
> Subject: Re: Analyze Particles Overlay problems
>
>> On Dec 12, 2018, at 5:12 AM, Stein Rørvik <[hidden email]> wrote:
>>
>> I want to run Analyze Particles on a stack, but only on specific slices.
>> I want the results (which particles were analyzed or not) to be shown as an overlay.
>> If I say yes to process all slices, the results are as expected:
>> There is an individual overlay for each slice.
>>
>> But if I want to analyze a single slice, the result overlay is "global"; that is, one overlay for the entire stack. So when I process another slice, the previous result overlay is lost. I think the overlay should have been applied to a single slice position in this case as well.
>>
>> Am I missing an option somewhere? Or is this a bug?
>
> It’s a bug that is fixed in the daily build (1.52j26). The following example runs the particle analyzer on two slices of a stack and set the overlay color to red.
>
> -wayne
>
>  run("T1 Head (2.4M, 16-bits)");
>  setThreshold(150, 65535);
>  setSlice(60);
>  run("Analyze Particles...", "size=400 show=Overlay slice");
>  setThreshold(250, 65535);
>  setSlice(62);
>  run("Analyze Particles...", "size=400 show=Overlay slice");
>  resetThreshold;
>  for (i=0; i<Overlay.size; i++) {
>     Overlay.activateSelection(i);
>     Roi.setStrokeColor("red");
>     Roi.setStrokeWidth(1);
>  }
>  Roi.remove;
>  Overlay.setFontSize(18);
>  run("In [+]"); run("In [+]”);
>
>
>> Also, I cannot figure out where in the preferences/options to set the result overlay colors (outline color and label color), nor how to do this in a macro.
>>
>> Demo macro, illustrating what I want to do:
>> ------------------------------
>>
>> //analyze entire stack
>> run("T1 Head (2.4M, 16-bits)");
>> setThreshold(350, 65535);
>> run("Analyze Particles...", "size=10-Infinity pixel show=Overlay
>> stack"); setSlice(nSlices/2); //results are as expected; an individual
>> overlay for each slice
>>
>> //analyze slice 30 and 60
>> run("T1 Head (2.4M, 16-bits)");
>> setThreshold(350, 65535);
>> setSlice(30);
>> run("Analyze Particles...", "size=10-Infinity pixel show=Overlay
>> slice"); setSlice(60); run("Analyze Particles...", "size=10-Infinity
>> pixel show=Overlay slice");
>>
>> setSlice(30);
>> //problem: overlay is per stack, not per slice, so the result overlay
>> for slice 30 was lost
>>
>> run("Tile");
>>
>> ------------------------------
>>
>> I am using daily build ImageJ 1.52j with Java 1.6 on Windows 7/64-bit.
>>
>>
>> Stein

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