fill holes based on size filter

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

fill holes based on size filter

PEARSON Matthew
Hi all,

I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?

Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?

Thanks for the help,

Matt




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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

Re: fill holes based on size filter

Krs5
Dear Matt,

I would select the larger holes that you want to reject via Analyze Particles and set the Size + Add to Manager. Highlight all the ROIs found in the manager and select More>> OR (Combine). Add this selection to the manager. Select this ROI and Edit > Selection > Make Inverse. Now you have selected everything except the larger holes and you can do your measurements.

But maybe somebody else knows a more elegant way to do this?

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of PEARSON Matthew
Sent: 21 May 2015 14:32
To: [hidden email]
Subject: fill holes based on size filter

Hi all,

I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?

Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?

Thanks for the help,

Matt




--
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

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

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

Re: fill holes based on size filter

PEARSON Matthew
Hi Keys,

I've attached an image so you can see what i mean, the image has been processed to highlight the invading cells more clearly and has made thresholding easier.  This is with limit to threshold and include holes selected.  I'm measuring the total area of the cells but don't want to count the centre of the spheroid in the area measurement as i think it is doing here.  When you threshold this image, indeed the dark centre is not included in the threshold, so according to, limit to threshold, this central area wouldn't form part of the area measurement but because i have enabled fill holes, it is being counted?

There are some small sparse areas within the cell mass that don't form part of the the threshold but i would like to include using fill holes but then i also get the circular centre too.. This is all done through a macro, so would like to keep physical interaction to a minimum if possible.

I could probably threshold purely for the centre of the spheroid and subtract its area measurement from the whole but thats a few extra steps that i'd like to avoid if its possible, if not i can live with it.

Thanks for the advice,

Matt




On 21 May 2015, at 16:41, Straatman, Kees (Dr.) wrote:

> Dear Matt,
>
> I would select the larger holes that you want to reject via Analyze Particles and set the Size + Add to Manager. Highlight all the ROIs found in the manager and select More>> OR (Combine). Add this selection to the manager. Select this ROI and Edit > Selection > Make Inverse. Now you have selected everything except the larger holes and you can do your measurements.
>
> But maybe somebody else knows a more elegant way to do this?
>
> Best wishes
>
> Kees
>
>
> Dr Ir K.R. Straatman
> Senior Experimental Officer
> Advanced Imaging Facility
> Centre for Core Biotechnology Services
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of PEARSON Matthew
> Sent: 21 May 2015 14:32
> To: [hidden email]
> Subject: fill holes based on size filter
>
> Hi all,
>
> I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?
>
> Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?
>
> Thanks for the help,
>
> Matt
>
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Matt Pearson
Microscopy Facility
MRC Human Genetics Unit
IGMM
University of Edinburgh
Crewe Road
EH4 2XU


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

Re: fill holes based on size filter

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by PEARSON Matthew
> On May 21, 2015, at 9:31 AM, PEARSON Matthew <[hidden email]> wrote:
>
> Hi all,
>
> I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?

The particle analyzer ignores the “Limit to threshold” setting. Non-thresholded areas (“holes”) within objects are measured if the “Include holes” option is enabled.

-wayne

> Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?
>
> Thanks for the help,
>
> Matt
>
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


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

Re: fill holes based on size filter

PEARSON Matthew
Ah i see that make sense that one would yield to the other, good to know.

Many thanks,

Matt

On 21 May 2015, at 17:39, Rasband, Wayne (NIH/NIMH) [E] wrote:

On May 21, 2015, at 9:31 AM, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote:

Hi all,

I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?

The particle analyzer ignores the “Limit to threshold” setting. Non-thresholded areas (“holes”) within objects are measured if the “Include holes” option is enabled.

-wayne

Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?

Thanks for the help,

Matt




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


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

--
Matt Pearson
Microscopy Facility
MRC Human Genetics Unit
IGMM
University of Edinburgh
Crewe Road
EH4 2XU


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

Re: fill holes based on size filter

Anderson, Charles (DNR)
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:

Create your template - A.
Duplicate it - B.
On A, analyze particles and create a template or mask - C.
On B, analyze particles including holes and create a template or mask - D.
Calculate D-C (or maybe C-D) to obtain a mask showing only the holes - E.
On E, analyze particles for the sizes to include and create mask of them - F.
Calculate A+F. This should have filled the holes you wanted to include - G.
On G, analyze particles (or use the mask for other).

Charles

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of PEARSON Matthew
Sent: Friday, May 22, 2015 6:13 AM
To: [hidden email]
Subject: Re: fill holes based on size filter

Ah i see that make sense that one would yield to the other, good to know.

Many thanks,

Matt

On 21 May 2015, at 17:39, Rasband, Wayne (NIH/NIMH) [E] wrote:

On May 21, 2015, at 9:31 AM, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote:

Hi all,

I just wanted to clarify something in imageJ.  I'm using both "include holes" in analyse particles and "limit to threshold" in set measurements.  If there is an area within my thresholded object that is not included in the threshold yet is completely encapsulated by the threshold, what will be measured?  Limit to threshold suggests, this non-thresholded area would not be measured but include holes suggests it would be measured?

The particle analyzer ignores the "Limit to threshold" setting. Non-thresholded areas ("holes") within objects are measured if the "Include holes" option is enabled.

-wayne

Which leads me on to the real problem at hand, i'd like to be able to filter the holes i am including based on size.  Smaller holes, enclosed by the threshold i'd include up to a certain size and holes any bigger i want to reject.  Is there a simple way to do this?

Thanks for the help,

Matt




--
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

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


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

--
Matt Pearson
Microscopy Facility
MRC Human Genetics Unit
IGMM
University of Edinburgh
Crewe Road
EH4 2XU


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

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

Re: fill holes based on size filter

Gabriel Landini
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
Reply | Threaded
Open this post in threaded view
|

Re: fill holes based on size filter

PEARSON Matthew
Hi all,

Thanks for your comments on this, i think i have found a solution to my analysis problem which doesn't require the hole filtering but its useful to know in future that this is possible with the morphology plugins.

Thanks,

Matt

On 22 May 2015, at 16:24, Gabriel Landini wrote:

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

--
Matt Pearson
Microscopy Facility
MRC Human Genetics Unit
IGMM
University of Edinburgh
Crewe Road
EH4 2XU


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

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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