Permalink
Browse files

Merge pull request #203 from jjhelmus/ticket-954-fix

BUG: Fix segfault in distance_transform_edt (ticket 954).
  • Loading branch information...
2 parents 6a2d895 + c6e7ea3 commit 005cdcfc4539b99fb12713f633a2e678889bf1ea @stefanv stefanv committed May 8, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −1 scipy/ndimage/morphology.py
  2. +5 −0 scipy/ndimage/tests/test_ndimage.py
@@ -2160,7 +2160,7 @@ def distance_transform_edt(input, sampling = None,
ft_inplace = isinstance(indices, numpy.ndarray)
dt_inplace = isinstance(distances, numpy.ndarray)
# calculate the feature transform
- input = numpy.where(input, 1, 0).astype(numpy.int8)
+ input = numpy.atleast_1d(numpy.where(input, 1, 0).astype(numpy.int8))
if sampling is not None:
sampling = _ni_support._normalize_sequence(sampling, input.ndim)
sampling = numpy.asarray(sampling, dtype = numpy.float64)
@@ -2987,6 +2987,11 @@ def test_distance_transform_edt4(self):
sampling=[2, 1])
assert_array_almost_equal(ref, out)
+ def test_distance_transform_edt5(self):
+ "Ticket #954"
+ out = ndimage.distance_transform_edt(False)
+ assert_array_almost_equal(out, [0.])
+
def test_generate_structure01(self):
"generation of a binary structure 1"
struct = ndimage.generate_binary_structure(0, 1)

0 comments on commit 005cdcf

Please sign in to comment.