CellProfiler/CellProfiler — Issue #47: JIRA [IMG-1553] Morphology operations with kernels of even width
Author: thouis
Created: 2011-11-23 20:49:41+00:00
State: open
Labels: current

On 10/15/2011 6:32 AM, Thouis (Ray) Jones wrote:
> Do we allow even-side-length structuring elements in CP? If so, we
> should look at our chained operations (e.g., open) to make sure they
> behave correctly.
>
>
> ---------- Forwarded message ----------
> From: Tony Yu<tsyu80@gmail.com>
> Date: Sat, Oct 15, 2011 at 10:58
> Subject: Pull request: morphology fix
> To:scikits-image@googlegroups.com
>
>
> 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 theselem 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()
> _______________________________________________
> cellprofiler-dev mailing list
>cellprofiler-dev@broadinstitute.org
>https://imap.broadinstitute.org/mailman/listinfo/cellprofiler-dev

Original reporter: leek
Jira link: https://jira.broadinstitute.org/browse/IMG-1553
Fix version: Current
Assignee: leek