
    _h                     d   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                  j                  d	g d
      ej                  j                  dej                   ej"                  g      d               Zd Zej                  j                  dej(                  ej                   ej*                  ej,                  ej.                  ej0                  ej2                  ej4                  ej6                  ej"                  ej8                  g      d        Zd Zd Zd Z d Z!d Z"y)    N)assert_array_almost_equal)_supported_float_type)reconstructionc                  |    t        t        t        j                  d      t        j                  d            d       y)z0Test reconstruction with image and mask of zeros)      r   N)r   r   npzeros     f/var/www/html/engine/venv/lib/python3.12/site-packages/skimage/morphology/tests/test_reconstruction.py
test_zerosr   
   s&    nRXXf-=rxx?OPRSTr   c                  |    t        t        t        j                  d      t        j                  d            d       y)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                      t        j                  d      } t        j                  d      dz  }t        t        | |      d       y)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      s2    GGFOE776?QDnUD91=r   c                      t        j                  d      } d| d<   t        j                  d      dz  }t        t        | |      d       y)z'Test reconstruction with one peak pixelr   r   )r   r      Nr   r   s     r   test_one_image_peakr      s;    GGFOEE$K776?QDnUD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        ||       y	)
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.   %   s8    HH''''''	
 
E 88''''''	
 
D xx''''''	
 
H yy7UZZ#789yyEJJ$567d|,wwtdD\*778dD\2

%C99-djj9999c8,r   c                      t        t        j                  d      t        j                  d            } t	        | d       y)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                    t        j                  g d|       }t        j                  g d|       }t        ||d      }|j                  t	        |j                        k(  sJ t        j                  g d|       }t        ||       y)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<   ^   sk    $ 882%@D882%@DD$y9F<<0<<<<xx6eDHfh/r   c                  T   t        j                  d      } t        j                  d      }t        j                  t              5  t        | dz  |d       d d d        t        j                  t              5  t        | dz  |d       d d d        y # 1 sw Y   =xY w# 1 sw Y   y xY w)Nr   r   dilationr9   g      ?r8   r	   r   pytestraises
ValueErrorr   r;   r   s     r   test_invalid_seedrD   x   s    776?D776?D	z	" :taxj9:	z	" ;tcz4	:; ;: :; ;s   B7BBB'c                     t        j                  d      } t        j                  d      }t        j                  t              5  t        | |t        j                  d             d d d        t        j                  t              5  t        | |t        j                  d             d d d        t        | |t        j                  d             y # 1 sw Y   nxY w# 1 sw Y   7xY w)Nr   )r#   r#   )	footprint)r   r#   r   r   r?   rC   s     r   test_invalid_footprintrH      s    776?D776?D	z	" >tTRWWV_=>	z	" >tTRWWV_=>49	> >> >s   "C"CCC(c                      t        j                  g d      } t        j                  g d      }t        j                  t              5  t        | |d       d d d        y # 1 sw Y   y xY w)Nr4   r6   foor9   )r	   r$   r@   rA   rB   r   rC   s     r   test_invalid_methodrK      sM    8823D8823D	z	" 1tT%01 1 1s   A  A)c                  l   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       y# 1 sw Y   yxY w)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   (9B**B3c                     t        j                  g d      } t        j                  g d      }t        j                  g d      }t        t        | |dt        j                  d      t        j                  dg            |       y)	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      sc    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   