Login  Register

Re: dummy question about "median"

Posted by Wayne Rasband on Dec 14, 2006; 6:10pm
URL: http://imagej.273.s1.nabble.com/dummy-question-about-median-tp3700824p3700826.html

The ImagePlus.getStatistics() method does not calculate the median
unless you pass it the Measurements.MEDIAN flag. The mean and standard
deviation are always calculated so you do not have to pass
Measurements.MEAN and Measurements.STD_DEV. With RGB images, the
statistics are calculated using luminance values [(R+G+B)/3].

   ImageStatistics stats = imp.getStatistics(Measurements.MEDIAN);
   IJ.log(
      "Stnd.Dev1:" + stats.stdDev+", " +
      "Media1:" + stats.mean + ", " +
      "Median1:" + stats.median);
   stats = ImageStatistics.getStatistics(imp.getProcessor(),
Measurements.MEDIAN, null);
   IJ.log(
      "Stnd.Dev2:" + stats.stdDev + ", " +
      "Media2:" + stats.mean + ", " +
      "Median2:" + stats.median);

-wayne


On Dec 14, 2006, at 4:46 AM, [hidden email] wrote:

> Hi all,
> I've a little doubt about median of an rgb image.
> Could anybody explain me why in next fragment of code "median1" is
> different from "median2", while "stnd.Dev1" and "mean1" are respective
> the same of "stnd.Dev2" and "mean2"?
>
> Suppose imp in an ImagePlus Object is an RGB image.
>
>
> --------------
> System.out.println(
>    "Stnd.Dev1:" + imp.getStatistics().stdDev+", " +
>    "Media1:" + imp.getStatistics().mean + ", " +
>    "Median1:" + imp.getStatistics().median);
>
> ImageStatistics stats = ImageStatistics.getStatistics(
>    imp.getProcessor(),
>    Measurements.MEAN+Measurements.MEDIAN+Measurements.STD_DEV,
>    null);
>
> System.out.println(
>    "Stnd.Dev2:" + stats.stdDev + ", " +
>    "Media2:" + stats.mean + ", " +
>    "Median2:" + stats.median);
> ----------------------
>
> Thanks All,
> by
>
>   Nicola B.
>
>
>
>
>
> ------------------------------------------------------
> Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
> http://click.libero.it/infostrada14dic06
>