
    9i                     d   S SK r S SKrS SKrS SKJr  S SKJr  S SKJ	r	  S r
S rS rS r\R                  R                  S	/ S
Q5      \R                  R                  S\R                   \R"                  /5      S 5       5       rS r\R                  R                  S\R(                  \R                   \R*                  \R,                  \R.                  \R0                  \R2                  \R4                  \R6                  \R"                  \R8                  /5      S 5       rS rS rS r S r!S r"g)    N)assert_array_almost_equal)_supported_float_type)reconstructionc                      [        [        [        R                  " S5      [        R                  " S5      5      S5        g)z0Test reconstruction with image and mask of zeros)      r   N)r   r   npzeros     l/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/morphology/tests/test_reconstruction.py
test_zerosr   
   s&    nRXXf-=rxx?OPRSTr   c                      [        [        [        R                  " S5      [        R                  " S5      5      S5        g)z9Test reconstruction where the image and mask are the same)r   r      N)r   r   r	   onesr   r   r   test_image_equals_maskr      s$    nRWWV_bggfoNPQRr   c                      [         R                  " S5      n [         R                  " S5      S-  n[        [        X5      S5        g)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      s0    GGFOE776?QDnU91=r   c                      [         R                  " S5      n SU S'   [         R                  " S5      S-  n[        [        X5      S5        g)z'Test reconstruction with one peak pixelr   r   )r   r      Nr   r   s     r   test_one_image_peakr      s9    GGFOEE$K776?QDnU91=r   minsize)N   i N  i@  i8 dtypec           	         [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/US9n[         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/US9n[         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/US9nU b  [        R                  " [        R                  " XR
                  -  5      5      n[        R                  " XR
                  U-  -  5      n[         R                  " X%U45      n[         R                  " X5U45      n[         R                  " XEU45      n[        X#5      nUR                  [        UR                  5      :X  d   e[        Xt5        g	)
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*    HH''''''	
 
E 88''''''	
 
D xx''''''	
 
H yy7ZZ#789yyJJ$567d|,wwtD\*778D\2

%C99-djj9999c,r   c                      [        [        R                  " S5      [        R                  " S5      5      n [	        U S5        g)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*    BHHX.0ABFfa(r   c                    [         R                  " / SQU S9n[         R                  " / SQU S9n[        XSS9nUR                  [	        UR                  5      :X  d   e[         R                  " / SQU S9n[        X45        g)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<   ^   sg    $ 882%@D882%@DDy9F<<0<<<<xx6eDHf/r   c                  d   [         R                  " S5      n [         R                  " S5      n[        R                  " [        5         [        U S-  USS9  S S S 5        [        R                  " [        5         [        U S-  USS9  S S S 5        g ! , (       d  f       N@= f! , (       d  f       g = f)Nr   r   dilationr9   g      ?r8   r	   r   pytestraises
ValueErrorr   r;   r   s     r   test_invalid_seedrD   x   sq    776?D776?D	z	"taxj9 
#	z	"tcz4	: 
#	" 
#	"	"	"s   B8B!
B!
B/c                     [         R                  " S5      n [         R                  " S5      n[        R                  " [        5         [        X[         R                  " S5      S9  S S S 5        [        R                  " [        5         [        X[         R                  " S5      S9  S S S 5        [        X[         R                  " S5      S9  g ! , (       d  f       Nn= f! , (       d  f       N>= f)Nr   )r#   r#   )	footprint)r   r#   r   r   r?   rC   s     r   test_invalid_footprintrH      s    776?D776?D	z	"tRWWV_= 
#	z	"tRWWV_= 
#49	 
#	"	"	"s   CC
C
C-c                      [         R                  " / SQ5      n [         R                  " / SQ5      n[        R                  " [        5         [        XSS9  S S S 5        g ! , (       d  f       g = f)Nr4   r6   foor9   )r	   r$   r@   rA   rB   r   rC   s     r   test_invalid_methodrK      sB    8823D8823D	z	"t%0 
#	"	"s   A
A-c                  z   [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[        R                  " [        5         [        U US[         R                  " S5      [         R                  " SS	/5      S
9  SSS5        g! , (       d  f       g= f)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      s    HH$$$$$$	
	E 88$$$$$$	
	D 
z	"ggfo88QF#	
 
#	"	"s   +8B,,
B:c                     [         R                  " / SQ5      n [         R                  " / SQ5      n[         R                  " / SQ5      n[        [        XS[         R                  " S5      [         R                  " S/5      S9U5        g)	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      sa    8823D8823Dxx67HzRWWQZ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 7 =U
S
>> $DE288RZZ"89.- : F.-b) 



		

		

		








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