Login  Register

Re: Why is the median value zero?

Posted by Aryeh Weiss on Nov 27, 2016; 4:10pm
URL: http://imagej.273.s1.nabble.com/Why-is-the-median-value-zero-tp5017632p5017637.html

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
>


--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


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