Search code examples
pythonimage-processingpaddingscikit-imageentropy

What are the boundary conditions for the scikit-image entropy calculations


I am implementing a local entropy calculation with scikit-image, following the example that can be found here. The entropy is calculated using a circular structuring element, whose radius is defined by the user, and it is quite simple to implement.

However, the documentation does not specify what are the boundary conditions used to calculate the entropy (e.g. if at the boundaries the image is zero-padded, or periodically/symmetrically repeated), and even looking into the source code I could not understand it. Does someone know which kind of boundary conditions are applied to the image in this case?


Solution

  • even looking into the source code I could not understand it.

    Yeah, that Cython code is hard to follow. The trick is to know that all kernels in the rank filters behave the same way, and then find the hint in the module docstring:

    The filter is applied up to the image border, the neighborhood used is adjusted accordingly.

    So, there is no boundary padding at all: you merely implement the filter function using fewer values in the histogram.