Esempio n. 1
0
File: bbox.py Progetto: sdsk/mahotas
def bbox(img):
    """
    min1,max1,min2,max2 = bbox(img)

    Calculate the bounding box of image img.

    Parameters
    ----------
      img : Any image type
    Returns
    -------
      min1,max1,min2,max2 : These are such that img[min1:max1, min2:max2]
                            contains all non-zero pixels
    """
    if not img.shape:
        return np.array([], dtype=np.intp)
    if len(img.shape) == 2:
        return _bbox.bbox(img)
    raise NotImplementedError, 'mahotas.bbox for images of more than 2 dimensions'
Esempio n. 2
0
def bbox(img):
    """
    min1,max1,min2,max2 = bbox(img)

    Calculate the bounding box of image img.

    Parameters
    ----------
      img : Any image type

    Returns
    -------
      min1,max1,min2,max2 : These are such that img[min1:max1, min2:max2]
                            contains all non-zero pixels
    """
    _verify_is_integer_type(img, 'mahotas.bbox')
    if not img.shape:
        return np.array([], dtype=np.intp)
    return _bbox.bbox(img)
Esempio n. 3
0
def bbox(img):
    """
    min1,max1,min2,max2 = bbox(img)

    Calculate the bounding box of image img.

    Parameters
    ----------
    img : ndarray
        Any integer image type

    Returns
    -------
    min1,max1,min2,max2 : int,int,int,int
        These are such that ``img[min1:max1, min2:max2]`` contains all non-zero
        pixels
    """
    if not img.shape:
        return np.array([], dtype=np.intp)
    return _bbox.bbox(img)
Esempio n. 4
0
def bbox(img):
    """
    min1,max1,min2,max2 = bbox(img)

    Calculate the bounding box of image img.

    Parameters
    ----------
    img : ndarray
        Any integer image type

    Returns
    -------
    min1,max1,min2,max2 : int,int,int,int
        These are such that ``img[min1:max1, min2:max2]`` contains all non-zero
        pixels
    """
    if not img.shape:
        return np.array([], dtype=np.intp)
    return _bbox.bbox(img)