Automatically detect circular ROI

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

Automatically detect circular ROI

MariaS


Dear everybody,

I am new to ImageJ and I am trying to automate the task of manually selecting a circular ROI.

I have this kind of images and I want everytime ImageJ to automatically detect the inside membrane, which is not exactly in the same position in every image. Then I want to Clear the Outside, so I can work on the region I am interested in. I tried with the plugin Hough Circles, but it doesn't really work; when I try to use it ImageJ crashes and I am not sure if it could give me the result I want, since I cannot use it.

It would be really helpful if somebody could give me some advice. Is there an available plugin which could perform this task?

Thank you in advance.
Maria
Reply | Threaded
Open this post in threaded view
|

Re: Automatically detect circular ROI

Straub, Volko A. (Dr.)
Hi Maria,

Here is a suggestion that might work based on the sample image:
- convert image to 8-bit greyscale
- auto threshold image using triangle method
- carry out a binary open (if you follow this by a binary dilate, you can smooth the edges a bit more)
- invert the image
- use analyse particle (size: 1000-Infinity; circularity: 0.5-1)
- for the sample image, this produces a nice selection of the filter
- you can then easily obtain the centre of the selection (Measure Centroid) and use this to create a circular selection if that is needed

Hope this helps,
Volko



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of MariaS
Sent: 13 November 2015 15:16
To: [hidden email]
Subject: Automatically detect circular ROI

<http://imagej.1557.x6.nabble.com/file/n5014946/petri_dish.jpg>

Dear everybody,

I am new to ImageJ and I am trying to automate the task of manually selecting a circular ROI.

I have this kind of images and I want everytime ImageJ to automatically detect the inside membrane, which is not exactly in the same position in every image. Then I want to Clear the Outside, so I can work on the region I am interested in. I tried with the plugin Hough Circles, but it doesn't really work; when I try to use it ImageJ crashes and I am not sure if it could give me the result I want, since I cannot use it.

It would be really helpful if somebody could give me some advice. Is there an available plugin which could perform this task?

Thank you in advance.
Maria



--
View this message in context: http://imagej.1557.x6.nabble.com/Automatically-detect-circular-ROI-tp5014946.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
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: Automatically detect circular ROI

Straub, Volko A. (Dr.)
In reply to this post by MariaS
Dear Maria,

Following my earlier response, I put together a macro that detects the
filter with your colonies, removes the gridlines and counts the colonies
(see code below, also attached as .ijm file). I think it does a
reasonable job on the sample image you posted, but struggles a bit when
colonies overlap a lot. That will probably require a bit of manual
editing at the end, which should be relatively straight forward in the
ROI manager.

Hope this helps,
Volko


imageName=getTitle;
run("8-bit");

//find filter and crop image
run("Duplicate...", "TempImage");

setAutoThreshold("Triangle");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Open");
run("Dilate");
run("Invert");
if(roiManager("count")>0){
     roiManager("Deselect");
     roiManager("Delete");
};
run("Analyze Particles...", "size=1000-Infinity circularity=0.5-1.00 add");
run("Set Measurements...", "area centroid bounding redirect=None
decimal=1");
run("Clear Results");
roiManager("Measure");
close();

diameter=minOf(getResult("Width",0),getResult("Height",0));
centreX=getResult("X",0)-diameter/2;
centreY=getResult("Y",0)-diameter/2;
selectWindow(imageName);
makeOval(centreX,centreY,diameter,diameter);
run("Crop");

//remove gridlines
run("Duplicate...", "TempImage");
run("Subtract Background...", "rolling=50");
setAutoThreshold("Triangle dark");
run("Convert to Mask");
run("Options...", "iterations=2 count=1 black do=Open");
run("Watershed");
run("Create Selection");
close();
selectWindow(imageName);
run("Restore Selection");
run("Clear Outside");

//detect colonies
run("Select None");
run("Duplicate...", "TempImage");
setAutoThreshold("MaxEntropy dark");
run("Convert to Mask");
run("Options...", "iterations=1 count=1 black do=Open");
run("Watershed");
if(roiManager("count")>0){
     roiManager("Deselect");
     roiManager("Delete");
};
run("Analyze Particles...", "add");
close();
selectWindow(imageName);
roiManager("Show All");



On 13/11/2015 15:16, MariaS wrote:

> <http://imagej.1557.x6.nabble.com/file/n5014946/petri_dish.jpg>
>
> Dear everybody,
>
> I am new to ImageJ and I am trying to automate the task of manually
> selecting a circular ROI.
>
> I have this kind of images and I want everytime ImageJ to automatically
> detect the inside membrane, which is not exactly in the same position in
> every image. Then I want to Clear the Outside, so I can work on the region I
> am interested in. I tried with the plugin Hough Circles, but it doesn't
> really work; when I try to use it ImageJ crashes and I am not sure if it
> could give me the result I want, since I cannot use it.
>
> It would be really helpful if somebody could give me some advice. Is there
> an available plugin which could perform this task?
>
> Thank you in advance.
> Maria
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Automatically-detect-circular-ROI-tp5014946.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Colony_Counter.ijm (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automatically detect circular ROI

Herbie
Chapeau Volko !

Am 14.11.15 um 09:11 schrieb Volko Straub:

> imageName=getTitle;
> run("8-bit");
>
> //find filter and crop image
> run("Duplicate...", "TempImage");
>
> setAutoThreshold("Triangle");
> setOption("BlackBackground", true);
> run("Convert to Mask");
> run("Open");
> run("Dilate");
> run("Invert");
> if(roiManager("count")>0){
>      roiManager("Deselect");
>      roiManager("Delete");
> };
> run("Analyze Particles...", "size=1000-Infinity circularity=0.5-1.00 add");
> run("Set Measurements...", "area centroid bounding redirect=None
> decimal=1");
> run("Clear Results");
> roiManager("Measure");
> close();
>
> diameter=minOf(getResult("Width",0),getResult("Height",0));
> centreX=getResult("X",0)-diameter/2;
> centreY=getResult("Y",0)-diameter/2;
> selectWindow(imageName);
> makeOval(centreX,centreY,diameter,diameter);
> run("Crop");
>
> //remove gridlines
> run("Duplicate...", "TempImage");
> run("Subtract Background...", "rolling=50");
> setAutoThreshold("Triangle dark");
> run("Convert to Mask");
> run("Options...", "iterations=2 count=1 black do=Open");
> run("Watershed");
> run("Create Selection");
> close();
> selectWindow(imageName);
> run("Restore Selection");
> run("Clear Outside");
>
> //detect colonies
> run("Select None");
> run("Duplicate...", "TempImage");
> setAutoThreshold("MaxEntropy dark");
> run("Convert to Mask");
> run("Options...", "iterations=1 count=1 black do=Open");
> run("Watershed");
> if(roiManager("count")>0){
>      roiManager("Deselect");
>      roiManager("Delete");
> };
> run("Analyze Particles...", "add");
> close();
> selectWindow(imageName);
> roiManager("Show All");

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

Re: Automatically detect circular ROI

MariaS
In reply to this post by Straub, Volko A. (Dr.)
Dear Volko,

This is so so helpful!! Thank you very much!
I try it and I will come back to you if I have any questions.
Thank you!! :)

Maria