Login  Register

Re: Antwort: Re: Antwort: Area Fraction

Posted by meastwood98 on Mar 18, 2008; 9:45am
URL: http://imagej.273.s1.nabble.com/Area-Fraction-tp3696831p3696835.html

Ok, this works fine for the area fraction of the whole image but im wanting the area fraction of the selection i have selected using the IJ.makeOval command. Any ideas?

Thanks,
Mark

Joachim Wesner wrote
ImageJ Interest Group <IMAGEJ@LIST.NIH.GOV> schrieb am 18.03.2008 08:47:29:

> Ok, i cant get this to work at all. Do you think it would be possible for
you
> to write a quick example program for me?
>
> Thanks,
> Mark
>


Hi again,

this is my quick code. There was a small typo ("AREA_FRACTION"), sorry, but
this was why I wrote better check with the docs!

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Filter_Plugin implements PlugInFilter {
      ImagePlus imp;

      public int setup(String arg, ImagePlus imp) {
            this.imp = imp;
            return DOES_ALL;
      }

      public void run(ImageProcessor ip) {

            ImageStatistics stats = ImageStatistics.getStatistics(ip,
ImageStatistics.AREA_FRACTION, null);

            double aFraction = stats.areaFraction;

            IJ.write(""+aFraction);

      }

}

>
> Joachim Wesner wrote:
> >
> > ImageJ Interest Group <IMAGEJ@LIST.NIH.GOV> schrieb am 17.03.2008
> > 19:30:58:
> >
> >> Hi, im writing a plug-in java and I would like to use the "area
fraction"
> >> measurement option that is in imageJ (i.e. Analyze - Measure once it
is
> >> selected in Analyze - Set Measurements).
> >>
> >> Is there a piece of code i can use the retrive the value from a
selection
> >> and store it in a variable.
> >>
> >> Thanks,
> >> Mark
> >
> > Hi again Mark,
> >
> > OK,
> >
> > here is a simple example, if ip is a reference to the underlying
> > imageprocessor with the selection do
> >
> >       ImageStatistics stats = ImageStatistics.getStatistics(ip,
> > ImageStatistics.AREAFRACTION, null);
> >
> > to get a reference to the statistics Object. The second arg is actually
a
> > "bit map" that allows to specify a combination of the statistics you
try
> > to
> > retrieve.
> >
> > After this,
> >
> >       stats.areaFraction
> >
> > has what you are looking for.
> >
> > Again, for the documentation, look here:
> >
> > http://rsbweb.nih.gov/ij/developer/api/ij/process/ImageStatistics.html
> >
> > Hope this helps
> >
> > Sincerely
> >
> > Joachim Wesner


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________