Ë
    ÿ[;j<  ã            	       óŽ   — d dl Zd dlmZ d„ Zddgddgfddgddgfg d¢g d¢fg d¢g d	¢fg d
¢g d¢fg d¢g d¢fg d¢g d¢fdœZdd„Zy)é    N)Úsignalc                 óP  — |dk  r| S t        j                  | j                  d   d«      }t        j                  | j                  d   «      }d|d<   d|d<   d|j                  d   dz
  fg}d}|�s.|j                  «       \  }}| |dd…f   \  }}	| |dd…f   \  }
}|
|z
  }||	z
  }t        j                  ||«       }|	t        j
                  |«      z  |t        j                  |«      z  z   }| |dz   |…dd…f   }||dz   | }|dd…df   |z
  }|dd…df   |	z
  }|dd…df   |
z
  }|dd…df   |z
  }||z  ||z  z   }| |z  ||z  z
  }t        j                  |dkD  |dkD  «      }t        j                  |«      }t        j                  ||df   t        j                  |«      z  ||df   t        j
                  |«      z  z   |z
  «      ||<   t        j                  t        j                  ||   dz  ||   dz  z   «      t        j                  ||   dz  ||   dz  z   «      «      ||<   t        j                  ||kD  «      rF|t        j                  |«      z   dz   }|j                  ||f«       |j                  ||f«       d||<   t        |«      dk(  rd}|s�Œ.| |dd…f   S )	a¸  Approximate a polygonal chain with the specified tolerance.

    It is based on the Douglas-Peucker algorithm.

    Note that the approximated polygon is always within the convex hull of the
    original polygon.

    Parameters
    ----------
    coords : (K, 2) array
        Coordinate array.
    tolerance : float
        Maximum distance from original points of polygon to approximated
        polygonal chain. If tolerance is 0, the original coordinate array
        is returned.

    Returns
    -------
    coords : (L, 2) array
        Approximated polygonal chain where L <= K.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
    r   ÚboolTéÿÿÿÿé   FNé   )ÚnpÚzerosÚshapeÚpopÚarctan2ÚsinÚcosÚlogical_andÚlogical_notÚabsÚminimumÚsqrtÚanyÚargmaxÚappendÚlen)ÚcoordsÚ	toleranceÚchainÚdistsÚ	pos_stackÚend_of_chainÚstartÚendÚr0Úc0Úr1Úc1ÚdrÚdcÚsegment_angleÚsegment_distÚsegment_coordsÚsegment_distsÚdr0Údc0Údr1Údc1Úprojected_lengths0Úprojected_lengths1ÚperpÚeuclÚnew_ends                              úaG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\skimage/measure/_polygon.pyÚapproximate_polygonr5      så  € ð4 �A‚~Øˆä�H‰H�V—\‘\ !‘_ fÓ-€Eä�H‰H�V—\‘\ !‘_Ó%€EØ€Eˆ!�HØ€Eˆ"�IØ�U—[‘[ ‘^ aÑ'Ð(Ð)€IØ€LâØ—]‘]“_‰
ˆˆsà˜šq˜Ñ!‰ˆˆBØ˜šQ˜‘‰ˆˆBØ�"‰WˆØ�"‰WˆÜŸ™ B¨Ó+Ð+ˆØœBŸF™F =Ó1Ñ1°B¼¿¹ÀÓ9NÑ4NÑNˆð   ¨¡	¨C ²Ð 2Ñ3ˆØ˜e a™i¨#Ð.ˆð šQ ˜TÑ" RÑ'ˆØšQ ˜TÑ" RÑ'ˆØšQ ˜TÑ" RÑ'ˆØšQ ˜TÑ" RÑ'ˆà  2™X¨¨b©Ñ0ÐØ!˜T B™Y¨¨r©Ñ1ÐÜ�~‰~Ð0°1Ñ4Ð6HÈ1Ñ6LÓMˆÜ�~‰~˜dÓ#ˆÜ Ÿf™fØ˜4 ˜7Ñ#¤b§f¡f¨]Ó&;Ñ;Ø˜T 1˜WÑ%¬¯©¨}Ó(=Ñ=ñ>àñó
ˆ�dÑô
 !Ÿj™jä�G‰G�C˜‘I ‘N S¨¡Y°!¡^Ñ3Ó4ä�G‰G�C˜‘I ‘N S¨¡Y°!¡^Ñ3Ó4ó	
ˆ�dÑô �6‰6�- )Ñ+Ô,àœbŸi™i¨Ó6Ñ6¸Ñ:ˆGØ×Ñ˜g s˜^Ô,Ø×Ñ˜e WÐ-Ô.Ø!ˆE�'‰Näˆy‹>˜QÒØˆLó_ ðb �%š�(ÑÐó    r   é   )r   é   r   )r   é   r9   )é   é
   r   )r   r;   r:   )r   é   r<   r   )r   r8   é   r8   )é   é#   é   r   )r   r@   r?   r>   )r   é   éF   rA   r   )r   é   é8   rD   rC   )r   r   r7   r9   r:   r8   r>   c                 óN  — |t         vrt        d«      ‚t        j                  | ddd…f   | ddd…f   k(  «      }d}|r| dd…dd…f   } d}t         |   \  }}t        j                  |t
        «      d|z  z  }t        j                  |t
        «      d|z  z  }t        j                  | j                  t        j                  |«      |d¬	«      }t        j                  | j                  t        j                  |«      |d¬	«      }t        j                  |j                  d
   |j                  d
   z   df«      }	|j                  |	d
dd…<   |j                  |	ddd…<   |rt        j                  |	|	ddd…f   g«      }	|r(|s&t        j                  | ddd…f   |	| ddd…f   g«      }	|	S )a¸  Subdivision of polygonal curves using B-Splines.

    Note that the resulting curve is always within the convex hull of the
    original polygon. Circular polygons stay closed after subdivision.

    Parameters
    ----------
    coords : (K, 2) array
        Coordinate array.
    degree : {1, 2, 3, 4, 5, 6, 7}, optional
        Degree of B-Spline. Default is 2.
    preserve_ends : bool, optional
        Preserve first and last coordinate of non-circular polygon. Default is
        False.

    Returns
    -------
    coords : (L, 2) array
        Subdivided coordinate array.

    References
    ----------
    .. [1] http://mrl.nyu.edu/publications/subdiv-course2000/coursenotes00.pdf
    z8Invalid B-Spline degree. Only degree 1 - 7 is supported.r   Nr   ÚvalidÚsamer   Úwrap)ÚmodeÚboundaryr   )Ú_SUBDIVISION_MASKSÚ
ValueErrorr	   ÚallÚarrayÚfloatr   Ú
convolve2dÚTÚ
atleast_2dr
   r   Úvstack)
r   ÚdegreeÚpreserve_endsÚcircularÚmethodÚ	mask_evenÚmask_oddÚevenÚoddÚouts
             r4   Úsubdivide_polygonr]   l   s„  € ð2 Ô'Ñ'ÜÐVÓWÐWä�v‰v�f˜Q¢˜T‘l f¨R²¨U¡mÑ3Ó4€Hà€FÙà˜˜˜šQ˜‘ˆàˆä,¨VÑ4Ñ€Iˆxä—‘˜¤EÓ*¨a°©iÑ8€IÜ�x‰x˜¤%Ó(¨A¨v©IÑ6€Hä×ÑØ�‰”"—-‘- 	Ó*°À&ô€Dô ×
Ñ
Ø�‰”"—-‘- Ó)°Àô€Cô �(‰(�D—J‘J˜q‘M C§I¡I¨a¡LÑ0°!Ð4Ó
5€CØ—‘€Cˆˆˆ1ˆ�IØ�u‰u€C‰ˆ!ˆ�Háä�i‰i˜˜c !¢Q $™iÐ(Ó)ˆá™XÜ�i‰i˜ ¢1 ™ s¨F°2²q°5©MÐ:Ó;ˆà€Jr6   )r   F)Únumpyr	   Úscipyr   r5   rK   r]   © r6   r4   Ú<module>ra      sj   ðÛ Ý òVðz 
ˆAˆ��A�ÐØ	
ˆAˆ��A�ÐÚ’9ÐÚ’JÐÚšÐ&ÚšÐ'ÚÒ-Ð.ñ
Ð ô<r6   