[SciPy-user] Bug in find_objects? (Was: Re: image processing)
Vicent Mas (V+)
vmas at carabos.com
Fri Nov 3 10:07:52 CST 2006
El Friday, 3 de November de 2006 15:42, Gary Ruben escribió:
> 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.
>
You can have a look to numpy trac to see the status of the problem:
http://projects.scipy.org/scipy/numpy/ticket/370
It seems that problem could be fixed in two different ways:
1) changing numpy
2) changing scipy.ndimage
Possibility 1) has been discarded by backward-compatibility reasons so
2) is the winner. Unfortunately it seems that ndimage is not being
maintained so it could take some time to fix the problem :-(
Anyway my dirty trick is still working for me :-)
CU
--
::
\ / Vicent Mas http://www.carabos.com
0;0
/ \ Cárabos Coop. Enjoy Data
V V
" "
More information about the SciPy-user
mailing list