Login  Register

Re: ROI questions...

Posted by Martin du Saire on Jun 23, 2006; 9:47pm
URL: http://imagej.273.s1.nabble.com/Basic-ROI-questions-tp3702395p3702405.html

If I understand your problem, you want to be able to select ROIs and
process them individually and still have access the the final image
or intermediate images?  If so one option would be to explicitly save
the image.  If you don't close it, you can access it using
selectWindow() or selectImage(), otherwise, re-open the image with open():


open("C:\\Image_directory\\image1.tif");
makeRectangle(x, y, width, height);
run("Duplicate...", "title=roi_1");
saveAs("Tiff", "C:\\Image_directory\\roi_1.tif");
run("Duplicate...", "title=roi_1_background.tif");
saveAs("Tiff", "C:\\Image_directory\\roi_1_background.tif");
selectWindow("roi_1.tif");

<< Do whatever you want to with this copy of the ROI  >>

saveAs("Tiff", "C:\\Image_directory\\processed_roi_1.tif");

selectWindow("roi_1_background.tif");

<<  Do whatever with this second copy of the ROI  >>

saveAs("Tiff", "C:\\Image_directory\\processed_roi_1_background.tif");

If you don't want to go through the hassle of reading and writing
images to disk, just duplicate and rename the images you want to
"keep" for later use.

Of course, I may have completely misunderstood what you are trying to
do...Hope this helps.

M

At 12:00 PM 6/23/2006, you wrote:

>Sorry, I can't get my head round this... Basically, my macro has:
>
>run("Crop"); // A cropped image
>threshold(); // This is threshold with my function
>
>What I would like to do is this:
>
>Fit a bounding box to crop this newly threshold image:
>
>getSelectionBounds(x, y, width, height);
>makeRectangle(x, y, width, height);
>run("Crop");
>roiManager("Add"); // The ROI found from the threshold is added to the
>manager
>
>AND the new run("Crop") image with the roiManager("Add") ROI to delete
>the background. I guess using:
>
>imageCalculator("AND create", CropImage, ROI);
>
>I would like to save both the newly cropped-to-ROI and deleted
>background image AND the ROI. This will allow me to open these 2 in the
>future to do some analyses on them - morphological, textural, etc.
>
>I hope this makes sense and that someone can help me out?!
>
>Thanks, Andy
>
>On Fri, 2006-06-23 at 10:16 -0400, Wayne Rasband wrote:
> > > In essence, at each 'processing' point in my macro I want to store
> > > (not necessarily save) the result (ROI, image, etc) which can be
> > > called when ANDing, etc later in my macro. So for example, if I:
> > >
> > > doWand(getResult("XStart",index), getResult("YStart",index));
> > >
> > > I want to store that ROI as a variable which can be called later
> > > in my macro for subsequent processing/saving. I've searched
> > > the archives for an answer to no avail...
> >
> > Save the ROIs in the ROI Manager. Here are some example macros that do
> > this:
> >
> >        http://rsb.info.nih.gov/ij/macros/RoiManagerMacros.txt
> >        http://rsb.info.nih.gov/ij/macros/ROI_Manager_Stack_Demo.txt
> >        http://rsb.info.nih.gov/ij/macros/RoiManagerAddParticles.txt
> >
> > The ROI Manager macro functions are described at:
> >
> >
> > http://rsb.info.nih.gov/ij/developer/macro/functions.html#roiManager
> >
> > -wayne