[SciPy-user] Bug in find_objects? (Was: Re: image processing)
Gary Ruben
gruben at bigpond.net.au
Fri Nov 3 09:42:40 EST 2006
Vicent Mas (V+) wrote:
<snip>
> Hi Gary,
>
> first of all, I didn't mention which versions of scipy and numpy I'm
> using. Sorry. They are 0.5.1 and 1.0rc1.
>
> The problem is that scipy.ndimage.measurements.label returns an integer
> array with
>
> In [18]: label_matrix.dtype.num
> Out[18]: 5
I get 7 with this, which indicates an int32. I don't know why you get a
5, which looks like a native Python int or a dtype=int0. It's easier to
tell if you just look at label_matrix.dtype which is '<i4' on mine.
So this may have changed in your scipy version or it may be a platform
dependency. Someone else will have to explain why.
I don't know if this response is helpful to you. Hopefully someone else
who understands this will step up.
> Notice that if you build an integer array as usual then
>
> In [19]: A = numpy.oldnumeric.array(range(0,5))
>
> In [20]: A.dtype.num
> Out[20]: 7
>
> In [21]: B = scipy.array(range(0,5))
>
> In [22]: B.dtype.num
> Out[22]: 7
This is the same in my version, so it seems OK.
> Passing an array like label_matrix to find_objects raises a runtime
> error as explained in my last mail. Passing an array like A to
> find_objects works fine. The problem is not detected in the
> scipy.ndimage tests module because all arrays passed to find_objects
> are like A.
>
> This being said I can reproduce exactly your results after doing a dirty
> trick in the module numpy/oldnumeric/precision.py. Just replace the
> line
>
> typecodes =
> {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHI', 'Float':'fd', 'Complex':'FD'}
>
> by
>
> typecodes =
> {'Character':'c', 'Integer':'bhli', 'UnsignedInteger':'BHI', 'Float':'fd', 'Complex':'FD'}
>
>
> Although it works for me it is far from being perfect (I think it will
> not work on 64-bits platforms). One of my colleagues has reported the
> bug to numpy this morning, see
> http://projects.scipy.org/scipy/numpy/ticket/370
Hopefully someone will be able to reproduce your error.
> I hope that my explanations are clear enough (I'm not an expert on data
> types).
>
> Thanks a lot for your answer.
More information about the SciPy-User
mailing list