I just submitted a pull request for a somewhat-subtle bug with some morphology operations: https://github.com/scikits-image/scikits.image/pull/62 Overly detailed explanation: Using a structuring element with one-or-both sides being even-numbered gives buggy output for morphological open/close and white/black tophat operations. These issues arise because even-numbered structuring elements (selems) aren't centered on a pixel. The dilate and erode operations are (correctly) defined so that they are symmetric (dilation on a white feature is exactly the opposite of erosion on an equivalent black feature). When chaining them (e.g. open() = dilate(erode())), however, this symmetry ends up shifting features. To fix this, one of the operations should be shifted. For example, if erosion is done with the selem shifted slightly to the lower-right, the dilation operation should shift the selem to the upper-left. This change prevents features from being shifted. The open/close operations aren't that bad: they just shift features. But, when calling white/black tophat operations, the shifting can lead to over/underflow of pixels. I've attached examples of the lena image after calling white tophat, both before and after the fix. The underflow should be apparent in the first image. Best, -Tony Example code: import os import numpy as np import matplotlib.pyplot as plt from scikits.image import data_dir from scikits.image.morphology import * lena = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy')) plt.imshow(greyscale_white_top_hat(lena, square(4))) plt.show()
participants (1)
-
Tony Yu