Login  Register

Re: different results using ImageStatistics and Menu-Analyze-Measure command

Posted by Ben Liu-3 on Apr 28, 2006; 7:18am
URL: http://imagej.273.s1.nabble.com/different-results-using-ImageStatistics-and-Menu-Analyze-Measure-command-tp3702965p3702971.html

1. So, what does the result from my code mean then? if it is not the average along the line.
2. the mean from the Measure command is the mean of the whole line, i mean, including all pixels within the width of the line. is it correct?

Thanks.
Bian

Rasband Wayne <[hidden email]> wrote: > Hi there,

> I wanna measure the mean of line with width of w pixels.
> the line is from point ps to pe.
> the plugin is like this:
>         Line line = new Line(ps.x, ps.y, pe.x, pe.y);
>         line.setWidth(w);
>         imp.setRoi(line);
>         is = ImageStatistics.getStatistics(ip, Measurements.MEAN
> +Measurements.AREA, imp.getCalibration());
>         return is.mean;
>
> The result from this plugin is different from the one got from Menu-
> >Analyze->Measure command.
>
> Does anyone know why is this?

The getStatistics() method does not work with line selections. Here  
is how the Measure command (measureLength method in Analyzer class)  
calculates the mean of the values along the line:

     ProfilePlot profile = new ProfilePlot(imp);
     double[] values = profile.getProfile();
     ImageProcessor ip2 = new FloatProcessor(values.length, 1, values);
     ImageStatistics stats = ImageStatistics.getStatistics(ip2,  
Measurements.MEAN, null);
     double mean = stats.mean;

-wayne


               
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.