Login  Register

Re: how to define a ROI with selection and thresholding

Posted by jchanson on Mar 25, 2013; 7:57pm
URL: http://imagej.273.s1.nabble.com/how-to-define-a-ROI-with-selection-and-thresholding-tp5002332p5002403.html

Zhengyu -
        If you save both your region the selection from Otsu thresholding to the ROI manager, you can use it's "AND" function to select only objects inside the original ROI.  Here's a script that use the ROI manager to do the AND and then cleans up the temporary ROIs when it's done.

Jeff Hanson
Senior Imaging Analyst
//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>//
makeRectangle(100, 100, 128, 128);
nROIs = roiManager("count");
roiManager("Add");
//run("Threshold...");
setAutoThreshold("Otsu dark");
run("Create Selection");
roiManager("Add");

// AND the ROIs
roiList = newArray(2);
roiList[0] = nROIs; roiList[1] = nROIs+1;
roiManager("select",roiList);
roiManager("AND");

// Delete the temporary ROIs
roiManager("select",roiList);
roiManager("delete");
//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>//

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Pang, Zhengyu (GE Global Research)
Sent: Thursday, March 21, 2013 11:23 AM
To: [hidden email]
Subject: how to define a ROI with selection and thresholding

Dear ImageJ colleagues,

I would like to use makeRectangle to identify a specific area I would like to work on, and then set a threshold using the OTSU method.  Next I want to make a selection with thresholded pixels within  the Rectangle.

makeRectangle(512, 512, 512, 512);
setAutoThreshold("Otsu dark");
run("Create Selection");
roiManager("Add");

I found that ImageJ created selection on the whole image with the thresholded value determined by the Rectangele. I really want to create selection only within the rectangle. How could I do that?


Thanks!

Zhengyu

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

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