ocrd_cis/ocropy/ocrolib/morph.py
def find_objects(image, **kw):
    """Redefine the scipy.ndimage.measurements.find_objects function to
    work with a wider range of data types.  The default function
    is inconsistent about the data types it accepts on different
    platforms.
    
    Return a list of slice tuples for each label (except 0/bg),
    or None for missing labels between 0 and max_label+1.
    """
    # This OpenCV based approach is MUCH slower:
    # objects = list()
    # for label in range(max_label+1 if max_label else amax(image)):
    #     mask = array(image==(label+1), uint8)
    #     if mask.any():
    #         x, y, w, h = cv2.boundingRect(mask)
    #         objects.append(sl.box(y,y+h,x,x+w))
    #     else:
    #         objects.append(None)
    # return objects
    try: return measurements.find_objects(image,**kw)
    except: pass
    types = ["int32","uint32","int64","uint64","int16","uint16"]
    for t in types:
        try: return measurements.find_objects(array(image,dtype=t),**kw)
        except: pass
    # let it raise the same exception as before
    return measurements.find_objects(image,**kw)
Redefine the scipy.ndimage.measurements.find_objects function to
    work with a wider range of data types.  The default function
    is inconsistent about the data types it accepts on different
    platforms.
    
    Return a list of slice tuples for each label (except 0/bg),
    or None for missing labels between 0 and max_label+1.
    
Redefine the scipy.ndimage.measurements.find_objects function to
work with a wider range of data types.  The default function
is inconsistent about the data types it accepts on different
platforms.

Return a list of slice tuples for each label (except 0/bg),
or None for missing labels between 0 and max_label+1.
Redefine the scipy . ndimage . measurements . find_objects function to work with a wider range of data types . The default function is inconsistent about the data types it accepts on different platforms . Return a list of slice tuples for each label ( except 0 / bg ) or None for missing labels between 0 and max_label + 1 .
def find_objects(image, **kw):
    try: return measurements.find_objects(image,**kw)
    except: pass
    types = ["int32","uint32","int64","uint64","int16","uint16"]
    for t in types:
        try: return measurements.find_objects(array(image,dtype=t),**kw)
        except: pass
    return measurements.find_objects(image,**kw)
def find_objects ( image , ** kw ) : try : return measurements . find_objects ( image , ** kw ) except : pass types = [ "int32" , "uint32" , "int64" , "uint64" , "int16" , "uint16" ] for t in types : try : return measurements . find_objects ( array ( image , dtype = t ) , ** kw ) except : pass return measurements . find_objects ( image , ** kw )
Redefine the scipy.ndimage.measurements.find_objects function to
work with a wider range of data types.
Redefine the scipy . ndimage . measurements . find_objects function to work with a wider range of data types .
"""Redefine the scipy.ndimage.measurements.find_objects function to
    work with a wider range of data types.  The default function
    is inconsistent about the data types it accepts on different
    platforms.
    
    Return a list of slice tuples for each label (except 0/bg),
    or None for missing labels between 0 and max_label+1.
    """ # This OpenCV based approach is MUCH slower: # objects = list() # for label in range(max_label+1 if max_label else amax(image)): #     mask = array(image==(label+1), uint8) #     if mask.any(): #         x, y, w, h = cv2.boundingRect(mask) #         objects.append(sl.box(y,y+h,x,x+w)) #     else: #         objects.append(None) # return objects # let it raise the same exception as before
image