o
    h$                     @   s  d dl Z 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 Z
dd Zd	d
 Zdd Zejdg dejdejejgdd Zdd Zejdejejejejejejejejejejejgdd Zdd Zdd Zdd Z dd Z!dd Z"dS )     N)assert_array_almost_equal)_supported_float_type)reconstructionc                   C       t ttdtdd dS )z0Test reconstruction with image and mask of zeros)      r   N)r   r   npzeros r
   r
   g/var/www/html/scripts/venv/lib/python3.10/site-packages/skimage/morphology/tests/test_reconstruction.py
test_zeros
      r   c                   C   r   )z9Test reconstruction where the image and mask are the same)r   r      N)r   r   r   onesr
   r
   r
   r   test_image_equals_mask   r   r   c                  C   s,   t d} t dd }tt| |d dS )zATest reconstruction where the image is uniform and less than maskr   r      r   Nr   r   r   r   imagemaskr
   r
   r   test_image_less_than_mask   s   
r   c                  C   s4   t d} d| d< t dd }tt| |d dS )z'Test reconstruction with one peak pixelr   r   )r   r      Nr   r   r
   r
   r   test_one_image_peak   s   
r   minsize)N   i N  i@  i8 dtypec                 C   s$  t jg dg dg dg dg dg dg|d}t jg dg dg dg dg dg dg|d}t jg dg dg dg dg dg dg|d}| d	ur|tt| |j }t| |j|  }t |||f}t |||f}t |||f}t||}|jt	|jksJ t
|| d	S )
z=Test reconstruction with two peak pixels isolated by the mask)	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   )	   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   N)r   arraymathceilsqrtsizetiler   r   r   r   )r   r   r   r   expectednrowncoloutr
   r
   r   test_two_image_peaks'   sH   



r)   c                  C   s$   t tdtd} t| d dS )zDTest reconstruction with an image of all zeros and a mask that's not)
   r*   r   N)r   r   r	   r   r   )resultr
   r
   r   test_zero_image_one_maskK   s   r,   c                 C   sf   t jg d| d}t jg d| d}t||dd}|jt|jks#J t jg d| d}t|| dS )z@Test reconstruction by erosion, which should fill holes in mask.
r      r.   r.   r.   r.   r.   r.   r.   r   r   
r   r      r   r   r   r   r   r   r   erosionmethod)
r   r   r0   r   r   r   r   r   r   r   N)r   r   r   r   r   r   )r   seedr   r+   r%   r
   r
   r   test_fill_holeQ   s   r5   c                  C   s   t d} t d}tt t| d |dd W d    n1 s#w   Y  tt t| d |dd W d    d S 1 sBw   Y  d S )Nr   r   dilationr2   g      ?r1   r   r   pytestraises
ValueErrorr   r4   r   r
   r
   r   test_invalid_seed^   s   



"r<   c                  C   s   t d} t d}tt t| |t dd W d    n1 s$w   Y  tt t| |t dd W d    n1 sCw   Y  t| |t dd d S )Nr   )r   r   )	footprint)r   r   r   r   r7   r;   r
   r
   r   test_invalid_footprinti   s   

r?   c                  C   sZ   t g d} t g d}tt t| |dd W d    d S 1 s&w   Y  d S )Nr-   r/   foor2   )r   r   r8   r9   r:   r   r;   r
   r
   r   test_invalid_methodu   s
   "rA   c               
   C   s   t g dg dg dg dg dg dg} t g dg dg dg dg dg dg}tt t| |dt dt dd	gd
 W d   dS 1 sPw   Y  dS )z:Test reconstruction with invalid not None offset parameter)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r6   r>   r   r   r3   r=   offsetN)r   r   r8   r9   r:   r   r   r   r
   r
   r   test_invalid_offset_not_none|   s&   

"rD   c               	   C   sT   t g d} t g d}t g d}tt| |dt dt dgd| dS )	z/Test reconstruction with valid offset parameterr/   )
r   r.   r0   r.   r.   r.   r.   r   r   r   )
r   r   r0   r0   r0   r0   r0   r   r   r   r6   r   r   rB   N)r   r   r   r   r   )r4   r   r%   r
   r
   r   test_offset_not_none   s   rE   )#r    numpyr   r8   numpy.testingr   skimage._shared.utilsr   "skimage.morphology.grayreconstructr   r   r   r   r   markparametrizeuint8float32r)   r,   int8int16uint16int32uint32int64uint64float16float64r5   r<   r?   rA   rD   rE   r
   r
   r
   r   <module>   s0    
"

