ó
¦Õ\c           @` s¢   d  d l  m Z m Z m Z d  d l m Z d  d l Z y d  d l m Z Wn e	 e
 f k
 re n Xd d l m Z d d l m Z d	   Z d d d
  Z d S(   i    (   t   absolute_importt   divisiont   print_function(   t   globN(   t   imreadi   (   t   Arrayi   (   t   tokenizec         C` s   |  d S(   N.(   N.(   t   None(   t   x(    (    s/   lib/python2.7/site-packages/dask/array/image.pyt   add_leading_dimension   s    c         C` sh  | p	 t  } t t |    } | s7 t d |    n  d t | t t j j |   } | | d  } | r~ | |  } n  g  t	 t
 |   D]# } | | f d t
 | j  ^ q } | rī g  | D] } t | | | f f f ^ qĒ }	 n% g  | D] } t | | f f ^ qõ }	 t t | |	   }
 d t
 |  f t d   | j D  } t |
 | | | j  S(   sA   Read a stack of images into a dask array

    Parameters
    ----------

    filename: string
        A globstring like 'myfile.*.png'
    imread: function (optional)
        Optionally provide custom imread function.
        Function should expect a filename and produce a numpy array.
        Defaults to ``skimage.io.imread``.
    preprocess: function (optional)
        Optionally provide custom function to preprocess the image.
        Function should expect a numpy array for a single image.

    Examples
    --------

    >>> from dask.array.image import imread
    >>> im = imread('2015-*-*.png')  # doctest: +SKIP
    >>> im.shape  # doctest: +SKIP
    (365, 1000, 1000, 3)

    Returns
    -------

    Dask array of all images stacked along the first dimension.  All images
    will be treated as individual chunks
    s   No files found under name %ss	   imread-%si    i   c         s` s   |  ] } | f Vq d  S(   N(    (   t   .0t   d(    (    s/   lib/python2.7/site-packages/dask/array/image.pys	   <genexpr>E   s    (   i    (   i   (   t	   sk_imreadt   sortedR   t
   ValueErrorR   t   mapt   ost   patht   getmtimet   ranget   lent   shapeR	   t   dictt   zipt   tupleR   t   dtype(   t   filenameR   t
   preprocesst	   filenamest   namet   samplet   it   keyst   fnt   valuest   dskt   chunks(    (    s/   lib/python2.7/site-packages/dask/array/image.pyR      s"    "<+"*(   t
   __future__R    R   R   R   R   t
   skimage.ioR   R   t   AttributeErrort   ImportErrort   coreR   t   baseR   R	   R   (    (    (    s/   lib/python2.7/site-packages/dask/array/image.pyt   <module>   s   	