Clean-up ROIs

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Clean-up ROIs

CARL Philippe (LBP)
Dear all,
Please find under the following link:
http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
a picture of two ROIs.
The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
As the right ROI is obtained by a "by hand cleaning" of the right one.
My question is whether there may be a way to perform such a "cleaning" automatically?
I thank you very much in advance for your lighting on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

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

Re: Clean-up ROIs

Gabriel Landini
The right one is 4-connected, the left one is 8-connected.
IJ natively supports 8-connected regions.

You can analyse 4-connected regions using  the Particles4 plugin, but before
jumping into that, please make sure that you understand the implications of
changing the connectivity of your regions.

Cheers

Gabriel


On Friday, 17 January 2020 14:02:17 GMT you wrote:

> Dear all,
> Please find under the following link:
> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
> a picture of two ROIs.
> The ROI on the left had been obtained through a threshold process followed
> by an Analyze particles. As the right ROI is obtained by a "by hand
> cleaning" of the right one. My question is whether there may be a way to
> perform such a "cleaning" automatically? I thank you very much in advance
> for your lighting on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> --
> 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: Clean-up ROIs

Michael Schmid-3
In reply to this post by CARL Philippe (LBP)
Hi Philippe,

if you convert the rois to a mask, you can use the wand tool in
4-connected mode to select only the core.

You will need to find an initial pixel for the wand.

Among all pixels contained in the roi, I would try to use the pixel
closest to the roi center as a starting position for the wand.
This staring position will not work if you have crescent-shaped
particles and the center happens to be at a small 'side particle' on the
concave side of the crescent. If this can happen, you will have to try
all different starting positions in the roi and see which one gives the
largest area (for each roi tried, change the value of the mask to
something else than 255 inside the roi, then you know that you don't
need to try that point again).

Java method:
(new Wand(ip)).autoOutline(startX, startY, /*tolerance=*/0,
Wand.FOUR_CONNECTED)

Best,

Michael
________________________________________________________________

On 17.01.20 15:02, CARL Philippe (LBP) wrote:

> Dear all,
> Please find under the following link:
> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
> a picture of two ROIs.
> The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
> As the right ROI is obtained by a "by hand cleaning" of the right one.
> My question is whether there may be a way to perform such a "cleaning" automatically?
> I thank you very much in advance for your lighting on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> --
> 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: Clean-up ROIs

Peter Haub
In reply to this post by CARL Philippe (LBP)
Dear Phillipe,

here is one way to split your object:

If your ROI is displayed as a binary image with an intensity << 255,
e.g. 10,
then you can convolve it (Process>Filters>Convolve) with the following
kernel (kernel should be normalized )

0 1 0
1 4 1
0 1 0

This will separate all pixels with edge neighbors from those with only
corner neighbors.
You can use threshold to restore the original image but without pixels
with only corner neighbors.
Since this pixels with only corner neighbors are the 'connectors' you
want to get rid of you have separated objects after thresholding the
convolved image.

If necessary you can identify the largest of the splitted objects by
using the ultimate point created on the original 'ROI image'.

Hope that gives you a start.

Regards,
Peter




On 17.01.2020 15:02, CARL Philippe (LBP) wrote:

> Dear all,
> Please find under the following link:
> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
> a picture of two ROIs.
> The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
> As the right ROI is obtained by a "by hand cleaning" of the right one.
> My question is whether there may be a way to perform such a "cleaning" automatically?
> I thank you very much in advance for your lighting on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> --
> 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: Clean-up ROIs

CARL Philippe (LBP)
In reply to this post by Michael Schmid-3
Dear Gabriel, Michael and Peter,
Thanks a lot for your replies and lightings on my question.
Peter, I tried to follow your suggested recipie, but unless I missed something, I wasn't able to reach the wished results.
Thus I will finally implement (in java) the solution proposed by Michael which I validated by a use "by hand".
Very nice end of weekend for everybody!
My best regards,
Philippe

----- Le 17 Jan 20, à 15:25, Michael Schmid [hidden email] a écrit :

Hi Philippe,

if you convert the rois to a mask, you can use the wand tool in
4-connected mode to select only the core.

You will need to find an initial pixel for the wand.

Among all pixels contained in the roi, I would try to use the pixel
closest to the roi center as a starting position for the wand.
This staring position will not work if you have crescent-shaped
particles and the center happens to be at a small 'side particle' on the
concave side of the crescent. If this can happen, you will have to try
all different starting positions in the roi and see which one gives the
largest area (for each roi tried, change the value of the mask to
something else than 255 inside the roi, then you know that you don't
need to try that point again).

Java method:
(new Wand(ip)).autoOutline(startX, startY, /*tolerance=*/0,
Wand.FOUR_CONNECTED)

Best,

Michael
________________________________________________________________

On 17.01.20 15:02, CARL Philippe (LBP) wrote:

> Dear all,
> Please find under the following link:
> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
> a picture of two ROIs.
> The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
> As the right ROI is obtained by a "by hand cleaning" of the right one.
> My question is whether there may be a way to perform such a "cleaning" automatically?
> I thank you very much in advance for your lighting on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
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: Clean-up ROIs

Peter Haub
Hi Philippe,

assuming an 8bit image with black background (=0) and bright object
pixels (=255) which are representing your ROI, try the following macro
to delete the 'connector' pixels (the pixels which are only connected at
their corners):

run("Convolve...", "text1=[0 1 0\n1 4 1\n0 1 0\n] normalize");
setThreshold(150, 255);
setOption("BlackBackground", true);
run("Convert to Mask");

By the way,
if you implement Michaels solution, you can use the coordinates of the
'Ultimate points' of a binary image as starting point x, y of the wand tool.


Regards,
Peter


On 19.01.2020 19:03, CARL Philippe (LBP) wrote:

> Dear Gabriel, Michael and Peter,
> Thanks a lot for your replies and lightings on my question.
> Peter, I tried to follow your suggested recipie, but unless I missed something, I wasn't able to reach the wished results.
> Thus I will finally implement (in java) the solution proposed by Michael which I validated by a use "by hand".
> Very nice end of weekend for everybody!
> My best regards,
> Philippe
>
> ----- Le 17 Jan 20, à 15:25, Michael Schmid [hidden email] a écrit :
>
> Hi Philippe,
>
> if you convert the rois to a mask, you can use the wand tool in
> 4-connected mode to select only the core.
>
> You will need to find an initial pixel for the wand.
>
> Among all pixels contained in the roi, I would try to use the pixel
> closest to the roi center as a starting position for the wand.
> This staring position will not work if you have crescent-shaped
> particles and the center happens to be at a small 'side particle' on the
> concave side of the crescent. If this can happen, you will have to try
> all different starting positions in the roi and see which one gives the
> largest area (for each roi tried, change the value of the mask to
> something else than 255 inside the roi, then you know that you don't
> need to try that point again).
>
> Java method:
> (new Wand(ip)).autoOutline(startX, startY, /*tolerance=*/0,
> Wand.FOUR_CONNECTED)
>
> Best,
>
> Michael
> ________________________________________________________________
>
> On 17.01.20 15:02, CARL Philippe (LBP) wrote:
>> Dear all,
>> Please find under the following link:
>> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
>> a picture of two ROIs.
>> The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
>> As the right ROI is obtained by a "by hand cleaning" of the right one.
>> My question is whether there may be a way to perform such a "cleaning" automatically?
>> I thank you very much in advance for your lighting on this.
>> My best regards,
>> Philippe
>>
>> Philippe CARL
>> Laboratoire de Bioimagerie et Pathologies
>> UMR 7021 CNRS - Université de Strasbourg
>> Faculté de Pharmacie
>> 74 route du Rhin
>> 67401 ILLKIRCH
>> Tel : +33(0)3 68 85 41 84
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> 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: Clean-up ROIs

CARL Philippe (LBP)
Hi Peter,
I further tried to play with your proposed solution and will stay with the one proposed by Michael which gives better results on a couple of tried examples.
Nevertheless, your idea of using a kernel convolution in order to locate the "'Ultimate points' of a binary image as starting point x, y of the wand tool" is indeed excellent.
And definitely quite better than my 'more simple' idea of using the median of the ROI coordinates as starting point.
Especially there is a nice convolve3x3 method within the ByteProcessor class that will nicely doing the job on the output of a createRoiMask() method from the ImagePlus class!!!
Thanks a lot for your reply and have a nice day.
My best regards,
Philippe

----- Le 20 Jan 20, à 7:28, Peter Haub [hidden email] a écrit :

Hi Philippe,

assuming an 8bit image with black background (=0) and bright object
pixels (=255) which are representing your ROI, try the following macro
to delete the 'connector' pixels (the pixels which are only connected at
their corners):

run("Convolve...", "text1=[0 1 0\n1 4 1\n0 1 0\n] normalize");
setThreshold(150, 255);
setOption("BlackBackground", true);
run("Convert to Mask");

By the way,
if you implement Michaels solution, you can use the coordinates of the
'Ultimate points' of a binary image as starting point x, y of the wand tool.


Regards,
Peter


On 19.01.2020 19:03, CARL Philippe (LBP) wrote:

> Dear Gabriel, Michael and Peter,
> Thanks a lot for your replies and lightings on my question.
> Peter, I tried to follow your suggested recipie, but unless I missed something, I wasn't able to reach the wished results.
> Thus I will finally implement (in java) the solution proposed by Michael which I validated by a use "by hand".
> Very nice end of weekend for everybody!
> My best regards,
> Philippe
>
> ----- Le 17 Jan 20, à 15:25, Michael Schmid [hidden email] a écrit :
>
> Hi Philippe,
>
> if you convert the rois to a mask, you can use the wand tool in
> 4-connected mode to select only the core.
>
> You will need to find an initial pixel for the wand.
>
> Among all pixels contained in the roi, I would try to use the pixel
> closest to the roi center as a starting position for the wand.
> This staring position will not work if you have crescent-shaped
> particles and the center happens to be at a small 'side particle' on the
> concave side of the crescent. If this can happen, you will have to try
> all different starting positions in the roi and see which one gives the
> largest area (for each roi tried, change the value of the mask to
> something else than 255 inside the roi, then you know that you don't
> need to try that point again).
>
> Java method:
> (new Wand(ip)).autoOutline(startX, startY, /*tolerance=*/0,
> Wand.FOUR_CONNECTED)
>
> Best,
>
> Michael
> ________________________________________________________________
>
> On 17.01.20 15:02, CARL Philippe (LBP) wrote:
>> Dear all,
>> Please find under the following link:
>> http://punias.free.fr/ImageJ/Clean_up_ROIs.jpg
>> a picture of two ROIs.
>> The ROI on the left had been obtained through a threshold process followed by an Analyze particles.
>> As the right ROI is obtained by a "by hand cleaning" of the right one.
>> My question is whether there may be a way to perform such a "cleaning" automatically?
>> I thank you very much in advance for your lighting on this.
>> My best regards,
>> Philippe
>>
>> Philippe CARL
>> Laboratoire de Bioimagerie et Pathologies
>> UMR 7021 CNRS - Université de Strasbourg
>> Faculté de Pharmacie
>> 74 route du Rhin
>> 67401 ILLKIRCH
>> Tel : +33(0)3 68 85 41 84
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

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