Login  Register

Re: Why is the median value zero?

Posted by Jan Eglinger on Nov 27, 2016; 6:32pm
URL: http://imagej.273.s1.nabble.com/Why-is-the-median-value-zero-tp5017632p5017638.html

Dear all,

the Median calculation was recently removed from both ImagePlus [1] and
ImageStatistics [2] by Wayne in reaction to a related bug report [3].

I guess that from v1.51i on, you'll have to use .getAllStatistics()
introduced with v1.51i2 [4] instead of .getStatistics().

This is a backwards-incompatible change, but as mentioned in the github
issue, this improved the performance of the Brightness&Contrast dialog.

Hope that helps,
Jan


[1]:
https://github.com/imagej/imagej1/commit/6e74324174a6c5c87bd01c1a9ffb5568de8b1dce
[2]:
https://github.com/imagej/imagej1/commit/354b0d50a9f4c34908c0cb573d05ecde69ad5052
[3]: https://github.com/imagej/imagej1/issues/25#issuecomment-261691787
[4]:
https://github.com/imagej/imagej1/commit/6e74324174a6c5c87bd01c1a9ffb5568de8b1dce



On 27.11.16 17:10, Aryeh Weiss wrote:

> I can reproduce it, but I dont think that it is a bug.
>
> ip.getStatistics() does nto claim to return the median.
> Here is the API doc:
> Calculates and returns statistics (area, mean, std-dev, mode, min, max,
> centroid, center of mass, 256 bin histogram) for this image or ROI.
>
> ImageStatistics.getStatistics() is:
>
> public staticImageStatistics
> <https://imagej.nih.gov/ij/developer/api/ij/process/ImageStatistics.html>
> getStatistics(ImageProcessor
> <https://imagej.nih.gov/ij/developer/api/ij/process/ImageProcessor.html>  ip,
>
>                                              int mOptions,
>                                              Calibration
> <https://imagej.nih.gov/ij/developer/api/ij/measure/Calibration.html>  cal)
>
> If you set mOptions, you can get it to return many other things
> (including median), but I dont know how to set mOptions.
> Where is that documented?
>
> I think if you use the ImageStatistics.getStatistics()
> with the correct mOptions, you will get the median.
>
> --aryeh
>
> On 27/11/2016 17:57, Herbie wrote:
>> Good afternoon Avital,
>>
>> I've just upgraded ImageJ to the daily build 1.51i and now I can
>> confirm median = 0.
>>
>> This seems to be a case for Wayne...
>>
>> Best
>>
>> Herbie
>>
>> :::::::::::::::::::::::::::::::::::::::::::::
>> Am 27.11.16 um 16:35 schrieb Avital Steinberg:
>>> Thanks, Herbie - when I run it with Fiji on my Linux machine, which has
>>> ImageJ 1.51a13 with Java 1.6.0_24, there is no bug like you said. But
>>> when
>>> I run it on Fiji with my 10.9.5 mac OsX, I get a value of zero.
>>>
>>> Can anyone else reproduce the bug?
>>> Thanks,
>>> Avital
>>>
>>> On Sun, Nov 27, 2016 at 5:20 PM, Herbie <[hidden email]> wrote:
>>>
>>>> Good day Avital
>>>>
>>>> when running your script entered to a window from "Plugins > New >
>>>> JavaScript" I get in the Log-window:
>>>>
>>>>         "The median is: 71"
>>>>
>>>> ImageJ 1.51h, OSX 10.11.6, 64bit Java 1.6.0_65.
>>>>
>>>> HTH
>>>>
>>>> Herbie
>>>>
>>>> ::::::::::::::::::::::::::::::::::::::::::::::
>>>> Am 27.11.16 um 15:57 schrieb Avital Steinberg:
>>>>
>>>>> importClass(Packages.ij.IJ);
>>>>> importClass(Packages.ij.plugin.frame.RoiManager);
>>>>> importClass(Packages.ij.ImagePlus);
>>>>> importClass(Packages.ij.process.ImageProcessor);
>>>>> importClass(Packages.ij.gui.Roi);
>>>>> importClass(Packages.ij.gui.OvalRoi);
>>>>> importClass(Packages.ij.process.ImageStatistics);
>>>>>
>>>>> rm = RoiManager.getInstance();
>>>>> if (rm==null) rm = new RoiManager();
>>>>>
>>>>> imp = IJ.createImage("randRamp", "8-bit ramp", 2000, 2048, 1);
>>>>> imp.setRoi(new OvalRoi(471,273,177,180));
>>>>> imp.show();
>>>>> IJ.run("ROI Manager...", "");
>>>>> rm.addRoi(imp.getRoi());
>>>>> rm.select(0);
>>>>> ip = imp.getProcessor();
>>>>> selROI = rm.getRoi(0);
>>>>> imp.setRoi(selROI, false);
>>>>> ip.setRoi(selROI);
>>>>> stats = ip.getStatistics();
>>>>> median = stats.median; // Adjusted median
>>>>> IJ.log("The median is: " + median);
>>>>>
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html