[Scipy-tickets] [SciPy] #1467: find_objects makes a runtimeerror on Windows, but depends on numpy version

SciPy Trac scipy-tickets@scipy....
Wed Jun 29 09:13:06 CDT 2011


#1467: find_objects makes a runtimeerror on Windows, but depends on numpy version
---------------------------+------------------------------------------------
 Reporter:  yves           |       Owner:  somebody   
     Type:  defect         |      Status:  new        
 Priority:  normal         |   Milestone:  Unscheduled
Component:  scipy.ndimage  |     Version:  0.9.0      
 Keywords:  find_objects   |  
---------------------------+------------------------------------------------
 For this kind of code with numpy >= 1.6
 {{{
 from PIL import Image
 from numpy import *
 from scipy.ndimage import *
 import scipy

 def convert_3DRGB_packed_RGB(pilimg):
     seg = asarray(pilimg, int32)
     return (seg[:,:,0] << 16) | seg[:,:,1] << 8 | seg[:,:,2]
 #

 def load_segmentation(path):
     return convert_3DRGB_packed_RGB(Image.open(path))
 #

 def bug(path_seg):
     s = load_segmentation(path_seg)

     print unique(s)
     print s
     print type(s),s.dtype, shape(s)
     obj = find_objects(s)

 print scipy.__version__
 print numpy.__version__

 bug("000_0211_000002_00043.cseg.png")
 }}}

 makes this kind of Error:


 {{{
 0.9.0
 1.6.1rc1
 [   65537    65538    65539    65540    65541    65542    65543    65544
     65545 16777215]
 [[16777215 16777215 16777215 ..., 16777215 16777215 16777215]
  [16777215 16777215 16777215 ..., 16777215 16777215 16777215]
  [16777215 16777215 16777215 ..., 16777215 16777215 16777215]
  ...,
  [16777215 16777215 16777215 ..., 16777215 16777215 16777215]
  [16777215 16777215 16777215 ..., 16777215 16777215 16777215]
  [16777215 16777215 16777215 ..., 16777215 16777215 16777215]]
 <type 'numpy.ndarray'> int32 (2334, 1642)
 Traceback (most recent call last):
   File "F:/Dropbox/utils_python/bug.py", line 26, in <module>
     bug("000_0211_000002_00043.cseg.png")
   File "F:/Dropbox/utils_python/bug.py", line 21, in bug
     obj = find_objects(s)
   File "C:\Python26\lib\site-packages\scipy\ndimage\measurements.py", line
 221, in find_objects
     return _nd_image.find_objects(input, max_label)
 RuntimeError: data type not supported

 }}}

 and there is no problem at all with a numpy <= 1.5.1

 after some investigation, it can be "solved" by this kind of trick:
 obj = find_objects(s.astype(int32))

 but it's stange since the numpy.ndarray had already a dtype==int32 ...

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1467>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list