[SciPy-user] Weird label behaviour in ndimage

Reynaldo Baquerizo skraelings001@gmail....
Tue Sep 18 09:21:22 CDT 2007


Alexander Borghgraef escribió:
> Sorry about that, shortcut malfunction. Let me rephrase that:
> Hi all,
>
>  I'm doing some image treatment using the ndimage module, and I've 
> been playing a bit with the label
> function. I've encountered something very strange:
>  
>
>   a = zeros((5,4))                # a is a numpy.ndarray of int32
>   b = ndimage.label(a)[0]     # b is a numpy.ndarray of int32, and 
> basically identical to a
>   ndimage.maximum(a)       # returns 0.0
>   ndimage.maximum(b)       # returns the following error message:
>
> /usr/lib/python2.4/site-packages/scipy/ndimage/measurements.py in 
> maximum(input, labels, index)
>     195         if labels.shape != input.shape:
>     196             raise RuntimeError, 'input and labels shape are 
> not equal'
> --> 197     return _nd_image.statistics(input, labels, index, 4)
>     198
>     199
>
> RuntimeError: data type not supported
>
> Don't get this. Objects a and b are the same data type, contain the 
> same data type, print the same, can be
> added or multiplied together, but one of both cannot be used as input 
> for image statistics functions. What
> am I missing here?
You have a buggy version of scipy, it works fine for me:

> In [4]: a = zeros((5,4))
>
> In [5]: b = ndimage.label(a)[0]
>
> In [6]: ndimage.maximum(a)
> Out[6]: 0.0
>
> In [7]: ndimage.maximum(b)
> Out[7]: 0.0


Cheers,
Reynaldo



More information about the SciPy-user mailing list