U
    ƒ±Ëhã  ã                   @   s4   d dl ZddlmZ d dlmZ d
ddœdd	„ZdS )é    Né   )Úimg_as_float)ÚproductÚdiff)é   r   )Ún_tilesc                C   s*  | j |j krtdƒ‚t| ƒ}t|ƒ}|dkr<t || ¡}nê|dkrRd||  }nÔ|dkr|j \}}t ||fd¡}	t||d  ƒ}
t||d  ƒ}tt|d ƒt|d ƒƒD ]D\}}|| d	 dkr°d
|	||
 |d |
 …|| |d | …f< q°t 	|¡}||	 ||	< ||	  ||	 < ntdƒ‚|S )a{  
    Return an image showing the differences between two images.

    .. versionadded:: 0.16

    Parameters
    ----------
    image1, image2 : 2-D array
        Images to process, must be of the same shape.
    method : string, optional
        Method used for the comparison.
        Valid values are {'diff', 'blend', 'checkerboard'}.
        Details are provided in the note section.
    n_tiles : tuple, optional
        Used only for the `checkerboard` method. Specifies the number
        of tiles (row, column) to divide the image.

    Returns
    -------
    comparison : 2-D array
        Image showing the differences.

    Notes
    -----
    ``'diff'`` computes the absolute difference between the two images.
    ``'blend'`` computes the mean value.
    ``'checkerboard'`` makes tiles of dimension `n_tiles` that display
    alternatively the first and the second image.
    z Images must have the same shape.r   Zblendg      à?ZcheckerboardFr   r   é   TzKWrong value for `method`. Must be either "diff", "blend" or "checkerboard".)
ÚshapeÚ
ValueErrorr   ÚnpÚabsÚfullÚintr   ÚrangeZ
zeros_like)Zimage1Zimage2Úmethodr   Zimg1Zimg2Z
comparisonZshapexZshapeyÚmaskZstepxZstepyÚiÚj© r   ú8/tmp/pip-unpacked-wheel-gtraehzf/skimage/util/compare.pyÚcompare_images   s*    

".
r   )r   )Znumpyr   Zdtyper   Ú	itertoolsr   r   r   r   r   r   Ú<module>   s   