
    9i                     ~    S SK r S SKrS SKrS SKJr  S SKJrJr  S SK	J
r
Jr  S SKJr   " S S\ R                  5      rg)    N)assert_equal)binary_dilationbinary_erosion)datafeature)img_as_floatc                   \    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)	TestCanny
   c           
          [         R                  " [        R                  " S5      SSS[        R                  " S[
        5      5      nU R                  [        R                  " U5      5        g)z<Test that the Canny filter finds no points for a blank field   r      r   N)r   cannynpzerosonesboolassertFalseanyselfresults     `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/feature/tests/test_canny.pytest_00_00_zerosTestCanny.test_00_00_zeros   sB    rxx11aBGGHd<ST(    c           
          [         R                  " [        R                  R	                  SS9SSS[        R
                  " S[        5      5      nU R                  [        R                  " U5      5        g)z<Test that the Canny filter finds no points in a masked imager   sizer   r   N)	r   r   r   randomuniformr   r   r   r   r   s     r   test_00_01_zeros_maskTestCanny.test_00_01_zeros_mask   sP    II8,aArxx$7O
 	(r   c           
         [         R                  SS2SS24   R                  [        5      S-  u  p[         R                  " [         R
                  " X-  X"-  -   5      S-
  5      S:  n[        R                  " UR                  [        5      SSS[         R                  " UR                  [        5      5      n[        USS9n[        USS9n[         R                  " U[         R                  " U5      5      nU R                  [         R                   " Xt   5      5        [         R"                  " U5      nU R                  US	:  5        U R                  US
:  5        g)z9Test that the Canny filter finds the outlines of a circle8         ?{Gz?r   r      
iterations  @  N)r   mgridastypefloatabssqrtr   r   r   shaper   r   r   logical_andlogical_not
assertTrueallsum)	r   ijcr   cdcecdepoint_counts	            r   test_01_01_circleTestCanny.test_01_01_circle   s    xxS$s(*+2259C?FF2771515=)C/047qxx1a$9OP
 Q1-A!,nnR!34s{+, ffVnd*+d*+r   c           
      Z   [         R                  R                  S5        [         R                  SS2SS24   R	                  [
        5      S-  u  p[         R                  " [         R                  " X-  X"-  -   5      S-
  5      S:  nUR	                  [
        5      S-  [         R                  R                  UR                  S9S-  -   n[        R                  " USSS	[         R                  " UR                  [        5      5      n[        USS
9n[        USS
9n[         R                   " U[         R"                  " U5      5      nU R%                  [         R&                  " X   5      5        [         R(                  " U5      n	U R%                  U	S:  5        U R%                  U	S:  5        g)zETest that the Canny filter finds the circle outlines
in a noisy imager   r&   r'   r(   r)   r   r   皙?皙?r+   r-   r.   N)r   r!   seedr/   r0   r1   r2   r3   r"   r4   r   r   r   r   r   r   r5   r6   r7   r8   r9   )
r   r:   r;   r<   cfr   r=   r>   r?   r@   s
             r   test_01_02_circle_with_noise&TestCanny.test_01_02_circle_with_noise.   s:    			qxxS$s(*+2259C?FF2771515=)C/047XXe_s"RYY%6%6AGG%6%Ds%JJr1c30FG
 Q1-A!,nnR!34s{+,ffVnd*+d*+r   c                 |    U R                  [        [        R                  [        R
                  " S5      SSS5        g )N)r   r   r   r   r   )assertRaises
ValueErrorr   r   r   r   )r   s    r   test_image_shapeTestCanny.test_image_shapeB   s)    *gmmRXXl5KQPQSTUr   c           
      :   [         R                  " [        R                  " S5      SSS[        R                  " S[
        5      5      n[         R                  " [        R                  " S5      SSS5      nU R                  [        R                  " X:H  5      5        g )Nr   r   r   )r   r   r   r   r   r   r7   r8   )r   result1result2s      r   test_mask_noneTestCanny.test_mask_noneE   sa    -- 2Aq!RWWXt=TU-- 2Aq!<w123r   c           	          [        [        R                  " 5       S S S2S S S24   5      n[        R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[
        R                  " USSSS	9n[        X25        g )
Nd   )FFFFFF)FTTTFF)FFFTFF)FFTTFFg333333?g?T)low_thresholdhigh_thresholduse_quantiles)r   r   camerar   arrayr   r   r   )r   imagecorrect_outputr   s       r   test_use_quantilesTestCanny.test_use_quantilesJ   sm    T[[]5S5%C%<89 :7998:	
 S
 	V,r   c                     [         R                  " S5      n[         R                  " [        R                  " U5      S:H  5      (       d   eg )Nr   r   r   )r   r   r8   r   r   r   r[   s     r   test_img_all_onesTestCanny.test_img_all_ones`   s3    !vvgmmE*a/0000r   c           	         [        [        R                  " 5       S S S2S S S24   5      nU R                  [        [
        R                  USSSS9  U R                  [        [
        R                  USSSS9  U R                  [        [
        R                  USSSS9  U R                  [        [
        R                  USSS	S9  [        R                  " 5       nU R                  [        [
        R                  USSS
S9  g )N2   Tr(   g@)rX   rV   rW   c   g?i   )r   r   rY   rK   rL   r   r   ra   s     r   test_invalid_use_quantiles$TestCanny.test_invalid_use_quantilesd   s   T[[]4R42:67MM 	 	
 	MM 	 	
 	MM 	 	
 	MM 	 	
 MM 	 	
r   c           
      8   [         R                  " 5       n[        U5      n[        R                  " U5      n[        R                  " U5      n[        X45        SnSn[        [        R                  " USXV5      [        R                  " USSU-  SU-  5      5        g)zACheck that the same output is produced regardless of image dtype.rD   rE   g      ?   N)r   rY   r   r   r   r   )r   image_uint8image_floatresult_uint8result_floatlowhighs          r   
test_dtypeTestCanny.test_dtype   sw    kkm";/}}[1}}[1\0MM+sC6MM+sC#IsTzB	
r   c                     [         R                  " 5       nS HK  n[        [        R                  " XS9[        R                  " X[
        R                  " U[        S9S95        MM     g)zAThe masked and unmasked algorithms should return the same result.)constantnearestreflect)modedtype)ry   maskN)r   rY   r   r   r   r   	ones_liker   )r   r[   ry   s      r   test_full_mask_matches_no_mask(TestCanny.test_full_mask_matches_no_mask   sD    6De/eR\\%t5TU 7r   c                 V   [         R                  [         R                  4 Hs  n[         R                  " SUS9n[         R                  " U5      R
                  US'   [        R                  " [        SS9   [        R                  " U5        S S S 5        Mu     g ! , (       d  f       M  = f)Nr`   rz   )r*   r*   z'64-bit integer images are not supported)match)r   int64uint64r   iinfomaxpytestraisesrL   r   r   )r   r{   r[   s      r   test_unsupported_int64 TestCanny.test_unsupported_int64   su    hh		*EHHXU3E((5/--E$K"K e$  + s   5B
B(	 N)__name__
__module____qualname____firstlineno__r   r#   rA   rH   rM   rR   r]   rb   ri   rs   r~   r   __static_attributes__r   r   r   r
   r
   
   s@    )
),.,(V4
-,10
d
$%r   r
   )unittestnumpyr   r   skimage._shared.testingr   scipy.ndimager   r   skimager   r   skimage.utilr   TestCaser
   r   r   r   <module>r      s.       0 9 ! %o%!! o%r   