Extract each ROI, dilate each roi and measure area individually

Hello there,
I have a binary image with several hundreds of particles where I would like to:

  1. “somehow” seperate/extract the individual ROIs
  2. then dilate each ROI with 2 pixel individually
  3. measure the area of the dilated ROIs and save the results.
    I was also looking at this post: Saving each ROI as individual images where step was already discussed, but I need some help for a general/scripted workflow.

If someone has an Idea would be great ;), thank you!

Hey again:
with this code from the linked post I was able to save all identified ROIs as an individual image, so step 1 is done with this:

for(N=0;N<roiManager(“Count”);N++){
roiManager(“Select”,N);
run(“Copy”);
newImage(“Untitled-”+N, “RGB white”, 400, 400, 1);
run(“Paste”);
saveAs(“Jpeg”, “C:\particles\Particle”+N+".jpeg");
close();
}

Here is an full ImageJ macro example how to measure particles, add them to the ROIManager, enlarge and measure them (enlarged area) by iterating over all ROI’s in the Manager.

run("Cell Colony (31K)");
setAutoThreshold("Default");
run("Analyze Particles...", "clear add");

n = roiManager("count");
for (i = 0; i < n; i++) {
    roiManager("select", i);
    run("Enlarge...", "enlarge=2");
    roiManager("update")//Replaces the selected ROI on the list with the current selection.
    roiManager("select", i);
    roiManager("Measure");
    
}

Thanks!!! I will try it,
I was using this script to save the enlarged particles, is there a difference between enlarge and maximum filter?

setOption(“BlackBackground”, false);
run(“Make Binary”);
run(“Analyze Particles…”);
for(N=0;N<roiManager(“Count”);N++){
roiManager(“Select”,N);
run(“Copy”);
newImage(“Untitled-”+N, “RGB white”, 600, 600, 1);
run(“Paste”);
saveAs(“Jpeg”, “C:\particles\Particle”+N+".jpeg");
setOption(“BlackBackground”, false);
run(“Make Binary”);
run(“Maximum…”, “radius=2”);
saveAs(“Jpeg”, “C:\particles\NewParticle”+N+".jpeg");
close();
}

Have a look at the documentation and select which fits for you:

https://imagej.nih.gov/ij/docs/guide/146-27.html#toc-Subsection-27.12

Enlarge enlarges the selection whereas Maximum is a filter:

https://imagej.nih.gov/ij/docs/guide/146-29.html#toc-Subsection-29.11

Tip: Use the macro recorder to get the macro commands for a GUI feature:

https://imagej.nih.gov/ij/docs/guide/146-31.html#sub:Macros