Login  Register

Re: Faster way to get statistics from an image.

Posted by Michael Schmid on Apr 28, 2014; 4:54pm
URL: http://imagej.273.s1.nabble.com/Faster-way-to-get-statistics-from-an-image-tp5007465p5007473.html

Hi Peter,

if your data are in a 1 GB virtual stack, I guess that the time for computing the ImageStatistics is usually dominated by the time for loading the files from disk (unless you have an SSD or a lot of RAM and/or a hybrid disk *and* the data are already in the disk cache).
If running the ImageStatistics in a threads makes it faster, the first thing to check is whether you have set only those measurement options (e.g. MEAN, STD_DEV, MODE, MIN_MAX) that you actually need.

If you don't need any data that are based on the histogram and you have no ROI (i.e., you want statistics on the whole image), it may be faster not to use the ImageJ ImageStatistics. In that case, you can try to get the pixels arrays of the stack and do the min, max, averaging or whatever you want by a loop over the pixels. Of course, to have it generally applicable you have to write your code four times, for 8-bit, 16-bit, float, and RGB images. And then you should probably care about 8-bit or 16-bit images with a calibration table (if it is nonlinear, note that e.g. the calibrated value of the raw pixel mean is not the mean of the calibrated values). When keeping all that in mind, you will soon have rather complex code, and I am not sure whether it will be much faster than the ImageJ built-in ImageStatistics (ByteStatistics, ShortStatistics, etc.)

So far my 3 cents,

Michael
________________________________________________________________
On Apr 28, 2014, at 13:40, Peter Mc wrote:

> Hi everyone;
>
> Using ImageJ to calculate the image stats from a huge virtual stack (around
> a 1 GB ) I noticed that the plugin used for calculating (Stack_Statistics)
> is quite slow for my purpose  so I implemented my own solution using
> threads. This solution is around 4 times faster but still slow.
>
> Have a few ideas about how to do it but I feel like reinventing the wheel so
> if someone has any idea please let me know.
>
> Best Regards.
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Faster-way-to-get-statistics-from-an-image-tp5007465.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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