U
    	Ùf#  ã                   @   s´   d dl Zd dlmZ d dlmZmZmZ d dlm	Z	m
Z
 d dlmZ e e ¡ ¡ZedkZdd„ Zd	d
„ Zejfdddœdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )é    N)Úassert_array_equal)ÚcolorÚdataÚ
morphology)ÚbinaryÚ	isotropic)Úimg_as_boolgÙ?c                  C   sP   t  td d…d d…f d¡} tt td d…d d…f t d¡¡ƒ}t| |ƒ d S )Néd   éÈ   é   ©	r   Úisotropic_erosionÚbw_imgr   r   Úbinary_erosionr   Údiskr   ©Úisotropic_resÚ
binary_res© r   úN/tmp/pip-target-lpfmz8o1/lib/python/skimage/morphology/tests/test_isotropic.pyÚtest_non_square_image   s     ÿr   c                  C   s0   t  td¡} tt tt d¡¡ƒ}t| |ƒ d S ©Nr   r   r   r   r   r   Útest_isotropic_erosion   s    r   T)Ústrict_radiusÚspacingc                C   sp   t  |  | d ¡}t  ||¡\}}|d k	rB||d 9 }||d 9 }|sN| d7 } t j|d |d  | d k|dS )Né   r   g      à?é   ©Údtype)ÚnpZarangeZmeshgridÚarray)Úradiusr   r   r   ÚLÚXÚYr   r   r   Ú_disk_with_spacing   s    r%   c                  C   s6   t jtddd} tt ttddd¡ƒ}t| |ƒ d S )Né   )r   r   )r   )r   Úisotropic_dilationr   r   r   Úbinary_dilationr%   r   r   r   r   r   Útest_isotropic_erosion_spacing(   s    r)   c                  C   s0   t  td¡} tt tt d¡¡ƒ}t| |ƒ d S r   )	r   r'   r   r   r   r(   r   r   r   r   r   r   r   Útest_isotropic_dilation.   s     ÿÿr*   c                  C   s0   t  td¡} tt tt d¡¡ƒ}t| |ƒ d S r   )	r   Zisotropic_closingr   r   r   Zbinary_closingr   r   r   r   r   r   r   Útest_isotropic_closing6   s    r+   c                  C   s0   t  td¡} tt tt d¡¡ƒ}t| |ƒ d S r   )	r   Zisotropic_openingr   r   r   Zbinary_openingr   r   r   r   r   r   r   Útest_isotropic_opening<   s    r,   c                  C   sR   t jdtd} d| dd…dd…f< t | d¡}tt | t 	d¡¡ƒ}t
||ƒ d S )N)é   r-   r   Tr   é   é	   )r   ZzerosÚboolr   r   r   r   r   r   r   r   )Úimgr   r   r   r   r   Útest_footprint_overflowB   s
    r2   c                  C   sf   t jt jfD ]T} d}t d¡}t |¡}| ¡ }| |||d t ||k¡sPt‚t	|| ||ƒƒ qd S )Nr   )é
   r3   )Úout)
r   r   r'   r   ZonesZ
zeros_likeÚcopyÚanyÚAssertionErrorr   )Úfuncr!   r1   r4   Z	out_savedr   r   r   Útest_out_argumentJ   s    

r9   )Únumpyr   Znumpy.testingr   Zskimager   r   r   Zskimage.morphologyr   r   Zskimage.utilr   Zrgb2grayZ	astronautr1   r   r   r   Zuint8r%   r)   r*   r+   r,   r2   r9   r   r   r   r   Ú<module>   s   