From 4f4f219788843bea2bd6d9ee2f811a1a87abf57c Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 15 Oct 2011 03:01:27 -0400 Subject: [PATCH] Reuse open/close operations for white/black tophat --- scikits/image/morphology/grey.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scikits/image/morphology/grey.py b/scikits/image/morphology/grey.py index ac41c4f1..0b8c49b8 100644 --- a/scikits/image/morphology/grey.py +++ b/scikits/image/morphology/grey.py @@ -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