o
    :ήc                     @   s   d dl Zd dlm  m  mZ d dlmZm	Z	m
Z
mZ G dd deZG dd deZG dd deZG d	d
 d
eZG dd deZdS )    N)assert_array_equalassert_almost_equalassert_equalassert_array_almost_equalc                   @   4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )ColorMixerTestc                 C   s&   t jddt jd| _t | j| _d S )N   !         dtype)npfulluint8state
zeros_likeimgself r   G/tmp/pip-target-vg8gfxp4/lib/python/skimage/io/tests/test_colormixer.pysetup	   s   zColorMixerTest.setupc                 C   :   |  | j| jd| j t| jd | | jd | j d S Nr   .r   )opr   r   positiver   py_opr   r   r   r   
test_basic      
zColorMixerTest.test_basicc                 C   s8   |  | j| jd| j t| jd t| jd d d S )Nr   r      )r   r   r   positive_clipr   r   	full_liker   r   r   r   	test_clip   s   
zColorMixerTest.test_clipc                 C   r   r   )r   r   r   negativer   r   r   r   r   r   test_negative   r!   zColorMixerTest.test_negativec                 C   s6   |  | j| jd| j t| jd t| jd  d S r   )r   r   r   negative_clipr   r   r   r   r   r   r   test_negative_clip   s   
z!ColorMixerTest.test_negative_clipN)__name__
__module____qualname__r   r    r%   r'   r)   r   r   r   r   r      s    r   c                   @   ,   e Zd ZeejZejZdZ	dZ
dZdZdS )TestColorMixerAdd2   8   i$N)r*   r+   r,   staticmethodcmaddr   r   r   r   r#   r&   r(   r   r   r   r   r.   "       
r.   c                   @   r-   )TestColorMixerMulg333333?         ?g      N)r*   r+   r,   r2   r3   multiplyr   r   r   r   r#   r&   r(   r   r   r   r   r6   +   r5   r6   c                   @   r   )TestColorMixerBrightc                 C   (   t jdt jdd | _t | j| _d S )Nr   r   r   r   onesr   r   r   r   r   r   r   r   r   6      zTestColorMixerBright.setupc                 C   0   t | j| jdd t| jt| jd  d S )Ng      ?      r3   
brightnessr   r   r   r   	ones_liker   r   r   r   test_brightness_pos:      z(TestColorMixerBright.test_brightness_posc                 C   r?   )Nr8   r1   r/   rB   r   r   r   r   test_brightness_neg>   rF   z(TestColorMixerBright.test_brightness_negc                 C   r?   )Nr7   r   r"   rB   r   r   r   r   test_brightness_pos_clipB   rF   z-TestColorMixerBright.test_brightness_pos_clipc                 C   s,   t | j| jdd t| jt| j d S Nr   )r3   rC   r   r   r   r   r   r   r   r   r   test_brightness_neg_clipF   s   z-TestColorMixerBright.test_brightness_neg_clipN)r*   r+   r,   r   rE   rG   rH   rJ   r   r   r   r   r:   4   s    r:   c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )TestColorMixerc                 C   r;   )Nr   r   r/   r<   r   r   r   r   r   M   r>   zTestColorMixer.setupc                 C   s   dd l }d}d}dd||  }dd|||   | }| jd }t| j| j|| ddt|||    }tj|| | d dd}t|| j d S )Nr         ?r@        o@r"   r   r   )	mathexpr   r3   sigmoid_gammar   r   asarrayr   )r   rN   alphabetac1c2r   r   r   r   r   test_sigmoidQ   s   
zTestColorMixer.test_sigmoidc                 C   sF   d}t | j| j| tj| jd d|  d dd}t|| j d S )NrL   rM   r@   r"   r   r   )r3   gammar   r   r   rQ   r   )r   rW   r   r   r   r   
test_gamma]   s   zTestColorMixer.test_gammac                 C   sr   d}d}d}t |||\}}}tt|gtdg tt|gtdg tt|gtdg d S )Nr"   r   r@   )r3   py_rgb_2_hsvr   r   array)r   rgbhsvr   r   r   test_rgb_2_hsvd      zTestColorMixer.test_rgb_2_hsvc                 C   sr   d}d}d}t |||\}}}tt|gtdg tt|gtdg tt|gtdg d S Nr   r@   r"   )r3   py_hsv_2_rgbr   r   rZ   )r   r^   r_   r`   r[   r\   r]   r   r   r   test_hsv_2_rgbm   rb   zTestColorMixer.test_hsv_2_rgbc                 C   (   t | j| jddd t| j| j d S )Nh  r   )r3   hsv_addr   r   r   r   r   r   r   test_hsv_addv   r>   zTestColorMixer.test_hsv_addc                 C   s.   t | j| jddd t| jt| j d S )Nr   )r3   rh   r   r   r   r   r   r   r   r   r   test_hsv_add_clip_negz      z$TestColorMixer.test_hsv_add_clip_negc                 C   s2   t | j| jddd t| jt| jd  d S rc   )r3   rh   r   r   r   r   rD   r   r   r   r   test_hsv_add_clip_pos~   s   z$TestColorMixer.test_hsv_add_clip_posc                 C   rf   )Nrg   r@   )r3   hsv_multiplyr   r   r   r   r   r   r   test_hsv_mul   r>   zTestColorMixer.test_hsv_mulc                 C   s.   t | j| jddd t| jt| j d S rI   )r3   rn   r   r   r   r   r   r   r   r   r   test_hsv_mul_clip_neg   rl   z$TestColorMixer.test_hsv_mul_clip_negN)r*   r+   r,   r   rV   rX   ra   re   ri   rk   rm   ro   rp   r   r   r   r   rK   K   s    		rK   )numpyr   skimage.io._plugins._colormixerio_plugins_colormixerr3   skimage._shared.testingr   r   r   r   objectr   r.   r6   r:   rK   r   r   r   r   <module>   s    		