Posted by
Michael Schmid on
Dec 16, 2014; 9:37am
URL: http://imagej.273.s1.nabble.com/Why-is-the-Median-Filter-limited-to-a-radius-of-100-pixel-maximum-tp5010953p5010958.html
Hi Matthias,
the reason for limiting the radius for the median is computing time:
For the median, ImageJ uses quickselect (Hoare's selection algorithm), with some additional tricks for optimization. This is a good choice for the typical small kernel sizes, but slow for large sizes of the kernel.
On my computer (2.4 GHz Core2Duo), the median for a noisy 2048x2048-pixel image with r=100 takes needs almost 7 minutes!
With these computing times, I think that it makes no sense to have larger radii; the user might think it got stuck if the progress bar does not change. A large radius is useful for large images only, and there it takes excessively long.
For 8-bit and 16-bit images and a large radius, you are much better off with a histogram-based median. If you are happy with a square (instead of circular) kernel area, you could try this one:
http://ij-plugins.sourceforge.net/plugins/filters/Maybe there is a reasonably fast 'true' median algorithm also for floating-point images; if someone knows one, let me know, please!
An approximation for the median, also with a square kernel, can be found in the Fast Filters plugin. It needs 5 seconds for the 2048x2048 image.
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:fast_filters:startWhat is the application of a median with such a large size?
Michael
________________________________________________________________
On Dec 15, 2014, at 20:29, Matthias Schade wrote:
> Hello
>
> it is not possible to execute the 'Median Filter' nor the 'Remove Outliers..' function via user-interface for radii > 100 pixels. Historically, considering processing power or RAM this might have been a reasonable limit. But nowadays?
>
> I was following recommendations from the following paper on the inference of an illumination function where the authors apply a median filter (r=500 pixels) on an image of 1280x1024 pixels:
> Singh, S., Bray, M., Jones, T. R., & Carpenter, a E. (2014). Pipeline for illumination correction of images for high-throughput microscopy. Journal of Microscopy, 256(3), 231–6. doi:10.1111/jmi.12178
>
> The ImageJ java code which I think is responsible for catching any radius>100 pixel is found in "RankFilters.Java" (latest version for 1.49m) and states: "int maxRadius = (filterType==MEDIAN || filterType==OUTLIERS || filterType==REMOVE_NAN) ? 100 : 1000;"
>
> This limitation is void/ignored for ImageJ macros, i.e. using a line such as: run("Median...", "radius=200 slice");
>
> Cheers
> Matthias
>
> --
> Matthias Schade
>
> Humboldt-Universität zu Berlin
> Molekulare Biophysik - Institut für Biologie
> Invalidenstraße 42 - 10115 Berlin, Germany
>
> fon +49-30-2093-8724
> fax: +49-30-2093-8585
> office: 216
>
> email:
[hidden email]
> www:
http://www2.hu-berlin.de/biologie/molbp/>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html