luispedro / mahotas

Computer Vision in Python
https://mahotas.rtfd.io
Other
844 stars 148 forks source link

Something wrong with distance() #24

Closed langner closed 12 years ago

langner commented 12 years ago

There seems to be something wrong with the distance transform in mahotas. Consider:

import numpy
from scipy import ndimage
import mahotas
a = numpy.zeros((5,5))
ndimage.distance_transform_edt(a)
array([[ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]])
mahotas.distance(a.astype(numpy.int8))
array([[ 1.,  1.,  1.,  1.,  1.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]])
luispedro commented 12 years ago

What is b?

I think you did a bit too much copying and pasting :)

langner commented 12 years ago

Yeah, sorry for typos... updated now.

luispedro commented 12 years ago

Ah, got it.

It's a cute little bug. I will fix it.

(the reason is that a is not correctly converted to a boolean array).

luispedro commented 12 years ago

Thanks for the report!

Fixed.