Re: different results using ImageStatistics and Menu-Analyze-Measure command
Posted by
Wayne Rasband on
Apr 28, 2006; 4:19am
URL: http://imagej.273.s1.nabble.com/different-results-using-ImageStatistics-and-Menu-Analyze-Measure-command-tp3702965p3702970.html
> 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