scikit-image/scikit-image — pull request #348 by odebeir (2012-10-05 16:40:15+00:00)
Title: Rank filters

Hi,
this is my first attempt to contribute to such a collaborative work, so please consider that this is a humble and presumably clumsy contribution,
I am ready to learn, so please do not hesitate to give your thought.

Basically this contribution is an ensemble of filters that compute local histogram for each pixel. Histogram is build using a moving window in order to limit redundant computation.
The path followed by the moving window is given hereunder

...-----------------------\
/--------------------------/
\-------------------------- ...

A comparison is proposed with cmorph.dilate algorithm to show how computation costs evolve with respect to image size or
structuring element size. This implementation gives better results for large structuring elements.

A local histogram is update at each pixel by introducing pixel entering the structuring element border and by removing those leaving it. The histogram size is 8bit (256 bins) for 8 bit images and 2 to 12 bit (up to 4096 bins) for 16bit image depending on the image maximum value. Image with pixels higher than 4095 raise a ValueError.

The filter is applied up to the image border, the neighboorhood used is adjusted accordingly. The user may provide a mask image (same size as input image) where non zero value are the part of the image participating the the histogram computation. By default all the image is filtered.

Some filters have also a 'soft' version where percentile are used instead of min/max.
A variation on the same algorithm allows to generate a sort of 'bilateral' filter by defining a spectral interval around the current point.

Some example are derived from existing ones. Tests are not exhaustive, I am working on it.

Thank you for feedback

Olivier