Login  Register

Re: ROI questions...

Posted by Weller Andrew Francis on Jun 26, 2006; 3:51pm
URL: http://imagej.273.s1.nabble.com/Basic-ROI-questions-tp3702395p3702399.html

Thanks all for your help! Yes I had been using the macro recorder, but
it didn't really reproduce what I wanted. Currently I have:

        threshold(); // my function
        roiManager("Add");
        //run("Create Mask"); // Maybe?!?
        roiManager("select", 0); // select the first ROI
        selectImage(id);
        setPasteMode("AND");
        run("Paste");
        id1 = getImageID();
        save(dir2+"NEW_"+fileName+".tif");
        roiManager("deselect"); // clear the ROImanager ready for loop N

but this is now giving me a more-or-less blotchy background with my red
particle on it!? What I really need is:

a) my roi stored for future reference (I think this is easy to do/save)
b) a new image stored with a black or white background AND my particle
right there, not a red blob...

Maybe this is a silly error that's easy to rectify.

Cheers, Andy

On Fri, 2006-06-23 at 12:45 -0400, Wayne Rasband wrote:

> Here is an example macro that does an AND-mode paste of the "Masks"
> output of the particle analyzer to erase the background of the original
> image.
>
>      run("Blobs (25K)");
>      id = getImageID();
>      setAutoThreshold();
>      run("Analyze Particles...", "size=400 circularity=0.00 show=Masks
> exclude");
>      run("Copy");
>      selectImage(id);
>      setPasteMode("AND");
>      run("Paste");
>      resetThreshold();
>
> -wayne
>
>
> On Jun 23, 2006, at 7:45 AM, Andy Weller wrote:
>
> > Dear all,
> >
> > I have a basic macro that reads images in a batch and segments them; I
> > want to add analysis later.
> >
> > I'm currently a little lost as to how to work with both the ROI
> > (morphology, texture) and how to delete the background from my original
> > image.
> >
> > I currently have a function threshold() that returns the doWand of my
> > thresholded image. As Wayne says I need to AND the original image with
> > the "Masks" image generated by the particle analyzer to delete the
> > background. For this I have:
> >
> > image = open(fileName); // sets original image
> > mask = threshold(); // returns thresholded image
> > threshImg = image & mask; // deletes background
> > open(threshImg); // open image
> >
> > This is not working though, perhaps there is an obvious reason, but it
> > ain't so obvious to me at present!?
> >
> > I am slowly getting more 'in' to ImageJ and the more I play, the more I
> > like, but some 'simple' things aren't so simple to me.
> >
> > Cheers, Andy
> >
> > On Mon, 2006-06-12 at 15:59 -0400, Wayne Rasband wrote:
> >>> I apologise for the basic questions, but something I've yet to get
> >>> accustomed to is ROI management in ImageJ.
> >>>
> >>> In essence, I have an image with a particle of interest in. I segment
> >>> the foreground/background using the 'Mixture Modeling' plugin
> >>> (http://rsb.info.nih.gov/ij/plugins/mixture-modeling.html).
> >>>
> >>> How do I eliminate smaller ROIs? (Or select the largest one,
> >>> presuming it's the particle I am after?)
> >>
> >> The particle analyzer will eliminate smaller objects if you set a
> >> minimum size in the dialog and choose "Masks" from the drop down menu.
> >> You would need a macro something like this to find the largest object:
> >>
> >>      max = 0;
> >>      for (i=0; i<nResults; i++) {
> >>          area = getResult("Area", i);
> >>          if (area>max) {
> >>              max = area;
> >>              index = i;
> >>          }
> >>     }
> >>     doWand(getResult("XStart",index), getResult("YStart",index));
> >>
> >> This macro assumes that that "Record Starts" was checked in the
> >> particle analyze dialog and areas are in pixels.
> >>
> >>> How do I delete the background from my original image?
> >>
> >> AND the original image with the "Masks" image generated by the
> >> particle
> >> analyzer.
> >>
> >>> How do I select my particle with a bounding box and save as a new
> >>> (smaller) image?
> >>
> >> Create a rectangular ROI and then use the Image>Duplicate command.
> >>
> >>> Can I save the ROI as well for future reference?
> >>
> >> Use File>Save As>Selection to save the ROI.
> >>
> >>> I would then like to do some morphological analysis on the ROI.
> >>>
> >>> I hope someone can point me in the right direction?
> >>>
> >>> Many thanks, Andy