Area Fraction

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

Area Fraction

meastwood98
This post was updated on .
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
Reply | Threaded
Open this post in threaded view
|

Antwort: Area Fraction

Joachim Wesner
Hi,

simply look up the ImageJ Java API documentation for the class
ImageStatistics


Mit freundlichen Grüßen / Best regards

Joachim Wesner

Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis


                                                                           
             meastwood98                                                  
             <meastwood98@YAHO                                            
             O.CO.UK>                                                   An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Area Fraction                      
                                                                           
                                                                           
             17.03.2008 16:25                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




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.

Any help would be much appriciated.

Thanks,
Mark
--
View this message in context:
http://www.nabble.com/Area-Fraction-tp16093861p16093861.html
Sent from the ImageJ mailing list archive at Nabble.com.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Antwort: Area Fraction

Joachim Wesner
In reply to this post by meastwood98
ImageJ Interest Group <[hidden email]> 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 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Area Fraction

meastwood98
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

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 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Antwort: Area Fraction

Joachim Wesner
ImageJ Interest Group <[hidden email]> 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 <[hidden email]> 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 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Area Fraction

meastwood98
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 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Antwort: Re: Antwort: Area Fraction

Joachim Wesner
Hmm,

I just did a quick check with a *manually* selected area and the area
statistics and it CHANGES depending on the size of the selection.

Maybe you need to do use "new OvalRoi"?

OR, you will need to get a NEW statistics object AFTER any call to
makeoval!

Anybody else any idea?


Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme




                                                                           
             meastwood98                                                  
             <meastwood98@YAHO                                            
             O.CO.UK>                                                   An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Re: Antwort: Re: Antwort: Area    
                                        Fraction                          
                                                                           
             18.03.2008 10:45                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




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 <[hidden email]> 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 <[hidden email]> 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
> ______________________________________________________________________
>
>

--
View this message in context:
http://www.nabble.com/Area-Fraction-tp16093861p16117343.html
Sent from the ImageJ mailing list archive at Nabble.com.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Area Fraction

Michael Schmid
In reply to this post by meastwood98
Hi Mark,

possibly, you have stumbled over the fact that the ROI of an
ImageProcessor is not necessarily the same as that of the
ImagePlus that contains the ImageProcessor.

What you see on the screen, and where you do selections with
the mouse, etc. is the ImagePlus. The actual processing
operations work on the ImageProcessor.
IJ.makeOval works on the ImagePlus that is currently in the
foreground, see the code in IJ.java:
   ImagePlus img = getImage();

So, what you could do is either set the roi directly in the
Imageprocessor, e.g.,
   ip.setRoi(new OvalRoi(50, 50, 100, 50));
(this is the fastest way)

Or otherwise transfer the roi from the ImagePlus to the
ImageProcessor.
   ImagePlus imp = getImage();
   ip.setRoi(imp.getRoi());

In PlugInFilters, ImageJ transfers the roi from the ImagePlus
to the ImageProcessor automatically before the run(ip) method
is called (for area rois only).
Otherwise, it is not guaranteed that the ROI is always the same
in the ImagePlus and the ImageProcessor.


Michael
________________________________________________________________

On 18 Mar 2008, at 10:45, meastwood98 wrote:

> 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 <[hidden email]> 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 <[hidden email]> 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
>> _____________________________________________________________________
>> _
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Area-Fraction- 
> tp16093861p16117343.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Re: Antwort: Area Fraction

meastwood98
In reply to this post by Joachim Wesner
new OvalRoi doesn't seem to make a difference and getting a NEW statistics object AFTER any call to
makeoval gives a different percentage but this doesn't appear to be correct as it is not the same as the one given by ANAYLIZE - MEASURE.

Any more ideas any1?

Thanks,
Mark

Joachim Wesner wrote
Hmm,

I just did a quick check with a *manually* selected area and the area
statistics and it CHANGES depending on the size of the selection.

Maybe you need to do use "new OvalRoi"?

OR, you will need to get a NEW statistics object AFTER any call to
makeoval!

Anybody else any idea?


Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme




                                                                           
             meastwood98                                                  
             <meastwood98@YAHO                                            
             O.CO.UK>                                                   An
             Gesendet von:              IMAGEJ@LIST.NIH.GOV                
             ImageJ Interest                                         Kopie
             Group                                                        
             <IMAGEJ@LIST.NIH.                                       Thema
             GOV>                       Re: Antwort: Re: Antwort: Area    
                                        Fraction                          
                                                                           
             18.03.2008 10:45                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <IMAGEJ@LIST.NIH.                                            
                   GOV>                                                   
                                                                           
                                                                           




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
> ______________________________________________________________________
>
>

--
View this message in context:
http://www.nabble.com/Area-Fraction-tp16093861p16117343.html
Sent from the ImageJ mailing list archive at Nabble.com.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Area Fraction

meastwood98
In reply to this post by Michael Schmid
Thats it, thank you very much, i used the roi directly in the Imageprocessor, worked perfectly.

Thanks,
Mark

Michael Schmid-3 wrote
Hi Mark,

possibly, you have stumbled over the fact that the ROI of an
ImageProcessor is not necessarily the same as that of the
ImagePlus that contains the ImageProcessor.

What you see on the screen, and where you do selections with
the mouse, etc. is the ImagePlus. The actual processing
operations work on the ImageProcessor.
IJ.makeOval works on the ImagePlus that is currently in the
foreground, see the code in IJ.java:
   ImagePlus img = getImage();

So, what you could do is either set the roi directly in the
Imageprocessor, e.g.,
   ip.setRoi(new OvalRoi(50, 50, 100, 50));
(this is the fastest way)

Or otherwise transfer the roi from the ImagePlus to the
ImageProcessor.
   ImagePlus imp = getImage();
   ip.setRoi(imp.getRoi());

In PlugInFilters, ImageJ transfers the roi from the ImagePlus
to the ImageProcessor automatically before the run(ip) method
is called (for area rois only).
Otherwise, it is not guaranteed that the ROI is always the same
in the ImagePlus and the ImageProcessor.


Michael
________________________________________________________________

On 18 Mar 2008, at 10:45, meastwood98 wrote:

> 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
>> _____________________________________________________________________
>> _
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Area-Fraction- 
> tp16093861p16117343.html
> Sent from the ImageJ mailing list archive at Nabble.com.