mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 16:00:12 +08:00
Fix morphological open/close for square structuring elements with even sides.
This also fixes rectangular selems with even sides, but not rectangular selems with one odd and one even side.
This commit is contained in:
@@ -105,8 +105,13 @@ def greyscale_open(image, selem, out=None):
|
||||
opening : ndarray
|
||||
The result of the morphological opening.
|
||||
"""
|
||||
h, w = selem.shape
|
||||
if (h % 2) == 0 and (w % 2) == 0:
|
||||
flip = True
|
||||
else:
|
||||
flip = False
|
||||
eroded = greyscale_erode(image, selem)
|
||||
out = greyscale_dilate(eroded, selem, out=out)
|
||||
out = greyscale_dilate(eroded, selem, out=out, flip=flip)
|
||||
return out
|
||||
|
||||
def greyscale_close(image, selem, out=None):
|
||||
@@ -131,8 +136,13 @@ def greyscale_close(image, selem, out=None):
|
||||
opening : ndarray
|
||||
The result of the morphological opening.
|
||||
"""
|
||||
h, w = selem.shape
|
||||
if (h % 2) == 0 and (w % 2) == 0:
|
||||
flip = True
|
||||
else:
|
||||
flip = False
|
||||
dilated = greyscale_dilate(image, selem)
|
||||
out = greyscale_erode(dilated, selem, out=out)
|
||||
out = greyscale_erode(dilated, selem, out=out, flip=flip)
|
||||
return out
|
||||
|
||||
def greyscale_white_top_hat(image, selem, out=None):
|
||||
|
||||
Reference in New Issue
Block a user