
    1-Ph                        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 Z
d Zd Zd Zej                            d	g d
          ej                            dej        ej        g          d                         Z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             Zd Zd Zd Z d Z!d Z"dS )    N)assert_array_almost_equal)_supported_float_type)reconstructionc                      t          t          t          j        d          t          j        d                    d           dS )z0Test reconstruction with image and mask of zeros)      r   N)r   r   npzeros     l/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/morphology/tests/test_reconstruction.py
test_zerosr   
   s7    nRXf-=-=rx?O?OPPRSTTTTTr   c                      t          t          t          j        d          t          j        d                    d           dS )z9Test reconstruction where the image and mask are the same)r   r      N)r   r   r	   onesr   r   r   test_image_equals_maskr      s3    nRWV__bgfooNNPQRRRRRr   c                      t          j        d          } t          j        d          dz  }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masks     r   test_image_less_than_maskr      sA    GFOOE76??QDnUD991=====r   c                      t          j        d          } d| d<   t          j        d          dz  }t          t          | |          d           dS )z'Test reconstruction with one peak pixelr   r   )r   r      Nr   r   s     r   test_one_image_peakr      sJ    GFOOEE$K76??QDnUD991=====r   minsize)N   i N  i@  i8 dtypec           	         t          j        g dg dg dg dg dg dg|          }t          j        g dg dg dg dg dg dg|          }t          j        g dg dg dg dg dg dg|          }| t          j        t          j        | |j        z                      }t          j        | |j        |z  z            }t          j        |||f          }t          j        |||f          }t          j        |||f          }t          ||          }|j        t          |j                  k    sJ 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outs           r   test_two_image_peaksr.   %   s    H''''''''''''''''''	
 
 
 
E 8''''''''''''''''''	
 
 
 
D x''''''''''''''''''	
 
 
 
H y7UZ#78899yEJ$5677d|,,wtdD\**78dD\22

%
%C9-dj999999c8,,,,,r   c                      t          t          j        d          t          j        d                    } t	          | d           dS )zDTest reconstruction with an image of all zeros and a mask that's not)
   r0   r   N)r   r	   r
   r   r   )results    r   test_zero_image_one_maskr2   X   s;    BHX..0A0ABBFfa(((((r   c                    t          j        g d|           }t          j        g d|           }t          ||d          }|j        t	          |j                  k    sJ t          j        g d|           }t          ||           dS )z@Test reconstruction by erosion, which should fill holes in mask.
r      r5   r5   r5   r5   r5   r5   r5   r   r"   
r   r      r   r   r   r   r#   r   r   erosionmethod)
r   r   r7   r#   r#   r#   r#   r#   r   r   N)r	   r$   r   r    r   r   )r    seedr   r1   r*   s        r   test_fill_holer<   ^   s    $ 8222%@@@D8222%@@@DD$y999F<0<<<<<<x666eDDDHfh/////r   c                  p   t          j        d          } t          j        d          }t          j        t                    5  t          | dz  |d           d d d            n# 1 swxY w Y   t          j        t                    5  t          | dz  |d           d d d            d S # 1 swxY w Y   d S )Nr   r   dilationr9   g      ?r8   r	   r   pytestraises
ValueErrorr   r;   r   s     r   test_invalid_seedrD   x   s'   76??D76??D	z	"	" : :taxj9999: : : : : : : : : : : : : : :	z	"	" ; ;tcz4	::::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s$   A$$A(+A(B++B/2B/c                     t          j        d          } t          j        d          }t          j        t                    5  t          | |t          j        d                     d d d            n# 1 swxY w Y   t          j        t                    5  t          | |t          j        d                     d d d            n# 1 swxY w Y   t          | |t          j        d                     d S )Nr   )r#   r#   )	footprint)r   r#   r   r   r?   rC   s     r   test_invalid_footprintrH      sC   76??D76??D	z	"	" > >tTRWV__====> > > > > > > > > > > > > > >	z	"	" > >tTRWV__====> > > > > > > > > > > > > > >4999999s$   %A33A7:A7%CCCc                      t          j        g d          } t          j        g d          }t          j        t                    5  t          | |d           d d d            d S # 1 swxY w Y   d S )Nr4   r6   foor9   )r	   r$   r@   rA   rB   r   rC   s     r   test_invalid_methodrK      s    822233D822233D	z	"	" 1 1tT%00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   A&&A*-A*c                  v   t          j        g dg dg dg dg dg dg          } t          j        g dg dg dg dg dg dg          }t          j        t                    5  t          | |dt          j        d          t          j        dd	g          
           ddd           dS # 1 swxY w 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#   r>   rG   r   r   r:   rF   offsetN)r	   r$   r@   rA   rB   r   r   r   s     r   test_invalid_offset_not_nonerO      sN   H$$$$$$$$$$$$$$$$$$	
	 	E 8$$$$$$$$$$$$$$$$$$	
	 	D 
z	"	" 
 
gfoo8QF##	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   &;B..B25B2c                     t          j        g d          } t          j        g d          }t          j        g d          }t          t          | |dt          j        d          t          j        dg                    |           dS )	z/Test reconstruction with valid offset parameterr6   )
r   r5   r7   r5   r5   r5   r5   r#   r#   r   )
r   r   r7   r7   r7   r7   r7   r#   r#   r   r>   r   r   rM   N)r	   r$   r   r   r   )r;   r   r*   s      r   test_offset_not_nonerQ      s    822233D822233Dx66677H$zRWQZZRSQT	
 	
 	
 		    r   )#r%   numpyr	   r@   numpy.testingr   skimage._shared.utilsr   "skimage.morphology.grayreconstructr   r   r   r   r   markparametrizeuint8float32r.   r2   int8int16uint16int32uint32int64uint64float16float64r<   rD   rH   rK   rO   rQ   r   r   r   <module>rc      s         3 3 3 3 3 3 7 7 7 7 7 7 = = = = = =U U U
S S S
> > >> > > $D$D$DEE28RZ"899.- .- :9 FE.-b) ) ) 



	

	

	





  0 0!  0; ; ;: : :1 1 1
 
 
B    r   