Reuse open/close operations for white/black tophat

This commit is contained in:
Tony S Yu
2011-10-15 03:01:27 -04:00
parent b6e470dbd1
commit 4f4f219788
+2 -4
View File
@@ -159,8 +159,7 @@ def greyscale_white_top_hat(image, selem, out=None):
if image is out:
raise NotImplementedError("Cannot perform white top hat in place.")
eroded = greyscale_erode(image, selem)
out = greyscale_dilate(eroded, selem, out=out)
out = greyscale_open(image, selem, out=out)
out = image - out
return out
@@ -187,7 +186,6 @@ def greyscale_black_top_hat(image, selem, out=None):
"""
if image is out:
raise NotImplementedError("Cannot perform white top hat in place.")
dilated = greyscale_dilate(image, selem)
out = greyscale_erode(dilated, selem, out=out)
out = greyscale_close(image, selem, out=out)
out = out - image
return out