ó
 ‰\c           @   sÒ   d  d l  Z d  d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l m Z d	 d
 d d d d g Z e d d d „ Z e d d „ Z d d „ Z d d „ Z d d „ Z d „  Z d S(   iÿÿÿÿNi   (   t   call_plugin(   t   rgb2grayi   (   t   file_or_url_context(   t   is_low_contrast(   t   warnt   imreadt   imsavet   imshowt   showt   imread_collectiont   imshow_collectionc      
   K   sJ  d | j  ƒ  k r1 | j d | ƒ } t d ƒ n  | d
 k	 rP | } t d ƒ n  | d
 k rŒ t |  d ƒ rŒ |  j ƒ  j d ƒ rŒ d } qŒ n  t |  ƒ  }  t d |  d	 | | } Wd
 QXt | d ƒ sÌ | S| j	 d k rF| j
 d d k r.| j
 d d k r.t j | d d ƒ } t j | d d ƒ } n  | rFt | ƒ } qFn  | S(   sÛ  Load an image from file.

    Parameters
    ----------
    fname : string
        Image file name, e.g. ``test.jpg`` or URL.
    as_gray : bool, optional
        If True, convert color images to gray-scale (64-bit floats).
        Images that are already in gray-scale format are not converted.
    plugin : str, optional
        Name of plugin to use.  By default, the different plugins are
        tried (starting with the Python Imaging Library) until a suitable
        candidate is found.  If not given and fname is a tiff file, the
        tifffile plugin will be used.

    Other Parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.
    flatten : bool
        Backward compatible keyword, superseded by `as_gray`.

    Returns
    -------
    img_array : ndarray
        The different color bands/channels are stored in the
        third dimension, such that a gray-image is MxN, an
        RGB-image MxNx3 and an RGBA-image MxNx4.

    t   as_greys3   `as_grey` has been deprecated in favor of `as_gray`sQ   `flatten` has been deprecated in favor of `as_gray` and will be removed in v0.16.t   lowers   .tiffs   .tift   tifffileR   t   pluginNt   ndimi   iÿÿÿÿi   i   iýÿÿÿiþÿÿÿ(   s   .tiffs   .tif(   i   i   (   i   i   (   t   keyst   popR   t   Nonet   hasattrR   t   endswithR   R    R   t   shapet   npt   swapaxesR   (   t   fnamet   as_grayR   t   flattent   plugin_argst   img(    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR      s(     &c         K   s   t  d |  | d | | S(   s©  
    Load a collection of images.

    Parameters
    ----------
    load_pattern : str or list
        List of objects to load. These are usually filenames, but may
        vary depending on the currently active plugin.  See the docstring
        for ``ImageCollection`` for the default behaviour of this parameter.
    conserve_memory : bool, optional
        If True, never keep more than one in memory at a specific
        time.  Otherwise, images will be cached once they are loaded.

    Returns
    -------
    ic : ImageCollection
        Collection of images.

    Other parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.

    R	   R   (   R    (   t   load_patternt   conserve_memoryR   R   (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR	   N   s    c         K   s’   | d	 k r< t |  d ƒ r< |  j ƒ  j d
 ƒ r< d } q< n  t | ƒ rY t d |  ƒ n  | j t k ry t d |  ƒ n  t d |  | d | | S(   sŒ  Save an image to file.

    Parameters
    ----------
    fname : str
        Target filename.
    arr : ndarray of shape (M,N) or (M,N,3) or (M,N,4)
        Image data.
    plugin : str
        Name of plugin to use.  By default, the different plugins are
        tried (starting with the Python Imaging Library) until a suitable
        candidate is found.  If not given and fname is a tiff file, the
        tifffile plugin will be used.

    Other parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.

    Notes
    -----
    When saving a JPEG, the compression ratio may be controlled using the
    ``quality`` keyword argument which is an integer with values in [1, 100]
    where 1 is worst quality and smallest file size, and 100 is best quality
    and largest file size (default 75).  This is only available when using
    the PIL and imageio plugins.
    R   s   .tiffs   .tifR   s   %s is a low contrast images7   %s is a boolean image: setting True to 1 and False to 0R   R   N(   s   .tiffs   .tif(	   R   R   R   R   R   R   t   dtypet   boolR    (   R   t   arrR   R   (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR   l   s    c         K   s@   t  |  t j ƒ r* t d |  d | ƒ}  n  t d |  d | | S(   s   Display an image.

    Parameters
    ----------
    arr : ndarray or str
        Image data or name of image file.
    plugin : str
        Name of plugin to use.  By default, the different plugins are
        tried (starting with the Python Imaging Library) until a suitable
        candidate is found.

    Other parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.

    R   R   R   (   t
   isinstancet   sixt   string_typesR    (   R!   R   R   (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR   ’   s    c         K   s   t  d |  d | | S(   sp  Display a collection of images.

    Parameters
    ----------
    ic : ImageCollection
        Collection to display.
    plugin : str
        Name of plugin to use.  By default, the different plugins are
        tried until a suitable candidate is found.

    Other parameters
    ----------------
    plugin_args : keywords
        Passed to the given plugin.

    R
   R   (   R    (   t   icR   R   (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR
   ©   s    c           C   s
   t  d ƒ S(   sÞ  Display pending images.

    Launch the event loop of the current gui plugin, and display all
    pending images, queued via `imshow`. This is required when using
    `imshow` from non-interactive scripts.

    A call to `show` will block execution of code until all windows
    have been closed.

    Examples
    --------
    >>> import skimage.io as io

    >>> for i in range(4):
    ...     ax_im = io.imshow(np.random.rand(50, 50))
    >>> io.show() # doctest: +SKIP

    t	   _app_show(   R    (    (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyR   ½   s    (   t   numpyR   R#   t   io.manage_pluginsR    t   colorR   t   utilR   t   exposureR   t   _shared.utilsR   t   __all__t   FalseR   R   t   TrueR	   R   R   R
   R   (    (    (    s-   lib/python2.7/site-packages/skimage/io/_io.pyt   <module>   s   ?&