[Scipy-tickets] [SciPy] #1281: grey_erosion not symmetric with grey_dilation
SciPy Trac
scipy-tickets@scipy....
Wed Oct 13 18:44:42 CDT 2010
#1281: grey_erosion not symmetric with grey_dilation
---------------------------+------------------------------------------------
Reporter: bshanks | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 0.9.0
Component: scipy.ndimage | Version: 0.7.0
Keywords: |
---------------------------+------------------------------------------------
Description changed by warren.weckesser:
Old description:
> grey_erosion is implemented by a single line of code, but grey_dilation
> has a bunch of other stuff. I'm guessing these should be symmetric,
> although I'm not positive that it's wrong.
>
> Also, btw, http://projects.scipy.org/scipy/ticket/1135 may as well be
> applied at the same time this is fixed.
>
> here's what the functions currently look like:
> ----
>
> def grey_erosion(input, size = None, footprint = None, structure = None,
> output = None, mode = "reflect", cval = 0.0, origin =
> 0):
> """Calculate a grey values erosion.
>
> Either a size or a footprint, or the structure must be provided. An
> output array can optionally be provided. The origin parameter
> controls the placement of the filter. The mode parameter
> determines how the array borders are handled, where cval is the
> value when mode is equal to 'constant'.
> """
> return filters._min_or_max_filter(input, size, footprint, structure,
> output, mode, cval, origin, 1)
>
> def grey_dilation(input, size = None, footprint = None, structure =
> None,
> output = None, mode = "reflect", cval = 0.0, origin =
> 0):
> """Calculate a grey values dilation.
>
> Either a size or a footprint, or the structure must be
> provided. An output array can optionally be provided. The origin
> parameter controls the placement of the filter. The mode parameter
> determines how the array borders are handled, where cval is the
> value when mode is equal to 'constant'.
> """
> if structure is not None:
> size = numpy.asarray(structure).shape
> elif footprint is not None:
> size = numpy.asarray(footprint).shape
> elif size is None:
> raise RuntimeError("size, footprint, or structure must be
> specified")
> sizes = _ni_support._normalize_sequence(size, input.ndim)
> origin = _ni_support._normalize_sequence(origin, input.ndim)
> for ii in range(len(origin)):
> origin[ii] = -origin[ii]
> sz = sizes[ii]
> if not sz & 1:
> origin[ii] -= 1
> return filters._min_or_max_filter(input, size, footprint, structure,
> output, mode, cval, origin, 0)
New description:
grey_erosion is implemented by a single line of code, but grey_dilation
has a bunch of other stuff. I'm guessing these should be symmetric,
although I'm not positive that it's wrong.
Also, btw, http://projects.scipy.org/scipy/ticket/1135 may as well be
applied at the same time this is fixed.
here's what the functions currently look like:
{{{
def grey_erosion(input, size = None, footprint = None, structure = None,
output = None, mode = "reflect", cval = 0.0, origin = 0):
"""Calculate a grey values erosion.
Either a size or a footprint, or the structure must be provided. An
output array can optionally be provided. The origin parameter
controls the placement of the filter. The mode parameter
determines how the array borders are handled, where cval is the
value when mode is equal to 'constant'.
"""
return filters._min_or_max_filter(input, size, footprint, structure,
output, mode, cval, origin, 1)
def grey_dilation(input, size = None, footprint = None, structure = None,
output = None, mode = "reflect", cval = 0.0, origin = 0):
"""Calculate a grey values dilation.
Either a size or a footprint, or the structure must be
provided. An output array can optionally be provided. The origin
parameter controls the placement of the filter. The mode parameter
determines how the array borders are handled, where cval is the
value when mode is equal to 'constant'.
"""
if structure is not None:
size = numpy.asarray(structure).shape
elif footprint is not None:
size = numpy.asarray(footprint).shape
elif size is None:
raise RuntimeError("size, footprint, or structure must be
specified")
sizes = _ni_support._normalize_sequence(size, input.ndim)
origin = _ni_support._normalize_sequence(origin, input.ndim)
for ii in range(len(origin)):
origin[ii] = -origin[ii]
sz = sizes[ii]
if not sz & 1:
origin[ii] -= 1
return filters._min_or_max_filter(input, size, footprint, structure,
output, mode, cval, origin, 0)
}}}
--
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1281#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list