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 |
Hi,
On Thu, 14 Dec 2006, [hidden email] wrote: > 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"? My gut feeling is that one of the two handles the pixels as a Double instead of a triplet of bytes. But then, I really do not know what the median of a color is. The definition of the median is: 1. sort the values into a list 2. pick the value with the middle index But how do you sort colors? Is green smaller than blue or larger? Ciao, Dscho |
In reply to this post by nicola76b@libero.it
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 > |
In reply to this post by nicola76b@libero.it
thanks a lot!!
I thought this but of I was not sure.. -Nicola B. ---------- Initial Header ----------- From : "ImageJ Interest Group" [hidden email] To : [hidden email] Cc : Date : Thu, 14 Dec 2006 13:10:54 -0500 Subject : Re: dummy question about "median" > 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 > > > |
Free forum by Nabble | Edit this page |