Posted by
Gabriel Landini on
May 22, 2015; 3:22pm
URL: http://imagej.273.s1.nabble.com/fill-holes-based-on-size-filter-tp5012897p5012917.html
On Friday 22 May 2015 14:58:46 Anderson, Charles wrote:
> I wish ImageJ's Analyze Particles had the option to report Parent - Child
> relationships of objects/holes/objects in holes and their measurements
> (such as I think Matlab does). Without this, to include holes of a
> specified size range requires creating a template of the holes, filtering
> holes by size, and then combining the holes-of-interest with the original
> template, with this outline:
Yes here is a simpler way to do all this.
Create a binary image of the object you want to analyse. Then perform the
particle analysis on that.
If you need greyscale values of pixels, then redirect the result to the
original.
If you need filtering the holes of sizes <n, then invert the binary image
(holes become regions), floodfill from borders to kill the background and keep
regions >=n.
Then add the result to the original mask (therefore you fill the holes which
are <n).
You can do all this with the Morphology plugins. Example for filling holes
smaller than 10 pixels (I am using white regions on black background):
run("AuPbSn 40 (56K)");
setAutoThreshold("Default");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Duplicate...", "title=holes");
run("Invert");
run("BinaryKillBorders ", "top right bottom left white");
run("Particles8 ", "white show=Particles filter minimum=10 maximum=9999999
display redirect=None");
imageCalculator("Add", "AuPbSn40.jpg","holes");
Then you can run the particle analyzer or Particles8 again redirecting to the
greyscale image to get greyscale statistics.
There is also an advantage in separating the segmentation/thresholding from
the analysis: you can do some more pre-processing on the binary result if
needed (closing, opening, etc) before getting the greyscale data.
Cheers
Gabriel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html