ó
 ‰\c           @   sO   d  d l  m Z d d l m Z d d l m Z d d l Z d  e d „ Z	 d S(   i   (   t   _seam_carve_vi   (   t   util(   t   utilsiÿÿÿÿNc         C   sç   t  j |  d ƒ t j |  | ƒ }  t j | | ƒ } |  j d k rY |  d t j f }  n  | d k r’ t j |  d d ƒ }  t j | d d ƒ } n  t j |  ƒ }  t	 |  | | | ƒ } | d k rÚ t j | d d ƒ } n  t j
 | ƒ S(   s˜   Carve vertical or horizontal seams off an image.

    Carves out vertical/horizontal seams from an image while using the given
    energy map to decide the importance of each pixel.

    Parameters
    ----------
    image : (M, N) or (M, N, 3) ndarray
        Input image whose seams are to be removed.
    energy_map : (M, N) ndarray
        The array to decide the importance of each pixel. The higher
        the value corresponding to a pixel, the more the algorithm will try
        to keep it in the image.
    mode : str {'horizontal', 'vertical'}
        Indicates whether seams are to be removed vertically or horizontally.
        Removing seams horizontally will decrease the height whereas removing
        vertically will decrease the width.
    num : int
        Number of seams are to be removed.
    border : int, optional
        The number of pixels in the right, left and bottom end of the image
        to be excluded from being considered for a seam. This is important as
        certain filters just ignore image boundaries and set them to `0`.
        By default border is set to `1`.
    force_copy : bool, optional
        If set, the `image` and `energy_map` are copied before being used by
        the method which modifies it in place. Set this to `False` if the
        original image and the energy map are no longer needed after
        this operation.

    Returns
    -------
    out : ndarray
        The cropped image with the seams removed.

    References
    ----------
    .. [1] Shai Avidan and Ariel Shamir
           "Seam Carving for Content-Aware Image Resizing"
           http://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Avidan07.pdf
    i   i   .t
   horizontali    i   (   i   i   (   R   t	   assert_nDR   t   img_as_floatt   ndimt   npt   newaxist   swapaxest   ascontiguousarrayR    t   squeeze(   t   imaget
   energy_mapt   modet   numt   bordert
   force_copyt   out(    (    s=   lib/python2.7/site-packages/skimage/transform/seam_carving.pyt
   seam_carve   s    +(
   t   _seam_carvingR    t    R   t   _sharedR   t   numpyR   t   TrueR   (    (    (    s=   lib/python2.7/site-packages/skimage/transform/seam_carving.pyt   <module>   s   