Ë
    \;j“Ò ã                   óf  — d Z ddlmZmZmZ 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ZddlmZ ddlZddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlm Z! ddlm"Z# h d£Z$h d£Z%ejL                  ejN                  ejP                  ejP                  ejP                  dœZ)ejT                  ejV                  ejX                  ejZ                  ej\                  dœZ/d„ Z0d„ Z1d„ Z2	 	 dGd„Z3d„ Z4d„ Z5d„ Z6d„ Z7d„ Z8	 dHd„Z9 G d„ de:«      Z;dId „Z< G d!„ d"ejz                  «      Z> G d#„ d$e>«      Z? G d%„ d&e>«      Z@ G d'„ d(e>«      ZA G d)„ d*e>«      ZB G d+„ d,e>«      ZC G d-„ d.e>«      ZD G d/„ d0e>«      ZE G d1„ d2ejz                  «      ZF G d3„ d4e:«      ZG G d5„ d6ejz                  «      ZH G d7„ d8e:«      ZI G d9„ d:ejz                  «      ZJ G d;„ d<e:«      ZK G d=„ d>ejz                  «      ZL G d?„ d@ejz                  «      ZM G dA„ dBejz                  «      ZN G dC„ dDejz                  «      ZO G dE„ dFe:«      ZPy)JaÔ  Augmenters that apply affine or similar transformations.

List of augmenters:

    * :class:`Affine`
    * :class:`ScaleX`
    * :class:`ScaleY`
    * :class:`TranslateX`
    * :class:`TranslateY`
    * :class:`Rotate`
    * :class:`ShearX`
    * :class:`ShearY`
    * :class:`AffineCv2`
    * :class:`PiecewiseAffine`
    * :class:`PerspectiveTransform`
    * :class:`ElasticTransformation`
    * :class:`Rot90`
    * :class:`WithPolarWarping`
    * :class:`Jigsaw`

é    )Úprint_functionÚdivisionÚabsolute_importN)Úndimage)Ú	transform)Ú_normalize_cv2_input_arr_)Ú_ConcavePolygonRecovereré   )Úmeta)Úblur)Úsizeé   )Ú
parameters)Údtypes)Úrandom>	   ÚboolÚint8Úint16Úint32Úuint8Úuint16Úfloat16Úfloat32Úfloat64>   r   r   r   r   r   r   r   r   )r   r
   r   é   é   ©ÚconstantÚedgeÚ	symmetricÚreflectÚwrapc           
      óŒ  — | t         j                  k(  r2|dv rt        j                  g d¢«      S t        j                  g d¢«      S t        j                  | «      rAd| cxk  rdk  sn J d| fz  «       ‚|dk(  r| dv sJ d| fz  «       ‚t        j
                  | «      S t        | t        «      rÒt        | D �cg c]  }t        j                  |«      ‘Œ c}«      s+J d	t        | D �cg c]  }t        |«      ‘Œ c}«      ›d
�«       ‚t        | D �cg c]  }d|cxk  xr dk  nc ‘Œ c}«      sJ dt        | «      ›d
�«       ‚|dk(  r&t        | D �cg c]  }|dv ‘Œ c}«      sJ d| ›d
�«       ‚t        j                  | «      S t        | t        j                  «      r| S t        dt        | «      ›d
�«      ‚c c}w c c}w c c}w c c}w )N)ÚautoÚcv2©r   r
   r   )r   r
   r   r   é   r   r'   zDExpected order's integer value to be in the interval [0, 5], got %d.r%   zWBackend "cv2" and order=%d was chosen, but cv2 backend can only handle order 0, 1 or 3.z8Expected order list to only contain integers, got types Ú.zGExpected all of order's integer values to be in range 0 <= x <= 5, got z?cv2 backend can only handle order 0, 1 or 3. Got order list of zNExpected order to be imgaug.ALL, int, list of int or StochasticParameter, got )ÚiaÚALLÚiapÚChoiceÚis_single_integerÚDeterministicÚ
isinstanceÚlistÚallÚstrÚtypeÚStochasticParameterÚ	Exception)ÚorderÚbackendÚvals      údG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\imgaug/augmenters/geometric.pyÚ_handle_order_argr:   Q   sÍ  € ð ”—‘‚Ø�oÑ%Ü—:‘:šiÓ(Ð(ô �z‰zš/Ó*Ð*Ü	×Ñ˜EÔ"Ø�EŒ˜QŒð 	"ðØ˜ñ!ó	"ˆð �eÒØ˜IÑ%ð ?ð3Ø6;°Xñ>ó?Ð%ô × Ñ  Ó'Ð'Ü�%œÔÜ¹Ó?¹°#”B×(Ñ(¨Õ-¸Ñ?Ô@ñ 	Dä"¹Ó#?¹°#¤D¨¥I¸Ñ#?Õ@ðCó	DÐ@ô ©UÓ3©U c�A˜–M –M¨UÑ3Ô4ñ 	4ä&)¨%¥jð3ó	4Ð4ð �eÒÜ±EÓ:±E¨S˜˜yÒ(°EÑ:Ô;ñ *â!&ð)ó*Ð;ô �z‰z˜%Ó Ð Ü�%œ×0Ñ0Ô1ØˆÝ
ä*.¨u­+ð	8ó9ð 9ùò @ùâ#?ùÚ3ùò ;s   Â5F2Ã#F7ÄF<ÅGc                 óˆ   — | t         j                  k(  rt        j                  dd«      S t        j                  | dd dd¬«      S )Nr   éÿ   ÚcvalT©Úvalue_rangeÚtuple_to_uniformÚlist_to_choice)r)   r*   r+   ÚUniformÚhandle_continuous_param)r=   s    r9   Ú_handle_cval_argrD   }   s?   € ØŒr�v‰v‚~ô �{‰{˜1˜cÓ"Ð"Ü×&Ñ&Øˆf $¸Øôð ó    c                 ó:  — | t         j                  k(  rt        j                  g d¢«      S t        j                  | «      rt        j
                  | «      S t        | t        «      rzt        | D �cg c]  }t        j                  |«      ‘Œ c}«      s9J ddj                  | D �cg c]  }t        t        |«      «      ‘Œ c}«      z  «       ‚t        j                  | «      S t        | t        j                  «      r| S t        dt        | «      ›d�«      ‚c c}w c c}w )Nr   z<Expected list of modes to only contain strings, got types %sú, úXExpected mode to be imgaug.ALL, a string, a list of strings or StochasticParameter, got r(   )r)   r*   r+   r,   Ú	is_stringr.   r/   r0   r1   Újoinr2   r3   r4   r5   )Úmoder8   Úvs      r9   Ú_handle_mode_argrM   ‰   sî   € ØŒr�v‰v‚~Ü�z‰zò .ó /ð 	/ä	‡|�|�DÔÜ× Ñ  Ó&Ð&Ü�$œÔÜ±Ó6±¨#”B—L‘L Õ%°Ñ6Ô7ð 	DðØŸ)™)¹4Ó$@¹4°a¤S¬¨a«¥\¸4Ñ$@ÓAñCó	DÐ7ô �z‰z˜$ÓÐÜ�$œ×/Ñ/Ô0ØˆÝ
ä-1°$­Zð	:ó;ð ;ùò 7ùâ$@s   Á.DÂ"Dc                 ó€  — t        j                  |«      r|gt        | j                  d   «      z  }| j                  dk(  r| S t        j                  | j                  «      \  }}}	|dv}
|dk(  r| j                  j                  t        v}n| j                  j                  t        v}|
xs |}|dk(  xs	 |dk(  xr |}|r.|d   }t        t        ||	«      |«      }t        | |||||¬«      }|S |rJ | d| j                  ›d�f«       ‚t        | |t        |D �cg c]  }t!        |«      ‘Œ c}«      |||¬«      }|S c c}w )	Nr   r   r&   Úskimager$   )r=   rK   r6   Úoutput_shapez"cv2 backend in Affine got a dtype zE, which it cannot handle. Try using a different dtype or set order=0.)r)   r-   ÚlenÚshaper   ÚiadtÚget_value_range_of_dtypeÚdtypeÚnameÚ_VALID_DTYPES_CV2_ORDER_0Ú_VALID_DTYPES_CV2_ORDER_NOT_0ÚmaxÚminÚ_warp_affine_arr_skimageÚ_warp_affine_arr_cv2ÚtupleÚint)ÚarrÚmatrixr6   rK   r=   rP   r7   Ú	min_valueÚ_center_valueÚ	max_valueÚcv2_bad_orderÚcv2_bad_dtypeÚcv2_impossibleÚuse_skimageÚimage_warpedrL   s                   r9   Ú_warp_affine_arrri   ›   s  € ä	×Ñ˜DÔ!Øˆvœ˜CŸI™I a™LÓ)Ñ)ˆð ‡x�x�1‚}Øˆ
ô 	×%Ñ% c§i¡iÓ0ñ (€Iˆ}˜ið  Ð*€MØ�‚zà�I‰I�N‰NÜ,ð-ñ 	ð
 �I‰I�N‰NÜ0ð1ð 	ð #Ò3 m€Nà�9Ñò 	2Ø�vÑÒ0 .ð ñ ð �A‰wˆä”3�t˜YÓ'¨Ó3ˆÜ/ØØØØØØ%ô
ˆð. Ðñ !ð 	ØÑð —	“	ðð#ó 	Ð ô ,ØØÜ©Ó-© 1œ˜A�¨Ñ-Ó.ØØØ%ô
ˆð Ðùò .s   ÄD;c           	      ó  — t        j                  | g d¢g d¢d ¬«       | j                  }t        j                  | |j
                  |||d|¬«      }|t        j                  k(  r|dkD  }|S t        j                  ||«      }|S )N©
r   r   r   Úuint32r   r   r   r   r   r   ©	Úuint64Úuint128Úuint256Úint64Úint128Úint256Úfloat96Úfloat128Úfloat256©ÚallowedÚ
disallowedÚ	augmenterT©r6   rK   r=   Úpreserve_rangerP   ç      à?)	rS   Úgate_dtypesrU   ÚtfÚwarpÚinverseÚnpÚbool_Úrestore_dtypes_)r_   r`   r=   rK   r6   rP   Úinput_dtyperh   s           r9   r[   r[   Ö   sŽ   € Ü×ÑØò2ò7ð õ	ð —)‘)€Kä—7‘7ØØ�‰ØØØØØ!ô€Lð ”b—h‘hÒØ# cÑ)ˆð Ðô ×+Ñ+¨L¸+ÓFˆàÐrE   c                 óÈ  — t        j                  | g d¢g d¢d ¬«       |dk7  r$| j                  j                  dk7  sJ d|fz  «       ‚| j                  }|t        j
                  t        j                  fv r | j                  t        j                  «      } n7|t        j                  k(  r$|dk7  r| j                  t        j                  «      } t        t	        j                  |d   «      «      t        t	        j                  |d   «      «      f}t        j                  ||«      }t        j                  ||«      }| j                   d   }|d	k  rVt#        j$                  t'        | «      |j(                  d d
 ||||¬«      }	|	j*                  d
k(  r•|	dt        j,                  f   }	nt/        j0                  |«      D �
cg c]J  }
t#        j$                  t'        | d d …d d …|
f   «      |j(                  d d
 |||t3        |d   g«      ¬«      ‘ŒL }	}
t	        j4                  |	d¬«      }	|j                  dk(  r|	dkD  }	|	S |j                  dv rt        j6                  |	|«      }	|	S c c}
w )N©	r   r   r   r   r   r   r   r   r   ©
rl   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   r   r   zkAffine only supports cv2-based transformations of int32 arrays when using order=0, but order was set to %d.r
   éÿÿÿÿr   r   ©ÚdsizeÚflagsÚ
borderModeÚborderValue.©Úaxisr   r}   )r   r   )rS   r~   rU   rV   r‚   rƒ   r   Úastyper   r   r   r^   ÚroundÚ_AFFINE_MODE_SKIMAGE_TO_CV2ÚgetÚ*_AFFINE_INTERPOLATION_ORDER_SKIMAGE_TO_CV2rR   r%   Ú
warpAffiner   ÚparamsÚndimÚnewaxisÚsmÚxranger]   Ústackr„   )r_   r`   r=   rK   r6   rP   r…   r‹   Únb_channelsrh   Úcs              r9   r\   r\   ÷   sE  € Ü×ÑØò2ò7ð õ	ð �‚zØ�y‰y�~‰~ Ò(ð 	ðBàðEñó	Ð(ð
 —)‘)€KØ”r—x‘x¤§¡Ð,Ñ,Ø�j‰jœŸ™Ó$‰Ø	œŸ™Ò	 E¨Q¢JØ�j‰jœŸ™Ó"ˆô 	ŒB�H‰H�\ !‘_Ó%Ó&ÜŒB�H‰H�\ !‘_Ó%Ó&ð€Eô '×*Ñ*¨4°Ó6€DÜ6×:Ñ:¸5À%ÓH€Eð —)‘)˜B‘-€KØ�aÒô —~‘~Ü% cÓ*Ø�M‰M˜"˜1ÐØØØØô
ˆð ×Ñ Ò!Ø'¨¬R¯Z©Z¨Ñ8‰Lô —Y‘Y˜{Ô+ó	-ñ ,�ô �N‰NÜ)¨#ªa²°A¨g©,Ó7Ø—‘˜b˜qÐ!ØØØÜ! 4¨¡7 )Ó,öð ,ð 	ð 	-ô —x‘x °2Ô6ˆà×Ñ˜6Ò!Ø# cÑ)ˆð Ðð 
×	Ñ	Ð0Ñ	0Ü×+Ñ+¨L¸+ÓFˆàÐùò#	-s   Æ;AIc                 ó¦  — |d d \  }}|dk(  s|dk(  r| |fS t        j                  ddgd|dz
  g|dz
  |dz
  g|dz
  dgg«      } | |«      }|d d …df   j                  «       }|d d …df   j                  «       }|d d …df   j                  «       }|d d …df   j                  «       }||z
  dz   }	||z
  dz   }
t	        |«      dk(  rt        j
                  |	|
|d   f«      }nt        j
                  |	|
f«      }t        |j                  «       D �cg c]  }t        |«      ‘Œ c}«      }| | f}t        j                  |¬«      }| |z   } | |fS c c}w )Nr   r   r
   r   ©Útranslation)r‚   ÚarrayrZ   rY   rQ   Úceilr]   Útolistr^   r   ÚSimilarityTransform)r`   Úinput_shapeÚheightÚwidthÚcornersÚmincÚminrÚmaxcÚmaxrÚ
out_heightÚ	out_widthrP   rL   r¡   Úmatrix_to_fits                  r9   Ú!_compute_affine_warp_output_shaper±   B  s�  € Ø  �O�M€FˆEà�‚{�e˜q’jØ�{Ð"Ð"ô �h‰hØ	
ˆAˆØ	
ˆF�Q‰JˆØ	�‰�F˜Q‘JÐØ	�‰�Aˆð	ó €Gñ �W‹o€GØ’1�a�4‰=×ÑÓ€DØ’1�a�4‰=×ÑÓ€DØ’1�a�4‰=×ÑÓ€DØ’1�a�4‰=×ÑÓ€DØ˜‘˜q‘€JØ�t‘˜a‘€IÜ
ˆ;Ó˜1ÒÜ—w‘w 
¨I°{À1±~ÐFÓG‰ä—w‘w 
¨IÐ6Ó7ˆÜ¨,×*=Ñ*=Ô*?Ó@Ñ*? Qœ#˜a�&Ð*?Ñ@ÓA€Là�5˜4˜%�.€KÜ×*Ñ*°{ÔC€MØ�mÑ#€FØ�<ÐÐùò As   ÄEc                 ó
  — |j                   dd \  }}| j                  dk\  s J d| j                  | j                   fz  «       ‚| j                   d   |z  dk(  sJ d| j                   d   |fz  «       ‚| j                   d   |z  dk(  sJ d| j                   d   |fz  «       ‚| j                   d   |z  }| j                   d   |z  }t        j                  |j	                  «       ||f«      \  }}t        j
                  | «      }d}	t        j                  |«      D ]i  }
t        j                  |«      D ]O  }||	   ||	   }}|
|z  }||z   }||z  }||z   }||z  }||z   }||z  }||z   }| ||…||…f   }||||…||…f<   |	dz  }	ŒQ Œk |S )a  Move cells of an image similar to a jigsaw puzzle.

    This function will split the image into ``rows x cols`` cells and
    move each cell to the target index given in `destinations`.

    Added in 0.4.0.

    **Supported dtypes**:

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; fully tested
        * ``uint32``: yes; fully tested
        * ``uint64``: yes; fully tested
        * ``int8``: yes; fully tested
        * ``int16``: yes; fully tested
        * ``int32``: yes; fully tested
        * ``int64``: yes; fully tested
        * ``float16``: yes; fully tested
        * ``float32``: yes; fully tested
        * ``float64``: yes; fully tested
        * ``float128``: yes; fully tested
        * ``bool``: yes; fully tested

    Parameters
    ----------
    arr : ndarray
        Array with at least two dimensions denoting height and width.

    destinations : ndarray
        2-dimensional array containing for each cell the id of the destination
        cell. The order is expected to a flattened c-order, i.e. row by row.
        The height of the image must be evenly divisible by the number of
        rows in this array. Analogous for the width and columns.

    Returns
    -------
    ndarray
        Modified image with cells moved according to `destinations`.

    r   r   zFExpected array with at least two dimensions, but got %d with shape %s.z¨Expected image height to by divisible by number of rows, but got height %d and %d rows. Use cropping or padding to modify the image height or change the number of rows.r
   z®Expected image width to by divisible by number of columns, but got width %d and %d columns. Use cropping or padding to modify the image width or change the number of columns.)rR   r˜   r‚   Úunravel_indexÚflattenÚ
zeros_likeÚarange)r_   ÚdestinationsÚnb_rowsÚnb_colsÚcell_heightÚ
cell_widthÚ	dest_rowsÚ	dest_colsÚresultÚiÚ
source_rowÚ
source_colÚdest_rowÚdest_colÚ	source_y1Ú	source_y2Ú	source_x1Ú	source_x2Údest_y1Údest_y2Údest_x1Údest_x2Úsources                          r9   Úapply_jigsawrÍ   c  sõ  € ðX $×)Ñ)¨!¨AÐ.Ñ€GˆWà�8‰8�qŠ=ð -ð	Ø—x‘x §¡Ð+ñ	,ó-ˆ=ð �I‰I�a‰L˜7Ñ" qÒ(ð ð	/à25·)±)¸A±,ÀÐ1Hñ	IóÐ(ð
 �I‰I�a‰L˜7Ñ" qÒ(ð ð	1à47·I±I¸a±LÀ'Ð3Jñ	KóÐ(ð —)‘)˜A‘, 'Ñ)€KØ—‘˜1‘ Ñ(€Jä×+Ñ+Ø×ÑÓ ¨'Ð 2ó4Ñ€Iˆyô �]‰]˜3Ó€FØ	€AÜ—i‘i Ö(ˆ
ÜŸ)™) GÖ,ˆJà!*¨1¡¨y¸©|�hˆHà" [Ñ0ˆIØ! KÑ/ˆIØ" ZÑ/ˆIØ! JÑ.ˆIà Ñ,ˆGØ Ñ+ˆGØ Ñ+ˆGØ 
Ñ*ˆGà˜ 9Ð,¨i¸	Ð.AÐAÑBˆFØ7=ˆF�7˜7�? G¨G OÐ3Ñ4à�‰F‰Añ# -ð )ð( €MrE   c                 óè  — |j                   dd \  }}|dd \  }}||z  }||z  }t        j                  |j                  «       ||f«      \  }	}
t        j                  | «      }t        | «      D ]�  \  }\  }}|dk  xs ||k\  }|dk  xs ||k\  }|s|rŒ&t        ||z  «      }t        ||z  «      }||z  |z   }|	|   }|
|   }||z  }||z  }||z  }||z  }|||z
  z   ||df<   |||z
  z   ||df<   Œƒ |S )a7  Move coordinates on an image similar to a jigsaw puzzle.

    This is the same as :func:`apply_jigsaw`, but moves coordinates within
    the cells.

    Added in 0.4.0.

    Parameters
    ----------
    coords : ndarray
        ``(N, 2)`` array denoting xy-coordinates.

    destinations : ndarray
        See :func:`apply_jigsaw`.

    image_shape : tuple of int
        ``(height, width, ...)`` shape of the image on which the
        coordinates are placed. Only height and width are required.

    Returns
    -------
    ndarray
        Moved coordinates.

    r   r   r
   )rR   r‚   r³   r´   ÚcopyÚ	enumerater^   )Úcoordsr·   Úimage_shaper¸   r¹   r§   r¨   rº   r»   r¼   r½   r¾   r¿   ÚxÚyÚooi_xÚooi_yrÀ   rÁ   Úsource_cell_idxrÂ   rÃ   rÄ   rÆ   rÈ   rÊ   s                             r9   Úapply_jigsaw_to_coordsrØ   ¾  sV  € ð: $×)Ñ)¨!¨AÐ.Ñ€GˆWà  !Ð$�M€FˆEØ˜GÑ#€KØ˜'Ñ!€Jä×+Ñ+Ø×ÑÓ ¨'Ð 2ó4Ñ€Iˆyô �W‰W�V‹_€Fô ˜vÖ&‰	ˆ‰6ˆAˆqØ�Q‘Ò$˜!˜u™*ˆØ�Q‘Ò%˜!˜v™+ˆÙ‘EØä˜˜kÑ)Ó*ˆ
Ü˜˜j™Ó)ˆ
Ø%¨Ñ/°:Ñ=ˆØ˜_Ñ-ˆØ˜_Ñ-ˆà Ñ,ˆ	Ø Ñ+ˆ	à˜[Ñ(ˆØ˜ZÑ'ˆà ! i¡-Ñ0ˆˆq�!ˆt‰Ø ! i¡-Ñ0ˆˆq�!ˆtŠð' 'ð* €MrE   c                 ó‚  — |dv sJ d|fz  «       ‚t        j                  |«      }|j                  d|| |fd¬«      }|j                  d|| ||fd¬«      }t        j                  | |z  «      j                  | |f«      }t        j                  |«      D �])  }	|dd…dd…|	f   }
t        j                  | «      D �]  }t        j                  |«      D ]æ  }|||f   dkD  sŒ|dz
  |dz   f|dz   |dz   f|dz   |dz   f|dz   |dz
  f|dz
  |dz
  f|dz
  |dz   f|dz   |dz   f|dz   |dz
  fd	œ|
||f      \  }}t        t        || dz
  «      d«      }t        t        ||dz
  «      d«      }|||f   }||f||fk7  sŒ§|dk\  sŒ­|||f   }|||f   }||||f<   ||||f<   |||fxx   dz  cc<   |||fxx   dz  cc<   Œè �Œ �Œ, |S )
af  Generate a destination pattern for :func:`apply_jigsaw`.

    Added in 0.4.0.

    Parameters
    ----------
    nb_rows : int
        Number of rows to split the image into.

    nb_cols : int
        Number of columns to split the image into.

    max_steps : int
        Maximum number of cells that each cell may be moved.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState
        Seed value or alternatively RNG to use.
        If ``None`` the global RNG will be used.

    connectivity : int, optional
        Whether a diagonal move of a cell counts as one step
        (``connectivity=8``) or two steps (``connectivity=4``).

    Returns
    -------
    ndarray
        2-dimensional array containing for each cell the id of the target
        cell.

    )r   é   z(Expected connectivity of 4 or 8, got %d.r   T)r   ÚendpointFNr
   )r   r
   r   r   r   r'   é   é   )ÚiarandomÚRNGÚintegersr‚   r¶   ÚreshaperY   rZ   )r¸   r¹   Ú	max_stepsÚseedÚconnectivityÚrandom_stateÚstepsÚ
directionsr·   ÚstepÚdirections_steprÔ   rÓ   Úy_targetÚx_targetÚtarget_stepsÚsource_destÚtarget_dests                     r9   Úgenerate_jigsaw_destinationsrï   ÿ  sP  € ð@ ˜6Ñ!ð FØ2°l°_ÑDóFÐ!ä—<‘< Ó%€LØ×!Ñ! ! Y°g¸wÐ5GØ+/ð "ó 1€Eà×&Ñ& q¨,Ø-4°g¸yÐ,IØ05ð 'ó 7€Jô —9‘9˜W W™_Ó-×5Ñ5°wÀÐ6HÓI€Lä—	‘	˜)×$ˆØ$¢Qª¨4 ZÑ0ˆä—‘˜7×#ˆAÜ—Y‘Y˜wÖ'�Ø˜˜A˜‘; “?à˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:Ø˜a™C  1¡˜:ñ	*ð & a¨ dÑ+ñ	*-Ñ&�H˜hô  #¤3 x°¸±Ó#;¸QÓ?�HÜ"¤3 x°¸±Ó#;¸QÓ?�Hà#(¨°8Ð);Ñ#<�LØ˜1�v (¨HÐ!5Ó5¸,È!Ó:KØ&2°1°a°4Ñ&8˜Ø&2°8¸XÐ3EÑ&F˜Ø-8˜ Q¨ TÑ*Ø;F˜ X¨xÐ%7Ñ8à˜a ˜d› qÑ(›Ø˜h¨Ð0Ó1°QÑ6Ô1ò/ (ò $ð %ð: ÐrE   c                   ó6   — e Zd Z	 	 dd„Zd„ Z	 dd„Zd	d„Zd„ Zy)
Ú_AffineSamplingResultNc	                 ót   — || _         || _        || _        || _        || _        || _        || _        || _        y ©N©ÚscaleÚ	translateÚtranslate_modeÚrotateÚshearr=   rK   r6   )	Úselfrõ   rö   r÷   rø   rù   r=   rK   r6   s	            r9   Ú__init__z_AffineSamplingResult.__init__J  s;   € àˆŒ
Ø"ˆŒØ,ˆÔØˆŒØˆŒ
ØˆŒ	ØˆŒ	Øˆ�
rE   c                 ó(  — | j                   d   |   }| j                   d   |   }| j                  d   |   }| j                  d   |   }| j                  dv sJ d| j                  ›d�«       ‚| j                  dk(  r	||d   z  }n||d   z  |d   z  }| j                  dk(  r	||d   z  }	n||d   z  |d   z  }	| j                  |   }
| j                  d   |   }| j                  d   |   }t        j                  |
||g«      \  }}}||||	||||
||dœ
S )Nr
   r   )ÚpxÚpercentz!Expected 'px' or 'percent', got 'z'.rþ   )
Úscale_yÚscale_xÚtranslate_y_pxÚtranslate_x_pxÚ
rotate_radÚshear_y_radÚshear_x_radÚ
rotate_degÚshear_y_degÚshear_x_deg)rõ   rö   r÷   rø   rù   r‚   Údeg2rad)rú   ÚidxÚ	arr_shaperÒ   rÿ   r   Útranslate_yÚtranslate_xr  r  r  r  r  r  r  r  s                   r9   Úget_affine_parametersz+_AffineSamplingResult.get_affine_parametersV  sY  € Ø—*‘*˜Q‘- Ñ$ˆØ—*‘*˜Q‘- Ñ$ˆà—n‘n QÑ'¨Ñ,ˆØ—n‘n QÑ'¨Ñ,ˆØ×"Ñ"Ð&7Ñ7ñ 	NØ7;×7JÓ7JÐLó	NÐ7à×Ñ )Ò+Ø(¨9°Q©<Ñ7‰Nà)¨K¸©NÑ:¸iÈ¹lÑJˆNØ×Ñ )Ò+Ø(¨9°Q©<Ñ7‰Nà)¨K¸©NÑ:¸iÈ¹lÑJˆNà—[‘[ Ñ%ˆ
Ø—j‘j ‘m CÑ(ˆØ—j‘j ‘m CÑ(ˆÜ/1¯z©zØ˜ [ð;2ó 03Ñ,ˆ
�K ð ØØ,Ø,Ø$Ø&Ø&Ø$Ø&Ø&ñ
ð 	
rE   c                 ó,  — d|v rt        j                  «       |fS |dd \  }}| j                  |||¬«      }|dz  |d   z
  }	|dz  |d   z
  }
t        j                  |
 |	 g¬«      }t        j                  d¬«      }t        j                  |d	   ¬
«      }t        j                  d¬«      }t        j                  |d   |d   f|d   |d   f|d   |d   ¬«      }t        j                  |
|	g¬«      }||z   |z   |z   |z   |z   }|rt	        ||«      S ||fS )Nr   r   )r  rÒ   ç       @r
   r    gz ‹üú!ù¿)Úrotationr  )rù   gz ‹üú!ù?r   rÿ   r  r  r  r  ©rõ   r¡   r  rù   )r   ÚAffineTransformr  r¥   r±   )rú   r
  r  rÒ   Ú
fit_outputÚ	shift_addr§   r¨   r—   Úshift_yÚshift_xÚmatrix_to_topleftÚmatrix_shear_y_rotÚmatrix_shear_yÚmatrix_shear_y_rot_invÚmatrix_transformsÚmatrix_to_centerr`   s                     r9   Ú	to_matrixz_AffineSamplingResult.to_matrix|  sw  € à�ÑÜ×%Ñ%Ó'¨Ð2Ð2à! ! A˜‰ˆ�à×+Ñ+¨CØ6?Ø8Cð ,ó Eˆð ˜3‘, ¨1¡Ñ-ˆØ˜#‘+ 	¨!¡Ñ,ˆä×2Ñ2Ø!˜ G 8Ð,ô.Ðä×/Ñ/¸ÔEÐÜ×+Ñ+°&¸Ñ2GÔHˆÜ!#×!3Ñ!3¸ZÔ!HÐÜ×.Ñ.Ø˜)Ñ$ f¨YÑ&7Ð8ØÐ 0Ñ1°6Ð:JÑ3KÐLØ˜LÑ)Ø˜Ñ'ô	
Ðô ×1Ñ1Ø  'Ð*ô,Ðà#Ø&ñ'à"ñ#ð +ñ+ð &ñ	&ð
 %ñ%ˆñ Ü4°V¸YÓGÐGØ�yÐ Ð rE   c                 ó,   — | j                  |||||«      S ró   )r  )rú   r
  r  r  r  s        r9   Úto_matrix_cbaz#_AffineSamplingResult.to_matrix_cba¤  s   € Ø�~‰~˜c 9¨i¸ÀYÓOÐOrE   c           
      óÈ   — t        | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  ¬«      S )Nrô   )	rñ   rõ   rö   r÷   rø   rù   r=   rK   r6   ©rú   s    r9   rÏ   z_AffineSamplingResult.copy¨  sI   € Ü$Ø—*‘*Ø—n‘nØ×.Ñ.Ø—;‘;Ø—*‘*Ø—‘Ø—‘Ø—*‘*ô	
ð 		
rE   )NNrý   NNNNN))r}   r}   ))ç        r#  )Ú__name__Ú
__module__Ú__qualname__rû   r  r  r   rÏ   © rE   r9   rñ   rñ   I  s)   „ ØBFØFJó	ò$
ðN 'ó%!óPPó

rE   rñ   c                 ó®   — t        j                  g d¢g d¢g d¢g«      }t        j                  t        j                  || j                  z
  «      «      |k  S )N)r
   r   r   )r   r
   r   )r   r   r
   )r‚   r   ÚaverageÚabsr—   )r`   ÚepsÚidentitys      r9   Ú_is_identity_matrixr-  µ  sF   € Ü�z‰zÚÚÚðó €Hô
 �:‰:”b—f‘f˜X¨¯©Ñ5Ó6Ó7¸3Ñ>Ð>rE   c                   ó‚   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zed„ «       Zed„ «       Zed„ «       Zd„ Z		 	 dd„Z
d„ Zd	„ Zd
„ Zˆ xZS )ÚAffinea U  
    Augmenter to apply affine transformations to images.

    This is mostly a wrapper around the corresponding classes and functions
    in OpenCV and skimage.

    Affine transformations involve:

        - Translation ("move" image on the x-/y-axis)
        - Rotation
        - Scaling ("zoom" in/out)
        - Shear (move one side of the image, turning a square into a trapezoid)

    All such transformations can create "new" pixels in the image without a
    defined content, e.g. if the image is translated to the left, pixels
    are created on the right.
    A method has to be defined to deal with these pixel values. The
    parameters `cval` and `mode` of this class deal with this.

    Some transformations involve interpolations between several pixels
    of the input image to generate output pixel values. The parameter `order`
    deals with the method of interpolation used for this.

    .. note::

        While this augmenter supports segmentation maps and heatmaps that
        have a different size than the corresponding image, it is strongly
        recommended to use the same aspect ratios. E.g. for an image of
        shape ``(200, 100, 3)``, good segmap/heatmap array shapes also follow
        a ``2:1`` ratio and ideally are ``(200, 100, C)``, ``(100, 50, C)`` or
        ``(50, 25, C)``. Otherwise, transformations involving rotations or
        shearing will produce unaligned outputs.
        For performance reasons, there is no explicit validation of whether
        the aspect ratios are similar.

    **Supported dtypes**:

    if (backend="skimage", order in [0, 1]):

        * ``uint8``: yes; tested
        * ``uint16``: yes; tested
        * ``uint32``: yes; tested (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested
        * ``int16``: yes; tested
        * ``int32``: yes; tested  (1)
        * ``int64``: no (2)
        * ``float16``: yes; tested
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (2)
        * ``bool``: yes; tested

        - (1) scikit-image converts internally to float64, which might
              affect the accuracy of large integers. In tests this seemed
              to not be an issue.
        - (2) results too inaccurate

    if (backend="skimage", order in [3, 4]):

        * ``uint8``: yes; tested
        * ``uint16``: yes; tested
        * ``uint32``: yes; tested (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested
        * ``int16``: yes; tested
        * ``int32``: yes; tested  (1)
        * ``int64``: no (2)
        * ``float16``: yes; tested
        * ``float32``: yes; tested
        * ``float64``: limited; tested (3)
        * ``float128``: no (2)
        * ``bool``: yes; tested

        - (1) scikit-image converts internally to float64, which might
              affect the accuracy of large integers. In tests this seemed
              to not be an issue.
        - (2) results too inaccurate
        - (3) ``NaN`` around minimum and maximum of float64 value range

    if (backend="skimage", order=5]):

            * ``uint8``: yes; tested
            * ``uint16``: yes; tested
            * ``uint32``: yes; tested (1)
            * ``uint64``: no (2)
            * ``int8``: yes; tested
            * ``int16``: yes; tested
            * ``int32``: yes; tested  (1)
            * ``int64``: no (2)
            * ``float16``: yes; tested
            * ``float32``: yes; tested
            * ``float64``: limited; not tested (3)
            * ``float128``: no (2)
            * ``bool``: yes; tested

            - (1) scikit-image converts internally to ``float64``, which
                  might affect the accuracy of large integers. In tests
                  this seemed to not be an issue.
            - (2) results too inaccurate
            - (3) ``NaN`` around minimum and maximum of float64 value range

    if (backend="cv2", order=0):

        * ``uint8``: yes; tested
        * ``uint16``: yes; tested
        * ``uint32``: no (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested
        * ``int16``: yes; tested
        * ``int32``: yes; tested
        * ``int64``: no (2)
        * ``float16``: yes; tested (3)
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (1)
        * ``bool``: yes; tested (3)

        - (1) rejected by cv2
        - (2) changed to ``int32`` by cv2
        - (3) mapped internally to ``float32``

    if (backend="cv2", order=1):

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; tested
        * ``uint32``: no (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested (3)
        * ``int16``: yes; tested
        * ``int32``: no (2)
        * ``int64``: no (2)
        * ``float16``: yes; tested (4)
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (1)
        * ``bool``: yes; tested (4)

        - (1) rejected by cv2
        - (2) causes cv2 error: ``cv2.error: OpenCV(3.4.4)
              (...)imgwarp.cpp:1805: error:
              (-215:Assertion failed) ifunc != 0 in function 'remap'``
        - (3) mapped internally to ``int16``
        - (4) mapped internally to ``float32``

    if (backend="cv2", order=3):

        * ``uint8``: yes; tested
        * ``uint16``: yes; tested
        * ``uint32``: no (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested (3)
        * ``int16``: yes; tested
        * ``int32``: no (2)
        * ``int64``: no (2)
        * ``float16``: yes; tested (4)
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (1)
        * ``bool``: yes; tested (4)

        - (1) rejected by cv2
        - (2) causes cv2 error: ``cv2.error: OpenCV(3.4.4)
              (...)imgwarp.cpp:1805: error:
              (-215:Assertion failed) ifunc != 0 in function 'remap'``
        - (3) mapped internally to ``int16``
        - (4) mapped internally to ``float32``


    Parameters
    ----------
    scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter or dict {"x": number/tuple/list/StochasticParameter, "y": number/tuple/list/StochasticParameter}, optional
        Scaling factor to use, where ``1.0`` denotes "no change" and
        ``0.5`` is zoomed out to ``50`` percent of the original size.

            * If a single number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]``. That value will be
              used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    translate_percent : None or number or tuple of number or list of number or imgaug.parameters.StochasticParameter or dict {"x": number/tuple/list/StochasticParameter, "y": number/tuple/list/StochasticParameter}, optional
        Translation as a fraction of the image height/width (x-translation,
        y-translation), where ``0`` denotes "no change" and ``0.5`` denotes
        "half of the axis size".

            * If ``None`` then equivalent to ``0.0`` unless `translate_px` has
              a value other than ``None``.
            * If a single number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]``. That sampled fraction
              value will be used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    translate_px : None or int or tuple of int or list of int or imgaug.parameters.StochasticParameter or dict {"x": int/tuple/list/StochasticParameter, "y": int/tuple/list/StochasticParameter}, optional
        Translation in pixels.

            * If ``None`` then equivalent to ``0`` unless `translate_percent`
              has a value other than ``None``.
            * If a single int, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the discrete interval ``[a..b]``. That number
              will be used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    rotate : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Rotation in degrees (**NOT** radians), i.e. expected value range is
        around ``[-360, 360]``. Rotation happens around the *center* of the
        image, not the top left corner as in some other frameworks.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]`` and used as the rotation
              value.
            * If a list, then a random value will be sampled from that list
              per image.
            * If a ``StochasticParameter``, then this parameter will be used to
              sample the rotation value per image.

    shear : number or tuple of number or list of number or imgaug.parameters.StochasticParameter or dict {"x": int/tuple/list/StochasticParameter, "y": int/tuple/list/StochasticParameter}, optional
        Shear in degrees (**NOT** radians), i.e. expected value range is
        around ``[-360, 360]``, with reasonable values being in the range
        of ``[-45, 45]``.

            * If a number, then that value will be used for all images as
              the shear on the x-axis (no shear on the y-axis will be done).
            * If a tuple ``(a, b)``, then two value will be uniformly sampled
              per image from the interval ``[a, b]`` and be used as the
              x- and y-shear value.
            * If a list, then two random values will be sampled from that list
              per image, denoting x- and y-shear.
            * If a ``StochasticParameter``, then this parameter will be used
              to sample the x- and y-shear values per image.
            * If a dictionary, then similar to `translate_percent`, i.e. one
              ``x`` key and/or one ``y`` key are expected, denoting the
              shearing on the x- and y-axis respectively. The allowed datatypes
              are again ``number``, ``tuple`` ``(a, b)``, ``list`` or
              ``StochasticParameter``.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        Interpolation order to use. Same meaning as in ``skimage``:

            * ``0``: ``Nearest-neighbor``
            * ``1``: ``Bi-linear`` (default)
            * ``2``: ``Bi-quadratic`` (not recommended by skimage)
            * ``3``: ``Bi-cubic``
            * ``4``: ``Bi-quartic``
            * ``5``: ``Bi-quintic``

        Method ``0`` and ``1`` are fast, ``3`` is a bit slower, ``4`` and
        ``5`` are very slow. If the backend is ``cv2``, the mapping to
        OpenCV's interpolation modes is as follows:

            * ``0`` -> ``cv2.INTER_NEAREST``
            * ``1`` -> ``cv2.INTER_LINEAR``
            * ``2`` -> ``cv2.INTER_CUBIC``
            * ``3`` -> ``cv2.INTER_CUBIC``
            * ``4`` -> ``cv2.INTER_CUBIC``

        As datatypes this parameter accepts:

            * If a single ``int``, then that order will be used for all images.
            * If a list, then a random value will be sampled from that list
              per image.
            * If ``imgaug.ALL``, then equivalant to list ``[0, 1, 3, 4, 5]``
              in case of ``backend=skimage`` and otherwise ``[0, 1, 3]``.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the order value to use.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        The constant value to use when filling in newly created pixels.
        (E.g. translating by 1px to the right will create a new 1px-wide
        column of pixels on the left of the image).  The value is only used
        when `mode=constant`. The expected value range is ``[0, 255]`` for
        ``uint8`` images. It may be a float value.

            * If this is a single number, then that value will be used
              (e.g. 0 results in black pixels).
            * If a tuple ``(a, b)``, then three values (for three image
              channels) will be uniformly sampled per image from the
              interval ``[a, b]``.
            * If a list, then a random value will be sampled from that list
              per image.
            * If ``imgaug.ALL`` then equivalent to tuple ``(0, 255)`.
            * If a ``StochasticParameter``, a new value will be sampled from
              the parameter per image.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        Method to use when filling in newly created pixels.
        Same meaning as in ``skimage`` (and :func:`numpy.pad`):

            * ``constant``: Pads with a constant value
            * ``edge``: Pads with the edge values of array
            * ``symmetric``: Pads with the reflection of the vector mirrored
              along the edge of the array.
            * ``reflect``: Pads with the reflection of the vector mirrored on
              the first and last values of the vector along each axis.
            * ``wrap``: Pads with the wrap of the vector along the axis.
              The first values are used to pad the end and the end values
              are used to pad the beginning.

        If ``cv2`` is chosen as the backend the mapping is as follows:

            * ``constant`` -> ``cv2.BORDER_CONSTANT``
            * ``edge`` -> ``cv2.BORDER_REPLICATE``
            * ``symmetric`` -> ``cv2.BORDER_REFLECT``
            * ``reflect`` -> ``cv2.BORDER_REFLECT_101``
            * ``wrap`` -> ``cv2.BORDER_WRAP``

        The datatype of the parameter may be:

            * If a single string, then that mode will be used for all images.
            * If a list of strings, then a random mode will be picked
              from that list per image.
            * If ``imgaug.ALL``, then a random mode from all possible modes
              will be picked.
            * If ``StochasticParameter``, then the mode will be sampled from
              that parameter per image, i.e. it must return only the above
              mentioned strings.

    fit_output : bool, optional
        Whether to modify the affine transformation so that the whole output
        image is always contained in the image plane (``True``) or accept
        parts of the image being outside the image plane (``False``).
        This can be thought of as first applying the affine transformation
        and then applying a second transformation to "zoom in" on the new
        image so that it fits the image plane,
        This is useful to avoid corners of the image being outside of the image
        plane after applying rotations. It will however negate translation
        and scaling.
        Note also that activating this may lead to image sizes differing from
        the input image sizes. To avoid this, wrap ``Affine`` in
        :class:`~imgaug.augmenters.size.KeepSizeByResize`,
        e.g. ``KeepSizeByResize(Affine(...))``.

    backend : str, optional
        Framework to use as a backend. Valid values are ``auto``, ``skimage``
        (scikit-image's warp) and ``cv2`` (OpenCV's warp).
        If ``auto`` is used, the augmenter will automatically try
        to use ``cv2`` whenever possible (order must be in ``[0, 1, 3]``). It
        will silently fall back to skimage if order/dtype is not supported by
        cv2. cv2 is generally faster than skimage. It also supports RGB cvals,
        while skimage will resort to intensity cvals (i.e. 3x the same value
        as RGB). If ``cv2`` is chosen and order is ``2`` or ``4``, it will
        automatically fall back to order ``3``.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.Affine(scale=2.0)

    Zoom in on all images by a factor of ``2``.

    >>> aug = iaa.Affine(translate_px=16)

    Translate all images on the x- and y-axis by 16 pixels (towards the
    bottom right) and fill up any new pixels with zero (black values).

    >>> aug = iaa.Affine(translate_percent=0.1)

    Translate all images on the x- and y-axis by ``10`` percent of their
    width/height (towards the bottom right). The pixel values are computed
    per axis based on that axis' size. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.Affine(rotate=35)

    Rotate all images by ``35`` *degrees*. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.Affine(shear=15)

    Shear all images by ``15`` *degrees*. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.Affine(translate_px=(-16, 16))

    Translate all images on the x- and y-axis by a random value
    between ``-16`` and ``16`` pixels (to the bottom right) and fill up any new
    pixels with zero (black values). The translation value is sampled once
    per image and is the same for both axis.

    >>> aug = iaa.Affine(translate_px={"x": (-16, 16), "y": (-4, 4)})

    Translate all images on the x-axis by a random value
    between ``-16`` and ``16`` pixels (to the right) and on the y-axis by a
    random value between ``-4`` and ``4`` pixels to the bottom. The sampling
    happens independently per axis, so even if both intervals were identical,
    the sampled axis-wise values would likely be different.
    This also fills up any new pixels with zero (black values).

    >>> aug = iaa.Affine(scale=2.0, order=[0, 1])

    Same as in the above `scale` example, but uses (randomly) either
    nearest neighbour interpolation or linear interpolation. If `order` is
    not specified, ``order=1`` would be used by default.

    >>> aug = iaa.Affine(translate_px=16, cval=(0, 255))

    Same as in the `translate_px` example above, but newly created pixels
    are now filled with a random color (sampled once per image and the
    same for all newly created pixels within that image).

    >>> aug = iaa.Affine(translate_px=16, mode=["constant", "edge"])

    Similar to the previous example, but the newly created pixels are
    filled with black pixels in half of all images (mode ``constant`` with
    default `cval` being ``0``) and in the other half of all images using
    ``edge`` mode, which repeats the color of the spatially closest pixel
    of the corresponding image edge.

    >>> aug = iaa.Affine(shear={"y": (-45, 45)})

    Shear images only on the y-axis. Set `shear` to ``shear=(-45, 45)`` to
    shear randomly on both axes, using for each image the same sample for
    both the x- and y-axis. Use ``shear={"x": (-45, 45), "y": (-45, 45)}``
    to get independent samples per axis.

    c                 óŽ  •— t         t        | �  ||||¬«       |||||g}t        |D �cg c]  }|d u ‘Œ c}«      rdddœ}dddœ}d}dddœ}n|�|nd}|�|nd}|�|nd}|
d	v sJ d
|
›d�«       ‚|
| _        t        ||
«      | _        t        |«      | _        t        |«      | _
        | j                  |«      | _        | j                  ||«      | _        t        j                   |dd dd¬«      | _        | j%                  |«      \  | _        | _        |	| _        d| _        d| _        d| _        d| _        d| _        d| _        y c c}w )N©rã   rV   rå   Údeterministic)gÍÌÌÌÌÌì?gš™™™™™ñ?©rÓ   rÔ   )gš™™™™™¹¿gš™™™™™¹?)iñÿÿÿé   )iöÿÿÿé
   ç      ð?r#  )r$   rO   r%   z9Expected 'backend' to be "auto", "skimage" or "cv2", got r(   rø   Tr>   r   r   r   )Úsuperr/  rû   r1   r7   r:   r6   rD   r=   rM   rK   Ú_handle_scale_argrõ   Ú_handle_translate_argrö   r+   rC   rø   Ú_handle_shear_argrù   Ú_shear_param_typer  Ú_order_heatmapsÚ_order_segmentation_mapsÚ_mode_heatmapsÚ_mode_segmentation_mapsÚ_cval_heatmapsÚ_cval_segmentation_maps)rú   rõ   Útranslate_percentÚtranslate_pxrø   rù   r6   r=   rK   r  r7   rã   rV   rå   r2  r—   ÚpÚ	__class__s                    €r9   rû   zAffine.__init__�  sŠ  ø€ ô
 	Œf�dÑ$Ø˜DØ%°]ð 	%ô 	Dð Ð*¨L¸&À%ÐHˆÜ¡6Ó*¡6˜a��T’	 6Ñ*Ô+Ø$¨:Ñ6ˆEØ&1¸Ñ DÐØˆFØ#¨)Ñ4‰Eà"Ð.‘E°CˆEØ%Ð1‘V°sˆFØ"Ð.‘E°CˆEàÐ4Ñ4ñ 	$â ð#ó	$Ð4ð ˆŒÜ& u¨gÓ6ˆŒ
Ü$ TÓ*ˆŒ	Ü$ TÓ*ˆŒ	Ø×+Ñ+¨EÓ2ˆŒ
Ø×3Ñ3ØÐ+ó-ˆŒä×1Ñ1Ø�H¨$ÀØô!ˆŒð .2×-CÑ-CÀEÓ-JÑ*ˆŒ
�DÔ*Ø$ˆŒð  !ˆÔØ()ˆÔ%Ø(ˆÔØ'1ˆÔ$ØˆÔØ'(ˆÕ$ùòU +s   ©Ec                 ó$  — t        |t        «      rgd|v sd|v sJ d«       ‚|j                  dd«      }|j                  dd«      }t        j                  |dddd¬«      t        j                  |d	ddd¬«      fS t        j                  |d
ddd¬«      S )NrÓ   rÔ   úXExpected scale dictionary to contain at least key "x" or key "y". Found neither of them.r6  ú
scale['x']©ç-Cëâ6?NTr>   ú
scale['y']rõ   )r/   Údictr”   r+   rC   )Úclsrõ   rÓ   rÔ   s       r9   r8  zAffine._handle_scale_argÅ  s°   € ä�eœTÔ"Ø˜%‘< 3¨%¡<ð 5ð4ó5Ð/ð —	‘	˜#˜sÓ#ˆAØ—	‘	˜#˜sÓ#ˆAä×+Ñ+Ø�|°Ø%)¸$ô@ô ×+Ñ+Ø�|°Ø%)¸$ô@ð	ð ô ×*Ñ*Ø�7¨Ø!°$ô8ð 	8rE   c           	      ó‚  — |€|€d}|�	|�J d«       ‚|�•t        |t        «      rhd|v sd|v sJ d«       ‚|j                  dd«      }|j                  dd«      }t        j                  |dd dd¬«      t        j                  |d	d dd¬«      d
fS t        j                  |dd dd¬«      d d
fS t        |t        «      rjd|v sd|v sJ d«       ‚|j                  dd«      }|j                  dd«      }t        j
                  |dd ddd¬«      t        j
                  |dd ddd¬«      dfS t        j
                  |dd ddd¬«      d dfS )Nr   úZExpected either translate_percent or translate_px to be provided, but neither of them was.rÓ   rÔ   údExpected translate_percent dictionary to contain at least key "x" or key "y". Found neither of them.útranslate_percent['x']Tr>   útranslate_percent['y']rþ   rB  ú_Expected translate_px dictionary to contain at least key "x" or key "y". Found neither of them.útranslate_px['x']F©r?   r@   rA   Úallow_floatsútranslate_px['y']rý   rC  )r/   rL  r”   r+   rC   Úhandle_discrete_param)rM  rC  rB  rÓ   rÔ   s        r9   r9  zAffine._handle_translate_argÙ  sÝ  € ð Ð$¨Ð)=ØˆLà Ð(¨LÐ,@ð 	2ð1ó	2Ð@ð Ð(äÐ+¬TÔ2ØÐ/Ñ/°3Ð:KÑ3Kð LðKóLÐKð &×)Ñ)¨#¨qÓ1�Ø%×)Ñ)¨#¨qÓ1�ä×/Ñ/ØÐ3ÀØ)-¸dôDô ×/Ñ/ØÐ3ÀØ)-¸dôDð ðð ô ×+Ñ+Ø%Ð':Ø $°tØ#'ô)ð Øðð ô ˜,¬Ô-Ø˜lÑ*¨c°\Ñ.Að LðKóLÐAð !×$Ñ$ S¨!Ó,�Ø ×$Ñ$ S¨!Ó,�ä×-Ñ-ØÐ.¸DØ)-¸dØ%*ô,ô ×-Ñ-ØÐ.¸DØ)-¸dØ%*ô,ð ð
ð 
ô ×)Ñ)Ø  .¸dØ%)¸$Ø!&ô(ð Øðð rE   c                 ó^  — t        |t        «      rid|v sd|v sJ d«       ‚|j                  dd«      }|j                  dd«      }t        j                  |dd dd¬«      t        j                  |dd dd¬«      fd	fS d
}t        j                  |«      rd}t        j                  |dd dd¬«      |fS )NrÓ   rÔ   zXExpected shear dictionary to contain at least key "x" or key "y". Found neither of them.r   z
shear['x']Tr>   z
shear['y']rL  Úotherúsingle-numberrù   )r/   rL  r”   r+   rC   r)   Úis_single_number)rM  rù   rÓ   rÔ   Ú
param_types        r9   r:  zAffine._handle_shear_arg  sá   € ô �eœTÔ"Ø˜%‘< 3¨%¡<ð HðGóHÐ/ð —	‘	˜#˜qÓ!ˆAØ—	‘	˜#˜qÓ!ˆAä×+Ñ+Ø�|°Ø%)¸$ô@ô ×+Ñ+Ø�|°Ø%)¸$ô@ð	ð ðð ð !ˆJÜ×"Ñ" 5Ô)Ø,�
Ü×.Ñ.Ø�w¨DÀ4Ø#ôð ðð rE   c           	      ó@  — | j                  |j                  |«      }|j                  �!| j                  |j                  |«      |_        |j                  �D| j                  |j                  |d| j                  | j                  | j                  d«      |_        |j                  �D| j                  |j                  |d| j                  | j                  | j                  d«      |_	        dD �].  }t        ||«      }|€Œt        |«      D �]  \  }}	|j                  ||	j                   | j"                  «      \  }
}t%        |
«      sÆ|	j&                  sºd|	j                   dd vr©|dk(  rc|	j)                  «       }|j+                  «       }t-        j.                  ||
j0                  «      }|j3                  |«      }|	j5                  |«      }	nA|	j+                  «       }t-        j.                  ||
j0                  «      }|	j3                  |«      }	||	_        |	||<   �Œ �Œ1 |S )	NÚarr_0to1r   r_   r   ©Ú	keypointsÚbounding_boxesÚpolygonsÚline_stringsr   r   rb  )Ú_draw_samplesr¸   ÚimagesÚ_augment_images_by_samplesÚheatmapsÚ_augment_maps_by_samplesr@  r>  r<  Úsegmentation_mapsrA  r?  r=  ÚgetattrrÐ   r   rR   r  r-  ÚemptyÚto_keypoints_on_imageÚto_xy_arrayr   Úmatrix_transformr—   Úfill_from_xy_array_Úinvert_to_keypoints_on_image_)rú   Úbatchrå   ÚparentsÚhooksÚsamplesÚ	augm_nameÚ
augm_valuer¿   Úcbaoir`   rP   ÚkpsoirÑ   Ú
coords_augs                  r9   Ú_augment_batch_zAffine._augment_batch_4  sü  € Ø×$Ñ$ U§]¡]°LÓAˆà�<‰<Ð#Ø×:Ñ:¸5¿<¹<Ø;BóDˆEŒLð �>‰>Ð%Ø!×:Ñ:Ø—‘ ¨°T×5HÑ5HØ×#Ñ# T×%9Ñ%9¸9óFˆEŒNð ×"Ñ"Ð.Ø&*×&CÑ&CØ×'Ñ'¨°%Ø×,Ñ,¨d×.JÑ.JØ×-Ñ-¨wó'8ˆEÔ#ô
*ˆIä  ¨	Ó2ˆJØÑ%Ü )¨*× 5‘H�A�uØ+2×+@Ñ+@Ø˜5Ÿ;™;¨¯©ó,9Ñ(�F˜Lô 0°Ô7Ø$)§K¢KØ$%¨¯©°Q°qÐ)9Ñ$9à$Ð(8Ò8ð %*×$?Ñ$?Ó$A˜EØ%*×%6Ñ%6Ó%8˜FÜ)+×)<Ñ)<¸VØ=C¿]¹]ó*L˜Jà$)×$=Ñ$=¸jÓ$I˜EØ$)×$GÑ$GØ %ó%'™Eð &+×%6Ñ%6Ó%8˜FÜ)+×)<Ñ)<¸VØ=C¿]¹]ó*L˜Jà$)×$=Ñ$=¸jÓ$I˜Eà".�E”KØ$)�J˜q“Mò5 !6ð	*ð@ ˆrE   c           
      óÈ  — t        |«      }t        j                  |«      }|sd n|j                  }g }|rd g|z  }	t	        j
                  |«      D ]Ä  }
||
   }|€|j                  n||
   }|j                  |
|j                  || j                  «      \  }}|j                  |
   }|j                  |
   }|j                  |
   }t        |«      s.t        ||||||| j                  ¬«      }|j                  |«       n|j                  |«       |sŒÀ|	|
<   ŒÆ |r>t        |D �ch c]  }|j                  ’Œ c}«      }|dk(  rt!        j"                  ||«      }|r|	f}|S c c}w )N)r6   rK   r=   rP   r7   r
   )rQ   r)   Úis_np_arrayrU   rš   r›   rR   r  r  r=   rK   r6   r-  ri   r7   Úappendr‚   r¢   )rú   rf  ru  Úimage_shapesÚreturn_matricesÚ	nb_imagesÚinput_was_arrayr…   r¾   Úmatricesr¿   ÚimagerÒ   r`   rP   r=   rK   r6   rh   Ú	nb_shapess                       r9   rg  z!Affine._augment_images_by_samplesh  s`  € ô ˜“Kˆ	ÜŸ.™.¨Ó0ˆÙ"1‘d°v·|±|ˆØˆÙØ�v 	Ñ)ˆHÜ—‘˜9Ö%ˆAØ˜1‘IˆEà*6Ð*>˜5Ÿ;š;Ø ,¨Q¡ð à#*×#4Ñ#4°Q¸¿¹Ø5@Ø59·_±_ó$FÑ ˆF�Lð —<‘< ‘?ˆDØ—<‘< ‘?ˆDØ—M‘M !Ñ$ˆEä& vÔ.Ü/Ø˜6Ø d°Ø!-°t·|±|ô E�ð
 —‘˜lÕ+à—‘˜eÔ$âØ$�˜’ð1 &ñ8 Ü±fÓ=±f¨U˜UŸ[›[°fÑ=Ó>ˆIØ˜AŠ~ÜŸ™ &¨+Ó6�áØ˜hÐ'ˆFàˆùò >s   Ä"Ec                 ó¼  — t        |«      }|j                  «       }|�t        j                  |df||¬«      |_        |�|g|z  |_        |�|g|z  |_        |D �	cg c]  }	t        |	|«      ‘Œ }
}	|D �	cg c]  }	|	j                  ‘Œ }}	| j                  |
||d¬«      \  }}t        ||||j                  «      }|D ]”  \  }}}}d|j                  v rŒ|dk\  r3t        |t        j                  «      rt        j                  |dd|¬	«      }t        |||«       | j                   rt#        ||j                  «      \  }}n|j                  }||_        Œ– |S c c}	w c c}	w )
Nr
   ©rU   T)r  r€  r   r   r#  r6  ©Úout)rQ   rÏ   r‚   Úfullr=   rK   r6   rk  rR   rg  Úzipr/   r)   ÚHeatmapsOnImageÚclipÚsetattrr  r±   )rú   Úaugmentablesru  Úarr_attr_namer=   rK   r6   Ú
cval_dtyper�  ÚaugmentableÚarrsr  Úarrs_augrƒ  ÚgenÚaugmentable_iÚarr_augr`   Úorder_iÚ_Úoutput_shape_is                        r9   ri  zAffine._augment_maps_by_samples˜  s~  € ä˜Ó%ˆ	à—,‘,“.ˆØÐÜŸ7™7 I¨q >°4¸zÔJˆGŒLØÐØ ˜6 IÑ-ˆGŒLØÐØ"˜G iÑ/ˆGŒMñ $0ó1Ù#/�Kô ˜ ]Õ3Ø#/ð 	ð 1á=IÓJ¹\¨k˜×)Ó)¸\ˆÐJØ!×<Ñ<Ø�'¨Àdð =ó LÑˆ�(ô �, ¨(°G·M±MÓBˆÛ7:Ñ3ˆM˜7 F¨Gð �M×'Ñ'Ñ'Øð ˜!Š|¤
¨=¼"×:LÑ:LÔ MÜŸ'™' '¨3°¸ÔA�ä�M =°'Ô:Ø�ŠÜ$EØ˜M×/Ñ/ó%1Ñ!�‘>ð "/×!4Ñ!4�Ø"0ˆMÕð+ 8;ð, Ðùò;1ùâJs   ÁEÁ4Ec           
      ó  — |j                  d«      }t        | j                  t        «      rI| j                  d   j	                  |f|d   ¬«      | j                  d   j	                  |f|d   ¬«      f}n%| j                  j	                  |f|d   ¬«      }||f}| j
                  d   �I| j
                  d   j	                  |f|d   ¬«      | j
                  d   j	                  |f|d   ¬«      f}n(| j
                  d   j	                  |f|d   ¬«      }||f}| j                  j	                  |f|d	   ¬«      }| j                  d
k(  rI| j                  d   j	                  |f|d   ¬«      | j                  d   j	                  |f|d   ¬«      f}nm| j                  dk(  r9| j                  j	                  |f|d   ¬«      }|t        j                  |«      f}n%| j                  j	                  |f|d   ¬«      }||f}| j                  j	                  |df|d   ¬«      }| j                  j	                  |f|d   ¬«      }	| j                  j	                  |f|d   ¬«      }
t        ||| j
                  d   ||||	|
¬«      S )Né   r   ©rå   r
   r   r   r   r'   rÜ   rL  rÝ   rÚ   r[  é	   r5  é   rô   )Ú	duplicater/   rõ   r]   Údraw_samplesrö   rø   r;  rù   r‚   rµ   r=   rK   r6   rñ   )rú   Ú
nb_samplesrå   ÚrngsÚscale_samplesÚtranslate_samplesÚrotate_samplesÚshear_samplesÚcval_samplesÚmode_samplesÚorder_sampless              r9   re  zAffine._draw_samplesÃ  sÍ  € Ø×%Ñ% bÓ)ˆä�d—j‘j¤%Ô(à—
‘
˜1‘×*Ñ*¨J¨=ÀtÈAÁwÐ*ÓOØ—
‘
˜1‘×*Ñ*¨J¨=ÀtÈAÁwÐ*ÓOð‰Mð
 !ŸJ™J×3Ñ3°Z°MØAEÀaÁð 4ó JˆMà*¨MÐ:ˆMà�>‰>˜!ÑÐ(à—‘˜qÑ!×.Ñ.°
¨}Ø<@À¹Gð /ó Eà—‘˜qÑ!×.Ñ.°
¨}Ø<@À¹Gð /ó Eð!Ñð !%§¡¨qÑ 1× >Ñ >Ø�¨D°©Gð !?ó !5Ðà!2Ð4EÐ FÐàŸ™×1Ñ1°:°-Ø?CÀA¹wð 2ó Hˆà×!Ñ! VÒ+à—
‘
˜1‘×*Ñ*¨J¨=ÀtÈAÁwÐ*ÓOØ—
‘
˜1‘×*Ñ*¨J¨=ÀtÈAÁwÐ*ÓOð‰Mð ×#Ñ# Ò6à ŸJ™J×3Ñ3°Z°MØAEÀaÁð 4ó JˆMà*¬B¯M©M¸-Ó,HÐI‰Mà ŸJ™J×3Ñ3°Z°MØAEÀaÁð 4ó JˆMà*¨MÐ:ˆMà—y‘y×-Ñ-¨z¸1¨oØ;?À¹7ð .ó Dˆà—y‘y×-Ñ-¨z¨mØ;?À¹8ð .ó EˆàŸ
™
×/Ñ/°°Ø=AÀ"¹Xð 0ó Gˆô %ØØ'ØŸ>™>¨!Ñ,Ø!ØØØØô!ð 	!rE   c           	      óÌ   — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  g	S ©z=See :func:`~imgaug.augmenters.meta.Augmenter.get_parameters`.)	rõ   rö   rø   rù   r6   r=   rK   r7   r  r"  s    r9   Úget_parameterszAffine.get_parametersþ  sH   € ð �J‰J˜Ÿ™¨¯©°T·Z±ZÀÇÁØ�I‰I�t—y‘y $§,¡,°·±ðAð 	ArE   )NNNNNr
   r   r   Fr$   NNÚ
deprecatedr®  ©NF)r$  r%  r&  Ú__doc__rû   Úclassmethodr8  r9  r:  r{  rg  ri  re  r­  Ú__classcell__©rE  s   @r9   r/  r/  ¾  s†   ø„ ñNð` IMØ@JØ+1Ø!%Ø:Fõ	4)ðl ñ8ó ð8ð& ñ<ó ð<ð~ ñó ðò42ðj 15Ø38ó-ò`)òV9!övArE   r/  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )ÚScaleXaÜ  Apply affine scaling on the x-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``scale`` in :class:`Affine`, except that this scale
        value only affects the x-axis. No dictionary input is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.ScaleX((0.5, 1.5))

    Create an augmenter that scales images along the width to sizes between
    ``50%`` and ``150%``. This does not change the image shape (i.e. height
    and width), only the pixels within the image are remapped and potentially
    new ones are filled in.

    c                 óD   •— t         t        | �  d|i||||||||	|
¬«
       y )NrÓ   ©
rõ   r6   r=   rK   r  r7   rã   rV   rå   r2  )r7  rµ  rû   ©rú   rõ   r6   r=   rK   r  r7   rã   rV   rå   r2  rE  s              €r9   rû   zScaleX.__init__C  ó:   ø€ ô 	Œf�dÑ$Ø˜�,ØØØØ!ØØ˜DØ%°]ð 	%õ 	DrE   ©
)r}   g      ø?r
   r   r   Fr$   NNr®  r®  ©r$  r%  r&  r°  rû   r²  r³  s   @r9   rµ  rµ    ó%   ø„ ñ:ðz @JØ+1Ø!%Ø:F÷Dñ DrE   rµ  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )ÚScaleYaÝ  Apply affine scaling on the y-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``scale`` in :class:`Affine`, except that this scale
        value only affects the y-axis. No dictionary input is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.ScaleY((0.5, 1.5))

    Create an augmenter that scales images along the height to sizes between
    ``50%`` and ``150%``. This does not change the image shape (i.e. height
    and width), only the pixels within the image are remapped and potentially
    new ones are filled in.

    c                 óD   •— t         t        | �  d|i||||||||	|
¬«
       y )NrÔ   r·  )r7  r¾  rû   r¸  s              €r9   rû   zScaleY.__init__�  r¹  rE   rº  r»  r³  s   @r9   r¾  r¾  R  r¼  rE   r¾  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )Ú
TranslateXa€
  Apply affine translation on the x-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    percent : None or number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``translate_percent`` in :class:`Affine`, except that
        this translation value only affects the x-axis. No dictionary input
        is allowed.

    px : None or int or tuple of int or list of int or imgaug.parameters.StochasticParameter or dict {"x": int/tuple/list/StochasticParameter, "y": int/tuple/list/StochasticParameter}, optional
        Analogous to ``translate_px`` in :class:`Affine`, except that
        this translation value only affects the x-axis. No dictionary input
        is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.TranslateX(px=(-20, 20))

    Create an augmenter that translates images along the x-axis by
    ``-20`` to ``20`` pixels.

    >>> aug = iaa.TranslateX(percent=(-0.1, 0.1))

    Create an augmenter that translates images along the x-axis by
    ``-10%`` to ``10%`` (relative to the x-axis size).

    c                 óf   •— |€|€d}t         t        | �  |�d|ind |�d|ind |||||||	|
|¬«       y )N©g      Ð¿g      Ð?rÓ   ©rB  rC  r6   r=   rK   r  r7   rã   rV   rå   r2  )r7  rÁ  rû   ©rú   rþ   rý   r6   r=   rK   r  r7   rã   rV   rå   r2  rE  s               €r9   rû   zTranslateX.__init__ç  ó\   ø€ ð ˆ?˜r˜zØ#ˆGäŒj˜$Ñ(Ø18Ð1D  W™~È$Ø') ~˜3 ™)¸4ØØØØ!ØØ˜DØ%°]ð 	)õ 		DrE   ©NNr
   r   r   Fr$   NNr®  r®  r»  r³  s   @r9   rÁ  rÁ     ó$   ø„ ñCðL 56ØDJØ!%Ø:F÷Dñ DrE   rÁ  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )Ú
TranslateYa€
  Apply affine translation on the y-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    percent : None or number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``translate_percent`` in :class:`Affine`, except that
        this translation value only affects the y-axis. No dictionary input
        is allowed.

    px : None or int or tuple of int or list of int or imgaug.parameters.StochasticParameter or dict {"x": int/tuple/list/StochasticParameter, "y": int/tuple/list/StochasticParameter}, optional
        Analogous to ``translate_px`` in :class:`Affine`, except that
        this translation value only affects the y-axis. No dictionary input
        is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.TranslateY(px=(-20, 20))

    Create an augmenter that translates images along the y-axis by
    ``-20`` to ``20`` pixels.

    >>> aug = iaa.TranslateY(percent=(-0.1, 0.1))

    Create an augmenter that translates images along the y-axis by
    ``-10%`` to ``10%`` (relative to the y-axis size).

    c                 óf   •— |€|€d}t         t        | �  |�d|ind |�d|ind |||||||	|
|¬«       y )NrÃ  rÔ   rÄ  )r7  rÊ  rû   rÅ  s               €r9   rû   zTranslateY.__init__B  rÆ  rE   rÇ  r»  r³  s   @r9   rÊ  rÊ  û  rÈ  rE   rÊ  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )ÚRotateaÿ  Apply affine rotation on the y-axis to input data.

    This is a wrapper around :class:`Affine`.
    It is the same as ``Affine(rotate=<value>)``.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    rotate : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.Rotate((-45, 45))

    Create an augmenter that rotates images by a random value between ``-45``
    and ``45`` degress.

    c                 ó@   •— t         t        | �  |||||||||	|
¬«
       y )N)
rø   r6   r=   rK   r  r7   rã   rV   rå   r2  )r7  rÍ  rû   )rú   rø   r6   r=   rK   r  r7   rã   rV   rå   r2  rE  s              €r9   rû   zRotate.__init__‘  s6   ø€ ô 	Œf�dÑ$ØØØØØ!ØØ˜DØ%°]ð 	%õ 	DrE   ©
)iâÿÿÿé   r
   r   r   Fr$   NNr®  r®  r»  r³  s   @r9   rÍ  rÍ  U  s%   ø„ ñ8ðv @JØ+1Ø!%Ø:F÷Dñ DrE   rÍ  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )ÚShearXaM  Apply affine shear on the x-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    shear : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``shear`` in :class:`Affine`, except that this shear
        value only affects the x-axis. No dictionary input is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.ShearX((-20, 20))

    Create an augmenter that shears images along the x-axis by random amounts
    between ``-20`` and ``20`` degrees.

    c                 óD   •— t         t        | �  d|i||||||||	|
¬«
       y )NrÓ   ©
rù   r6   r=   rK   r  r7   rã   rV   rå   r2  )r7  rÒ  rû   ©rú   rù   r6   r=   rK   r  r7   rã   rV   rå   r2  rE  s              €r9   rû   zShearX.__init__Ü  r¹  rE   rÏ  r»  r³  s   @r9   rÒ  rÒ     ó$   ø„ ñ8ðv ?IØ+1Ø!%Ø:F÷Dñ DrE   rÒ  c                   ó,   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zˆ xZS )ÚShearYaM  Apply affine shear on the y-axis to input data.

    This is a wrapper around :class:`Affine`.

    Added in 0.4.0.

    **Supported dtypes**:

    See :class:`~imgaug.augmenters.geometric.Affine`.

    Parameters
    ----------
    shear : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Analogous to ``shear`` in :class:`Affine`, except that this shear
        value only affects the y-axis. No dictionary input is allowed.

    order : int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :class:`Affine`.

    fit_output : bool, optional
        See :class:`Affine`.

    backend : str, optional
        See :class:`Affine`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.ShearY((-20, 20))

    Create an augmenter that shears images along the y-axis by random amounts
    between ``-20`` and ``20`` degrees.

    c                 óD   •— t         t        | �  d|i||||||||	|
¬«
       y )NrÔ   rÔ  )r7  rØ  rû   rÕ  s              €r9   rû   zShearY.__init__'  r¹  rE   rÏ  r»  r³  s   @r9   rØ  rØ  ë  rÖ  rE   rØ  c                   óª   ‡ — e Zd ZdZdddddej
                  dej                  ddddfˆ fd„	Zd„ Ze	d	„ «       Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zˆ xZS )Ú	AffineCv2az:  
    **Deprecated.** Augmenter to apply affine transformations to images using
    cv2 (i.e. opencv) backend.

    .. warning::

        This augmenter is deprecated since 0.4.0.
        Use ``Affine(..., backend='cv2')`` instead.

    Affine transformations
    involve:

        - Translation ("move" image on the x-/y-axis)
        - Rotation
        - Scaling ("zoom" in/out)
        - Shear (move one side of the image, turning a square into a trapezoid)

    All such transformations can create "new" pixels in the image without a
    defined content, e.g. if the image is translated to the left, pixels
    are created on the right.
    A method has to be defined to deal with these pixel values. The
    parameters `cval` and `mode` of this class deal with this.

    Some transformations involve interpolations between several pixels
    of the input image to generate output pixel values. The parameter `order`
    deals with the method of interpolation used for this.

    Deprecated since 0.4.0.

    **Supported dtypes**:

        * ``uint8``: yes; fully tested
        * ``uint16``: ?
        * ``uint32``: ?
        * ``uint64``: ?
        * ``int8``: ?
        * ``int16``: ?
        * ``int32``: ?
        * ``int64``: ?
        * ``float16``: ?
        * ``float32``: ?
        * ``float64``: ?
        * ``float128``: ?
        * ``bool``: ?

    Parameters
    ----------
    scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter or dict {"x": number/tuple/list/StochasticParameter, "y": number/tuple/list/StochasticParameter}, optional
        Scaling factor to use, where ``1.0`` denotes "no change" and
        ``0.5`` is zoomed out to ``50`` percent of the original size.

            * If a single number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]``. That value will be
              used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    translate_percent : number or tuple of number or list of number or imgaug.parameters.StochasticParameter or dict {"x": number/tuple/list/StochasticParameter, "y": number/tuple/list/StochasticParameter}, optional
        Translation as a fraction of the image height/width (x-translation,
        y-translation), where ``0`` denotes "no change" and ``0.5`` denotes
        "half of the axis size".

            * If ``None`` then equivalent to ``0.0`` unless `translate_px` has
              a value other than ``None``.
            * If a single number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]``. That sampled fraction
              value will be used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    translate_px : int or tuple of int or list of int or imgaug.parameters.StochasticParameter or dict {"x": int/tuple/list/StochasticParameter, "y": int/tuple/list/StochasticParameter}, optional
        Translation in pixels.

            * If ``None`` then equivalent to ``0`` unless `translate_percent`
              has a value other than ``None``.
            * If a single int, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the discrete interval ``[a..b]``. That number
              will be used identically for both x- and y-axis.
            * If a list, then a random value will be sampled from that list
              per image (again, used for both x- and y-axis).
            * If a ``StochasticParameter``, then from that parameter a value
              will be sampled per image (again, used for both x- and y-axis).
            * If a dictionary, then it is expected to have the keys ``x``
              and/or ``y``. Each of these keys can have the same values as
              described above. Using a dictionary allows to set different
              values for the two axis and sampling will then happen
              *independently* per axis, resulting in samples that differ
              between the axes.

    rotate : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Rotation in degrees (**NOT** radians), i.e. expected value range is
        around ``[-360, 360]``. Rotation happens around the *center* of the
        image, not the top left corner as in some other frameworks.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]`` and used as the rotation
              value.
            * If a list, then a random value will be sampled from that list
              per image.
            * If a ``StochasticParameter``, then this parameter will be used to
              sample the rotation value per image.

    shear : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Shear in degrees (**NOT** radians), i.e. expected value range is
        around ``[-360, 360]``.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be uniformly sampled
              per image from the interval ``[a, b]`` and be used as the
              rotation value.
            * If a list, then a random value will be sampled from that list
              per image.
            * If a ``StochasticParameter``, then this parameter will be used
              to sample the shear value per image.

    order : int or list of int or str or list of str or imaug.ALL or imgaug.parameters.StochasticParameter, optional
        Interpolation order to use. Allowed are:

            * ``cv2.INTER_NEAREST`` (nearest-neighbor interpolation)
            * ``cv2.INTER_LINEAR`` (bilinear interpolation, used by default)
            * ``cv2.INTER_CUBIC`` (bicubic interpolation over ``4x4`` pixel
                neighborhood)
            * ``cv2.INTER_LANCZOS4``
            * string ``nearest`` (same as ``cv2.INTER_NEAREST``)
            * string ``linear`` (same as ``cv2.INTER_LINEAR``)
            * string ``cubic`` (same as ``cv2.INTER_CUBIC``)
            * string ``lanczos4`` (same as ``cv2.INTER_LANCZOS``)

        ``INTER_NEAREST`` (nearest neighbour interpolation) and
        ``INTER_NEAREST`` (linear interpolation) are the fastest.

            * If a single ``int``, then that order will be used for all images.
            * If a string, then it must be one of: ``nearest``, ``linear``,
              ``cubic``, ``lanczos4``.
            * If an iterable of ``int``/``str``, then for each image a random
              value will be sampled from that iterable (i.e. list of allowed
              order values).
            * If ``imgaug.ALL``, then equivalant to list ``[cv2.INTER_NEAREST,
              cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4]``.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the order value to use.

    cval : number or tuple of number or list of number or imaug.ALL or imgaug.parameters.StochasticParameter, optional
        The constant value to use when filling in newly created pixels.
        (E.g. translating by 1px to the right will create a new 1px-wide
        column of pixels on the left of the image).  The value is only used
        when `mode=constant`. The expected value range is ``[0, 255]`` for
        ``uint8`` images. It may be a float value.

            * If this is a single number, then that value will be used
              (e.g. 0 results in black pixels).
            * If a tuple ``(a, b)``, then three values (for three image
              channels) will be uniformly sampled per image from the
              interval ``[a, b]``.
            * If a list, then a random value will be sampled from that list
              per image.
            * If ``imgaug.ALL`` then equivalent to tuple ``(0, 255)`.
            * If a ``StochasticParameter``, a new value will be sampled from
              the parameter per image.

    mode : int or str or list of str or list of int or imgaug.ALL or imgaug.parameters.StochasticParameter,
           optional
        Method to use when filling in newly created pixels.
        Same meaning as in OpenCV's border mode. Let ``abcdefgh`` be an image's
        content and ``|`` be an image boundary after which new pixels are
        filled in, then the valid modes and their behaviour are the following:

            * ``cv2.BORDER_REPLICATE``: ``aaaaaa|abcdefgh|hhhhhhh``
            * ``cv2.BORDER_REFLECT``: ``fedcba|abcdefgh|hgfedcb``
            * ``cv2.BORDER_REFLECT_101``: ``gfedcb|abcdefgh|gfedcba``
            * ``cv2.BORDER_WRAP``: ``cdefgh|abcdefgh|abcdefg``
            * ``cv2.BORDER_CONSTANT``: ``iiiiii|abcdefgh|iiiiiii``,
               where ``i`` is the defined cval.
            * ``replicate``: Same as ``cv2.BORDER_REPLICATE``.
            * ``reflect``: Same as ``cv2.BORDER_REFLECT``.
            * ``reflect_101``: Same as ``cv2.BORDER_REFLECT_101``.
            * ``wrap``: Same as ``cv2.BORDER_WRAP``.
            * ``constant``: Same as ``cv2.BORDER_CONSTANT``.

        The datatype of the parameter may be:

            * If a single ``int``, then it must be one of the ``cv2.BORDER_*``
              constants.
            * If a single string, then it must be one of: ``replicate``,
              ``reflect``, ``reflect_101``, ``wrap``, ``constant``.
            * If a list of ``int``/``str``, then per image a random mode will
              be picked from that list.
            * If ``imgaug.ALL``, then a random mode from all possible modes
              will be picked.
            * If ``StochasticParameter``, then the mode will be sampled from
              that parameter per image, i.e. it must return only the above
              mentioned strings.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.AffineCv2(scale=2.0)

    Zoom in on all images by a factor of ``2``.

    >>> aug = iaa.AffineCv2(translate_px=16)

    Translate all images on the x- and y-axis by 16 pixels (towards the
    bottom right) and fill up any new pixels with zero (black values).

    >>> aug = iaa.AffineCv2(translate_percent=0.1)

    Translate all images on the x- and y-axis by ``10`` percent of their
    width/height (towards the bottom right). The pixel values are computed
    per axis based on that axis' size. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.AffineCv2(rotate=35)

    Rotate all images by ``35`` *degrees*. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.AffineCv2(shear=15)

    Shear all images by ``15`` *degrees*. Fill up any new pixels with zero
    (black values).

    >>> aug = iaa.AffineCv2(translate_px=(-16, 16))

    Translate all images on the x- and y-axis by a random value
    between ``-16`` and ``16`` pixels (to the bottom right) and fill up any new
    pixels with zero (black values). The translation value is sampled once
    per image and is the same for both axis.

    >>> aug = iaa.AffineCv2(translate_px={"x": (-16, 16), "y": (-4, 4)})

    Translate all images on the x-axis by a random value
    between ``-16`` and ``16`` pixels (to the right) and on the y-axis by a
    random value between ``-4`` and ``4`` pixels to the bottom. The sampling
    happens independently per axis, so even if both intervals were identical,
    the sampled axis-wise values would likely be different.
    This also fills up any new pixels with zero (black values).

    >>> aug = iaa.AffineCv2(scale=2.0, order=[0, 1])

    Same as in the above `scale` example, but uses (randomly) either
    nearest neighbour interpolation or linear interpolation. If `order` is
    not specified, ``order=1`` would be used by default.

    >>> aug = iaa.AffineCv2(translate_px=16, cval=(0, 255))

    Same as in the `translate_px` example above, but newly created pixels
    are now filled with a random color (sampled once per image and the
    same for all newly created pixels within that image).

    >>> aug = iaa.AffineCv2(translate_px=16, mode=["constant", "replicate"])

    Similar to the previous example, but the newly created pixels are
    filled with black pixels in half of all images (mode ``constant`` with
    default `cval` being ``0``) and in the other half of all images using
    ``replicate`` mode, which repeats the color of the spatially closest pixel
    of the corresponding image edge.

    r6  Nr#  r   r®  c           
      ó  •— t         t        | �  |	|
||¬«       t        j                  dd¬«       t
        j                  t
        j                  t
        j                  t
        j                  g}g d¢}|t        j                  k(  rt        j                  |«      | _        �n¥t        j                  |«      r5||v sJ dt        |«      |fz  «       ‚t        j                   |«      | _        �n[t        j"                  |«      r7||v sJ dt        |«      ›d|›d	�«       ‚t        j                   |«      | _        �nt%        |t&        «      rÅt)        |D �cg c].  }t        j                  |«      xs t        j"                  |«      ‘Œ0 c}«      }|s+J d
t        |D �cg c]  }t+        |«      ‘Œ c}«      ›d	�«       ‚t)        |D �cg c]	  }|||z   v ‘Œ c}«      }|sJ d||z   ›dt        |«      ›d	�«       ‚t        j                  |«      | _        n:t%        |t        j,                  «      r|| _        nt/        dt+        |«      ›d	�«      ‚|t        j                  k(  rt        j0                  dd«      | _        n t        j4                  |ddddd¬«      | _        t
        j6                  t
        j8                  t
        j:                  t
        j<                  t
        j>                  g}g d¢}|t        j                  k(  rt        j                  |«      | _         �n®t        j                  |«      r5||v sJ dt        |«      |fz  «       ‚t        j                   |«      | _         �ndt        j"                  |«      r7||v sJ dt        |«      ›d|›d	�«       ‚t        j                   |«      | _         �nt%        |t&        «      rÎt)        |D �cg c].  }t        j                  |«      xs t        j"                  |«      ‘Œ0 c}«      }|s+J dt        |D �cg c]  }t+        |«      ‘Œ c}«      ›d	�«       ‚t)        |D �cg c]	  }|||z   v ‘Œ c}«      }|s#J dt        ||z   «      ›dt        |«      ›d	�«       ‚t        j                  |«      | _         n:t%        |t        j,                  «      r|| _         nt/        dt+        |«      ›d	�«      ‚t%        |tB        «      rmd|v sd|v sJ d«       ‚|jE                  dd«      }|jE                  dd«      }t        jF                  |dddd¬«      t        jF                  |d ddd¬«      f| _$        nt        jF                  |d!ddd¬«      | _$        |€|€d}|�	|�J d"«       ‚|��t%        |tB        «      rmd|v sd|v sJ d#«       ‚|jE                  dd«      }|jE                  dd«      }t        jF                  |d$d dd¬«      t        jF                  |d%d dd¬«      f| _%        n¿t        jF                  |d&d dd¬«      | _%        nŸt%        |tB        «      rod|v sd|v sJ d'«       ‚|jE                  dd«      }|jE                  dd«      }t        j4                  |d(d ddd)¬«      t        j4                  |d*d ddd)¬«      f| _%        n t        j4                  |d+d ddd)¬«      | _%        t        jF                  |d,d dd¬«      | _&        t        jF                  |d-d dd¬«      | _'        y c c}w c c}w c c}w c c}w c c}w c c}w ).Nr1  z\AffineCv2 is deprecated. Use imgaug.augmenters.geometric.Affine(..., backend='cv2') instead.r   )Ú
stacklevel©ÚnearestÚlinearÚcubicÚlanczos4z3Expected order's integer value to be in %s, got %d.zExpected order to be in ú, got r(   z@Expected order list to only contain integers/strings, got types z#Expected all order values to be in z^Expected order to be imgaug.ALL, int, string, a list ofint/string or StochasticParameter, got r   r<   r=   )r   r<   TrU  ©Ú	replicater!   Úreflect_101r"   r   ú"Expected mode to be in %s, got %d.úExpected mode to be in ú?Expected mode list to only contain integers/strings, got types ú"Expected all mode values to be in údExpected mode to be imgaug.ALL, an int, a string, a list of int/strings or StochasticParameter, got rÓ   rÔ   rG  r6  rH  rI  r>   rK  rõ   rO  rP  rQ  rR  rB  rS  rT  FrW  rC  rø   rù   )(r7  rÛ  rû   r)   Úwarn_deprecatedr%   ÚINTER_NEARESTÚINTER_LINEARÚINTER_CUBICÚINTER_LANCZOS4r*   r+   r,   r6   r-   r2   r.   rI   r/   r0   r1   r3   r4   r5   ÚDiscreteUniformr=   rX  ÚBORDER_REPLICATEÚBORDER_REFLECTÚBORDER_REFLECT_101ÚBORDER_WRAPÚBORDER_CONSTANTrK   rL  r”   rC   rõ   rö   rø   rù   )rú   rõ   rB  rC  rø   rù   r6   r=   rK   rã   rV   rå   r2  Úavailable_ordersÚavailable_orders_strr8   Úvalid_typesÚvalid_ordersÚavailable_modesÚavailable_modes_strÚall_valid_typesÚall_valid_modesrÓ   rÔ   rE  s                           €r9   rû   zAffineCv2.__init__`	  sN  ø€ ô
 	Œi˜Ñ'Ø˜DØ%°]ð 	(ô 	Dô 	×Ñðà#$õ	&ô
  ×-Ñ-¬s×/?Ñ/?ÜŸO™O¬S×-?Ñ-?ðAÐâIÐà”B—F‘FŠ?ÜŸ™Ð$4Ó5ˆDŽJÜ×!Ñ! %Ô(ØÐ,Ñ,ð 3ØEÜÐ(Ó)¨5ðI2ñ 2ó3Ð,ô ×*Ñ*¨5Ó1ˆDŽJÜ�\‰\˜%Ô ØÐ0Ñ0ñ 7äÐ,Õ-ªuð6ó7Ð0ô ×*Ñ*¨5Ó1ˆDŽJÜ˜œtÔ$Üá!ó#Ù!�Sô ×%Ñ% cÓ*Ò?¬b¯l©l¸3Ó.?Ñ?Ø!ñ#ó$ˆKñ ñ Dä"¹Ó#?¹°#¤D¨¥I¸Ñ#?Õ@ðCóD�;ô á!ó#Ù!�Sð Ð(Ð+?Ñ?Ò?Ø!ñ#ó$ˆLñ  ñ Kà$Ð';Ó;¼SÀ½ZðJóK�<ô Ÿ™ EÓ*ˆD�JÜ˜œs×6Ñ6Ô7ØˆD�Jåä@DÀUÅðNóOð Oð ”2—6‘6Š>Ü×+Ñ+¨A¨sÓ3ˆD�Iä×1Ñ1Ø�f¨(ÀTØ#°$ô8ˆDŒIô ×/Ñ/´×1CÑ1CÜ×1Ñ1´3·?±?Ü×.Ñ.ð0ˆò3Ðà”2—6‘6Š>ÜŸ
™
 ?Ó3ˆDŽIÜ×!Ñ! $Ô'Ø˜?Ñ*ð 1Ø4Ü˜Ó(¨$ð80ñ 0ó1Ð*ô ×)Ñ)¨$Ó/ˆDŽIÜ�\‰\˜$ÔØÐ.Ñ.ñ 5äÐ+Õ,ªdð4ó5Ð.ô ×)Ñ)¨$Ó/ˆDŽIÜ˜œdÔ#Ü!ÙJNó#PÙJNÀ3”×$Ñ$ SÓ)Ò>¬R¯\©\¸#Ó->Ñ>È$ñ#Pó QˆOá"ñ Gä#&¹TÓ'B¹T°c¬¨S­	¸TÑ'BÕ#CðFóG�?ô "ÙHLó#NÙHLÀ��Ð)<Ñ<Ò<Èñ#Nó OˆOá"ñ Lä˜Ð*=Ñ=Õ>ÄÀDÅ	ðKóL�?ô Ÿ
™
 4Ó(ˆD�IÜ˜œc×5Ñ5Ô6ØˆD�IåäAEÀdÅðNóOð Oô
 �eœTÔ"Ø˜%‘< 3¨%¡<ð HðGóHÐ/ð —	‘	˜#˜sÓ#ˆAØ—	‘	˜#˜sÓ#ˆAä×+Ñ+Ø�|°Ø%)¸$ô@ô ×+Ñ+Ø�|°Ø%)¸$ô@ð	ˆD�Jô ×4Ñ4Ø�w¨NØ!%°dô<ˆDŒJð
 Ð$¨Ð)=ØˆLà Ð(¨LÐ,@ð 	2ð1ó	2Ð@ð Ð(äÐ+¬TÔ2ØÐ/Ñ/°3Ð:KÑ3Kð LðKóLÐKð &×)Ñ)¨#¨qÓ1�Ø%×)Ñ)¨#¨qÓ1�ä×/Ñ/ØÐ3ÀØ)-¸dôDô ×/Ñ/ØÐ3ÀØ)-¸dôDð	"�•ô "%×!<Ñ!<Ø%Ð':ÈØ%)¸$ô"@�•ô
 ˜,¬Ô-Ø˜lÑ*¨c°\Ñ.Að LðKóLÐAð !×$Ñ$ S¨!Ó,�Ø ×$Ñ$ S¨!Ó,�ä×-Ñ-ØÐ.¸DØ)-¸dØ%*ô,ô ×-Ñ-ØÐ.¸DØ)-¸dØ%*ô,ð	"�•ô "%×!:Ñ!:Ø  .¸dØ%)¸$Ø!&ô"(�”ô
 ×1Ñ1Ø�H¨$ÀØô!ˆŒô ×0Ñ0Ø�7¨¸tØô!ˆ�
ùòS#ùò $@ùò#ùòL#Pùò (Cùò#Ns$   Å3[-Æ[2Ç [7Ï3[<Ð\Ð4\c           
      ó€   — t        |«      }| j                  ||«      \  }}}}	}
}}| j                  |||||	|
||«      }|S ró   )rQ   re  rg  )rú   rf  rå   rs  rt  r�  r¤  r¥  r¦  r§  r¨  r©  rª  r¾   s                 r9   Ú_augment_imageszAffineCv2._augment_images
  s^   € Ü˜“Kˆ	à8<×8JÑ8JØ˜<ó9)ñ	6ˆÐ(¨.¸-Ø˜,¨à×0Ñ0Ø�MÐ#4°nØ˜<¨°}óFˆð ˆrE   c	                 óJ  — t         j                  t         j                  t         j                  t         j                  dœ}	t         j
                  t         j                  t         j                  t         j                  t         j                  dœ}
t        |«      }|}t        j                  |«      D �]j  }||   j                  d   ||   j                  d   }}|dz  dz
  }|dz  dz
  }|d   |   |d   |   }}|d   |   }|d   |   }t        j                  |«      r2t!        t#        j$                  |||   j                  d   z  «      «      }n|}t        j                  |«      r2t!        t#        j$                  |||   j                  d   z  «      «      }n|}||   }||   }||   }||   }||   }t        j&                  |«      r|n|
|   }t        j&                  |«      r|n|	|   }|dk7  xs! |dk7  xs |dk7  xs |dk7  xs |dk7  xs |dk7  }|rþt)        j*                  | | g¬«      }t)        j,                  ||f||ft/        j0                  |«      t/        j0                  |«      ¬	«      }t)        j*                  ||g¬«      } ||z   | z   }!t        j2                  t5        ||   «      |!j6                  d d
 ||f||t9        |D �"cg c]  }"t!        |"«      ‘Œ c}"«      ¬«      }#|#j:                  d
k(  r|#dt"        j<                  f   }#|#||<   �Œc||   ||<   �Œm |S c c}"w )NrÞ  rä  r   r
   r  r}   r6  r    r  r   rŠ   .)r%   rí  rî  rï  rð  rò  ró  rô  rõ  rö  rQ   rš   r›   rR   r)   Úis_single_floatr^   r‚   r’   r-   r   r¥   r  ÚmathÚradiansr–   r   r—   r]   r˜   r™   )$rM  rf  r¤  r¥  r¦  r§  r¨  r©  rª  Úorder_str_to_intÚmode_str_to_intr�  r¾   r¿   r§   r¨   r  r  r   rÿ   r  r  r  r  rø   rù   r=   rK   r6   Ú
any_changer  r  r  r`   rL   rh   s$                                       r9   rg  z$AffineCv2._augment_images_by_samples
  s_  € ô ×(Ñ(Ü×&Ñ&Ü—_‘_Ü×*Ñ*ñ	
Ðô ×-Ñ-Ü×)Ñ)Ü×1Ñ1Ü—O‘OÜ×+Ñ+ñ
ˆô ˜“Kˆ	ØˆÜ—‘˜9×%ˆAØ" 1™IŸO™O¨AÑ.°°q±	·±ÀÑ0B�EˆFØ˜c‘k CÑ'ˆGØ˜s‘l SÑ(ˆGØ,¨QÑ/°Ñ2°MÀ!Ñ4DÀQÑ4G�WˆGØ+¨AÑ.¨qÑ1ˆKØ+¨AÑ.¨qÑ1ˆKÜ×!Ñ! +Ô.Ü!$Ü—H‘H˜[¨6°!©9¯?©?¸1Ñ+=Ñ=Ó>ó"@‘ð "-�Ü×!Ñ! +Ô.Ü!$Ü—H‘H˜[¨6°!©9¯?©?¸1Ñ+=Ñ=Ó>ó"@‘ð "-�Ø# AÑ&ˆFØ! !Ñ$ˆEØ ‘?ˆDØ ‘?ˆDØ! !Ñ$ˆEô ×+Ñ+¨DÔ1ñ à(¨Ñ.ð ô ×,Ñ,¨UÔ3ñ à*¨5Ñ1ð ð
 ˜3‘ò - '¨S¡.ò -Ø! QÑ&ò-Ø*8¸AÑ*=ò-à˜Q‘;ò-à"'¨1¡*ð ñ Ü$&×$:Ñ$:Ø") ¨G¨8Ð 4ô%6Ð!ä$&×$6Ñ$6Ø" GÐ,Ø!/°Ð @Ü!Ÿ\™\¨&Ó1ÜŸ,™, uÓ-ô	%Ð!ô $&×#9Ñ#9Ø!(¨'Ð 2ô$4Ð à+Ø-ñ.à,ñ-�ô  #Ÿ~™~Ü-¨f°Q©iÓ8Ø—M‘M " 1Ð%Ø  &˜/ØØ#Ü %±tÓ&<±t°!¤s¨1¥v°tÑ&<Ó =ô �ð  ×$Ñ$¨Ò)Ø#/°´R·Z±Z°Ñ#@�Lð )��q“	à" 1™I��q“	ðG &ðJ ˆùò '=s   Ë
L c           
      óx  — t        |«      }| j                  ||«      \  }}}}	}
}}t        j                  |
j                  d   dft        j
                  ¬«      }
dgt        |«      z  }|D �cg c]  }|j                  ‘Œ }}| j                  |||||	|
||«      }t        ||«      D ]  \  }}||_        Œ |S c c}w ©Nr   r
   r‡  r   )	rQ   re  r‚   ÚzerosrR   r   r_  rg  r‹  )rú   rh  rå   rs  rt  r�  r¤  r¥  r¦  r§  r¨  r©  rª  Ú	heatmap_ir“  r”  r—  s                    r9   Ú_augment_heatmapszAffineCv2._augment_heatmapsv
  sÐ   € Ü˜“Mˆ	à8<×8JÑ8JØ˜<ó9)ñ	6ˆÐ(¨.¸-Ø˜,¨ä—x‘x ×!3Ñ!3°AÑ!6¸Ð :Ä"Ç*Á*ÔMˆØ"�|¤c¨,Ó&7Ñ7ˆÙ4<Ó=±H y�	×"Ó"°HˆÐ=Ø×2Ñ2Ø�-Ð!2°NØ˜<¨°}óFˆô #& h°Ö"9ÑˆI�wØ!(ˆIÕð #:àˆùò >s   Á-B7c           
      ó–  — t        |«      }| j                  ||«      \  }}}}	}
}}t        j                  |
j                  d   dft        j
                  ¬«      }
dgt        |«      z  }dgt        |«      z  }|D �cg c]  }|j                  ‘Œ }}| j                  |||||	|
||«      }t        ||«      D ]  \  }}||_        Œ |S c c}w r	  )	rQ   re  r‚   r
  rR   r   r_   rg  r‹  )rú   Úsegmapsrå   rs  rt  r�  r¤  r¥  r¦  r§  r¨  r©  rª  Ú	segmaps_ir“  r”  r—  s                    r9   Ú_augment_segmentation_mapsz$AffineCv2._augment_segmentation_maps…
  sÞ   € Ü˜“Lˆ	à8<×8JÑ8JØ˜<ó9)ñ	6ˆÐ(¨.¸-Ø˜,¨ä—x‘x ×!3Ñ!3°AÑ!6¸Ð :Ä"Ç*Á*ÔMˆØ"�|¤c¨,Ó&7Ñ7ˆØ˜œc -Ó0Ñ0ˆÙ/6Ó7©w )�	—“¨wˆÐ7Ø×2Ñ2Ø�-Ð!2°NØ˜<¨°}óFˆô #& g¨xÖ"8ÑˆI�wØ#ˆI�Mð #9àˆùò 8s   Á<Cc           
      ó.  — g }t        |«      }| j                  ||«      \  }}}	}
}}}t        |«      D �]X  \  }}|j                  s|j	                  |«       Œ%|j
                  |j                  }}|dz  dz
  }|dz  dz
  }|d   |   |d   |   }}|d   |   }|d   |   }t        j                  |«      r/t        t        j                  ||j                  d   z  «      «      }n|}t        j                  |«      r/t        t        j                  ||j                  d   z  «      «      }n|}|	|   }|
|   }|dk7  xs! |dk7  xs |dk7  xs |dk7  xs |dk7  xs |dk7  }|�rt        j                  | | g¬«      }t        j                  ||f||ft!        j"                  |«      t!        j"                  |«      ¬«      }t        j                  ||g¬«      }||z   |z   } |j%                  «       }!t        j&                  |!| j(                  «      }"t+        |j                  |"«      D �#�!cg c]  \  }#}!|#j-                  |!d   |!d   ¬«      ‘Œ  }$}#}!|j	                  |j-                  |$|j                  ¬	«      «       �ŒH|j	                  |«       �Œ[ |S c c}!}#w )
Nr  r}   r   r
   r6  r    r  r3  )ra  rR   )rQ   re  rÐ   ra  r~  r§   r¨   r)   r  r^   r‚   r’   rR   r   r¥   r  r  r  rn  ro  r—   r‹  Údeepcopy)%rú   Úkeypoints_on_imagesrå   rs  rt  r¾   r�  r¤  r¥  r¦  r§  Ú_cval_samplesÚ_mode_samplesÚ_order_samplesr¿   Úkeypoints_on_imager§   r¨   r  r  r   rÿ   r  r  r  r  rø   rù   r  r  r  r  r`   rÑ   rz  ÚkpÚkps_news%                                        r9   Ú_augment_keypointszAffineCv2._augment_keypoints•
  sþ  € àˆÜÐ+Ó,ˆ	à;?×;MÑ;MØ˜<ó<)ñ	9ˆÐ(¨.¸-Ø˜=¨.ô &/Ð/B×%CÑ!ˆAÐ!Ø%×/Ò/ð —‘Ð0Ô1ØØ.×5Ñ5Ð7I×7OÑ7O�EˆFØ˜c‘k CÑ'ˆGØ˜s‘l SÑ(ˆGØ,¨QÑ/°Ñ2°MÀ!Ñ4DÀQÑ4G�WˆGØ+¨AÑ.¨qÑ1ˆKØ+¨AÑ.¨qÑ1ˆKÜ×!Ñ! +Ô.Ü!$Ü—H‘H˜[Ð+=×+CÑ+CÀAÑ+FÑFÓGó"I‘ð "-�Ü×!Ñ! +Ô.Ü!$Ü—H‘H˜[Ð+=×+CÑ+CÀAÑ+FÑFÓGó"I‘ð "-�Ø# AÑ&ˆFØ! !Ñ$ˆEð ˜3‘ò - '¨S¡.ò -Ø! QÑ&ò-Ø*8¸AÑ*=ò-à˜Q‘;ò-à"'¨1¡*ð ò Ü$&×$:Ñ$:Ø") ¨G¨8Ð 4ô%6Ð!ä$&×$6Ñ$6Ø" GÐ,Ø!/°Ð @Ü!Ÿ\™\¨&Ó1ÜŸ,™, uÓ-ô	%Ð!ô $&×#9Ñ#9Ø!(¨'Ð 2ô$4Ð à+Ø-ñ.à,ñ-�ð ,×7Ñ7Ó9�Ü×0Ñ0°¸¿¹ÓG�
ô "Ð"4×">Ñ">À
ÔKôMáKñ  *˜r 6ð Ÿ;™;¨°©°f¸Q±i˜;Õ@àKð ñ Mð —‘Ð0×9Ñ9Ø%Ø,×2Ñ2ð :ó ö ð
 —‘Ð0Ö1ðq &Dðr ˆùóMs   È'#Jc                 ó*   — | j                  ||||«      S ró   )Ú_augment_polygons_as_keypoints)rú   Úpolygons_on_imagesrå   rs  rt  s        r9   Ú_augment_polygonszAffineCv2._augment_polygonsØ
  s   € à×2Ñ2Ø ¨g°uó>ð 	>rE   c                 ó*   — | j                  ||||«      S ró   )Ú"_augment_line_strings_as_keypoints)rú   Úline_strings_on_imagesrå   rs  rt  s        r9   Ú_augment_line_stringszAffineCv2._augment_line_stringsÝ
  s    € à×6Ñ6Ø" L°'¸5óBð 	BrE   c                 ó*   — | j                  ||||«      S ró   )Ú$_augment_bounding_boxes_as_keypoints)rú   Úbounding_boxes_on_imagesrå   rs  rt  s        r9   Ú_augment_bounding_boxesz!AffineCv2._augment_bounding_boxesâ
  s    € à×8Ñ8Ø$ l°G¸UóDð 	DrE   c                 ó    — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  gS r¬  )rõ   rö   rø   rù   r6   r=   rK   r"  s    r9   r­  zAffineCv2.get_parametersç
  s8   € à—
‘
˜DŸN™N¨D¯K©K¸¿¹Ø—
‘
˜DŸI™I t§y¡yð2ð 	2rE   c                 óp  — |j                  d«      }t        | j                  t        «      rI| j                  d   j	                  |f|d   ¬«      | j                  d   j	                  |f|d   ¬«      f}n%| j                  j	                  |f|d   ¬«      }||f}t        | j
                  t        «      rI| j
                  d   j	                  |f|d   ¬«      | j
                  d   j	                  |f|d   ¬«      f}n%| j
                  j	                  |f|d   ¬«      }||f}g d	¢}t        j                  d«      D ]K  }||   j                  j                  |v rŒJ d
t        |«      ›d||   j                  j                  ›d�«       ‚ | j                  j	                  |f|d   ¬«      }| j                  j	                  |f|d   ¬«      }	| j                  j	                  |df|d   ¬«      }
| j                  j	                  |f|d   ¬«      }| j                  j	                  |f|d   ¬«      }||||	|
||fS )NrŸ  r   r�  r
   r   r   r   r'   )r   rq   r   r   z0Expected translate_samples to have any dtype of z. Got r(   rÜ   rÝ   rÚ   rž  r5  )r   r/   rõ   r]   r¡  rö   rš   r›   rU   rV   r2   rø   rù   r=   rK   r6   )rú   r¢  rå   r£  r¤  r¥  Ú	valid_dtsr¿   r¦  r§  r¨  r©  rª  s                r9   re  zAffineCv2._draw_samplesì
  s{  € Ø×%Ñ% bÓ)ˆä�d—j‘j¤%Ô(à—
‘
˜1‘×*Ñ*¨J¨=Ø8<¸Q¹ð +ó Aà—
‘
˜1‘×*Ñ*¨J¨=Ø8<¸Q¹ð +ó Að‰Mð !ŸJ™J×3Ñ3°Z°MØAEÀaÁð 4ó JˆMà*¨MÐ:ˆMä�d—n‘n¤eÔ,à—‘˜qÑ!×.Ñ.°
¨}Ø<@À¹Gð /ó Eà—‘˜qÑ!×.Ñ.°
¨}Ø<@À¹Gð /ó Eð!Ñð !%§¡× ;Ñ ;Ø�¨D°©Gð !<ó !5Ðà!2Ð4EÐ FÐâ<ˆ	Ü—‘˜1–ˆAØ$ QÑ'×-Ñ-×2Ñ2°iÒ?ñ Pä  �^Ð->¸qÑ-A×-GÑ-G×-LÓ-LðOóPÐ?ð ð
 Ÿ™×1Ñ1°:°-Ø?CÀA¹wð 2ó HˆàŸ
™
×/Ñ/°°Ø=AÀ!¹Wð 0ó Fˆð —y‘y×-Ñ-¨z¸1¨oØ;?À¹7ð .ó Dˆà—y‘y×-Ñ-¨z¨mØ;?À¹7ð .ó DˆàŸ
™
×/Ñ/°°Ø=AÀ"¹Xð 0ó Gˆð Ð,¨n¸mØ˜,¨ð
ð 	
rE   )r$  r%  r&  r°  r%   rî  rö  rû   r   r±  rg  r  r  r  r  r"  r&  r­  re  r²  r³  s   @r9   rÛ  rÛ  6  s„   ø„ ñgðR	 !°DÀtØ 3¨c×.>Ñ.>ÀQØ×)Ñ)Ø Ø*¸,õ	m!ò^ð ñZó ðZòxòò AòF>ò
Bò
Dò
2ö
0
rE   rÛ  c                   ó   — e Zd Zd„ Zd„ Zy)Ú_PiecewiseAffineSamplingResultc                 óX   — || _         || _        || _        || _        || _        || _        y ró   )r¸   r¹   r6   Újitterr=   rK   )rú   r¸   r¹   r-  r6   r=   rK   s          r9   rû   z'_PiecewiseAffineSamplingResult.__init__   s,   € ØˆŒØˆŒØˆŒ
ØˆŒØˆŒ	Øˆ�	rE   c                 ó‚   — t        j                  |«      \  }}}| j                  |   }t        t	        ||«      |«      }|S ró   )rS   rT   r=   rY   rZ   )rú   r
  rU   ra   r™  rc   r=   s          r9   Úget_clipped_cvalz/_PiecewiseAffineSamplingResult.get_clipped_cval(  s>   € Ü"&×"?Ñ"?ÀÓ"FÑˆ	�1�iØ�y‰y˜‰~ˆÜ”3�t˜YÓ'¨Ó3ˆØˆrE   N)r$  r%  r&  rû   r/  r'  rE   r9   r+  r+    s   „ òórE   r+  c                   óX   ‡ — e Zd ZdZ	 	 	 	 	 d
ˆ fd„	Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zˆ xZS )ÚPiecewiseAffinea±  
    Apply affine transformations that differ between local neighbourhoods.

    This augmenter places a regular grid of points on an image and randomly
    moves the neighbourhood of these point around via affine transformations.
    This leads to local distortions.

    This is mostly a wrapper around scikit-image's ``PiecewiseAffine``.
    See also ``Affine`` for a similar technique.

    .. note::

        This augmenter is very slow. See :ref:`performance`.
        Try to use ``ElasticTransformation`` instead, which is at least 10x
        faster.

    .. note::

        For coordinate-based inputs (keypoints, bounding boxes, polygons,
        ...), this augmenter still has to perform an image-based augmentation,
        which will make it significantly slower for such inputs than other
        augmenters. See :ref:`performance`.

    **Supported dtypes**:

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; tested (1)
        * ``uint32``: yes; tested (1) (2)
        * ``uint64``: no (3)
        * ``int8``: yes; tested (1)
        * ``int16``: yes; tested (1)
        * ``int32``: yes; tested (1) (2)
        * ``int64``: no (3)
        * ``float16``: yes; tested (1)
        * ``float32``: yes; tested (1)
        * ``float64``: yes; tested (1)
        * ``float128``: no (3)
        * ``bool``: yes; tested (1) (4)

        - (1) Only tested with `order` set to ``0``.
        - (2) scikit-image converts internally to ``float64``, which might
              introduce inaccuracies. Tests showed that these inaccuracies
              seemed to not be an issue.
        - (3) Results too inaccurate.
        - (4) Mapped internally to ``float64``.

    Parameters
    ----------
    scale : float or tuple of float or imgaug.parameters.StochasticParameter, optional
        Each point on the regular grid is moved around via a normal
        distribution. This scale factor is equivalent to the normal
        distribution's sigma. Note that the jitter (how far each point is
        moved in which direction) is multiplied by the height/width of the
        image if ``absolute_scale=False`` (default), so this scale can be
        the same for different sized images.
        Recommended values are in the range ``0.01`` to ``0.05`` (weak to
        strong augmentations).

            * If a single ``float``, then that value will always be used as
              the scale.
            * If a tuple ``(a, b)`` of ``float`` s, then a random value will
              be uniformly sampled per image from the interval ``[a, b]``.
            * If a list, then a random value will be picked from that list
              per image.
            * If a ``StochasticParameter``, then that parameter will be
              queried to draw one value per image.

    nb_rows : int or tuple of int or imgaug.parameters.StochasticParameter, optional
        Number of rows of points that the regular grid should have.
        Must be at least ``2``. For large images, you might want to pick a
        higher value than ``4``. You might have to then adjust scale to lower
        values.

            * If a single ``int``, then that value will always be used as the
              number of rows.
            * If a tuple ``(a, b)``, then a value from the discrete interval
              ``[a..b]`` will be uniformly sampled per image.
            * If a list, then a random value will be picked from that list
              per image.
            * If a StochasticParameter, then that parameter will be queried to
              draw one value per image.

    nb_cols : int or tuple of int or imgaug.parameters.StochasticParameter, optional
        Number of columns. Analogous to `nb_rows`.

    order : int or list of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :func:`~imgaug.augmenters.geometric.Affine.__init__`.

    cval : int or float or tuple of float or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :func:`~imgaug.augmenters.geometric.Affine.__init__`.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        See :func:`~imgaug.augmenters.geometric.Affine.__init__`.

    absolute_scale : bool, optional
        Take `scale` as an absolute value rather than a relative value.

    polygon_recoverer : 'auto' or None or imgaug.augmentables.polygons._ConcavePolygonRecoverer, optional
        The class to use to repair invalid polygons.
        If ``"auto"``, a new instance of
        :class`imgaug.augmentables.polygons._ConcavePolygonRecoverer`
        will be created.
        If ``None``, no polygon recoverer will be used.
        If an object, then that object will be used and must provide a
        ``recover_from()`` method, similar to
        :class:`~imgaug.augmentables.polygons._ConcavePolygonRecoverer`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.PiecewiseAffine(scale=(0.01, 0.05))

    Place a regular grid of points on each image and then randomly move each
    point around by ``1`` to ``5`` percent (with respect to the image
    height/width). Pixels between these points will be moved accordingly.

    >>> aug = iaa.PiecewiseAffine(scale=(0.01, 0.05), nb_rows=8, nb_cols=8)

    Same as the previous example, but uses a denser grid of ``8x8`` points
    (default is ``4x4``). This can be useful for large images.

    c                 ó:  •— t         t        | �  |	|
||¬«       t        j                  |dddd¬«      | _        t        j                  d| j
                  ¬«      | _        t        j                  |dd	ddd
¬«      | _	        t        j                  |dd	ddd
¬«      | _
        t        |d¬«      | _        t        |«      | _        t        |«      | _        || _        || _        |dk(  rt'        «       | _        d| _        d| _        d| _        d| _        d| _        d| _        y )Nr1  rõ   ©r   NTr>   r   ©Úlocrõ   r¸   )r   NFrU  r¹   rO   )r7   r$   r   r   )r7  r1  rû   r+   rC   rõ   ÚNormalr-  rX  r¸   r¹   r:   r6   rD   r=   rM   rK   Úabsolute_scaleÚpolygon_recovererr	   r<  r=  r>  r?  r@  rA  )rú   rõ   r¸   r¹   r6   r=   rK   r7  r8  rã   rV   rå   r2  rE  s                €r9   rû   zPiecewiseAffine.__init__¼  s  ø€ ô
 	Œo˜tÑ-Ø˜DØ%°]ð 	.ô 	Dô ×0Ñ0Ø�7¨	ÀDØô!ˆŒ
ô —j‘j Q¨d¯j©jÔ9ˆŒÜ×0Ñ0Ø�Y¨IÈØ¨eô5ˆŒô ×0Ñ0Ø�Y¨IÈØ¨eô5ˆŒô ' u°iÔ@ˆŒ
Ü$ TÓ*ˆŒ	Ü$ TÓ*ˆŒ	à,ˆÔØ!2ˆÔØ Ò&Ü%=Ó%?ˆDÔ"ð  !ˆÔØ()ˆÔ%Ø(ˆÔØ'1ˆÔ$ØˆÔØ'(ˆÕ$rE   c                 ó4  — | j                  |j                  |«      }|j                  �!| j                  |j                  |«      |_        |j                  �C| j                  |j                  d|| j                  | j                  | j                  «      |_        |j                  �C| j                  |j                  d|| j                  | j                  | j                  «      |_	        |j                  �Nt        j                  | j                   |¬«      }| j#                  |j                  || j$                  ¬«      |_        dD ]Q  }t'        ||«      }|€Œt        j                  | j                   |¬«      }| j)                  ||«      }	t+        |||	«       ŒS |S )Nr_  r_   )ru  ©Ú	recoverer©ra  rb  rd  )re  r¸   rf  rg  rh  ri  r@  r>  r<  rj  rA  r?  r=  rc  Ú	functoolsÚpartialÚ_augment_keypoints_by_samplesÚ_apply_to_polygons_as_keypointsr8  rk  Ú_apply_to_cbaois_as_keypointsrŽ  )
rú   rr  rå   rs  rt  ru  Úfuncrv  rw  Úcbaoiss
             r9   r{  zPiecewiseAffine._augment_batch_æ  s  € Ø×$Ñ$ U§]¡]°LÓAˆà�<‰<Ð#Ø×:Ñ:¸5¿<¹<Ø;BóDˆEŒLð �>‰>Ð%Ø!×:Ñ:Ø—‘ 
¨G°T×5HÑ5HØ×#Ñ# T×%9Ñ%9ó;ˆEŒNð ×"Ñ"Ð.Ø&*×&CÑ&CØ×'Ñ'¨°Ø×,Ñ,¨d×.JÑ.JØ×-Ñ-ó'/ˆEÔ#ð �>‰>Ð%Ü×$Ñ$Ø×2Ñ2Øô!ˆDð "×AÑAØ—‘ °×0FÑ0Fð Bó HˆEŒNó IˆIÜ  ¨	Ó2ˆJØÑ%Ü ×(Ñ(Ø×6Ñ6Ø#ô%�ð ×;Ñ;¸JÈÓM�Ü˜˜y¨&Õ1ð Ið ˆrE   c                 ó¶  — t        j                  |g d¢g d¢| ¬«       |}t        |«      D �]*  \  }}| j                  |j                  |j                  |j
                  |   |j                  |   |j                  |   «      }|€ŒZ|j                  }|j                  j                  dk(  r|j                  t        j                  «      }t        j                  |||j                  |   |j                   |   |j#                  ||j                  «      d||   j                  ¬«      }|j                  dk(  r|dkD  }nt        j$                  ||«      }|||<   �Œ- |S )Nrk   rm   rw   ÚbTr{   r}   )rS   r~   rÐ   Ú_get_transformerrR   r¸   r¹   r-  rU   Úkindr‘   r‚   r   r   r€   r6   rK   r/  r„   )	rú   rf  ru  r¾   r¿   r„  Útransformerr…   rh   s	            r9   rg  z*PiecewiseAffine._augment_images_by_samples  s@  € Ü×ÑØò6ò;ð õ		ð ˆä! &×)‰HˆAˆuØ×/Ñ/Ø—‘˜UŸ[™[¨'¯/©/¸!Ñ*<Ø—‘ Ñ" G§N¡N°1Ñ$5ó7ˆKð Ñ&Ø#Ÿk™k�Ø—;‘;×#Ñ# sÒ*Ø!ŸL™L¬¯©Ó4�Eä!Ÿw™wØØØ!Ÿ-™-¨Ñ*Ø Ÿ™ a™Ø ×1Ñ1°!°U·[±[ÓAØ#'Ø!'¨¡§¡ô �ð ×#Ñ# sÒ*Ø#/°#Ñ#5‘Lô $(×#7Ñ#7Ø$ kó$3�Lð )��q“	ð9 *ð< ˆrE   c           
      ód  — |}t        |«      D �]  \  }}	t        |	|«      }
| j                  |
j                  |	j                  |j                  |   |j
                  |   |j                  |   «      }|€Œft        j                  |
||�|n|j                  |   |�|n|j                  |   |�|n|j                  |   d|
j                  ¬«      }|j                  |
j                  «      }|dk\  r3t        |	t        j                   «      rt#        j$                  |dd|¬«      }t'        |	||«       �Œ! |S )NTr{   r   r#  r6  rˆ  )rÐ   rk  rF  rR   r¸   r¹   r-  r   r€   r6   rK   r=   r‘   rU   r/   r)   rŒ  r‚   r�  rŽ  )rú   r�  r�  ru  r=   rK   r6   r¾   r¿   r’  r_   rH  Ú
arr_warpeds                r9   ri  z(PiecewiseAffine._augment_maps_by_samples;  s  € àˆä'¨×5‰NˆAˆ{Ü˜+ }Ó5ˆCà×/Ñ/Ø—	‘	˜;×,Ñ,¨g¯o©o¸aÑ.@Ø—‘ Ñ" G§N¡N°1Ñ$5ó7ˆKð Ñ&ÜŸW™WØØØ#(Ð#4™%¸'¿-¹-ÈÑ:JØ!%Ð!1™°w·|±|ÀA±Ø!%Ð!1™°w·|±|ÀA±Ø#'Ø!$§¡ô�
ð (×.Ñ.¨s¯y©yÓ9�
ð ˜A’:¤*¨[¼"×:LÑ:LÔ"MÜ!#§¡¨°S¸#À:Ô!N�Jä˜ ]°JÖ?ðA 6ðD ˆrE   c                 óÎ  — g }t        |«      D �]Ó  \  }}|j                  dd \  }}| j                  |j                  |j                  |j                  |   |j                  |   |j
                  |   «      }|�t        |j                  «      dk(  r|j                  |«       Œ•	 |j                  d¬«      }	t        j                  |	|dd|j                  d   |j                  d   t        |j                  «      f¬«      }
t        j                  j                  |
ddddd	œt        |j                  «      d
k  rd n|j                  d   ¬«      }t        |j                  |j                  «      D ]`  \  }}d|j                   cxk  xr |k  nc xr d|j"                  cxk  xr |k  nc }|sŒ?|j                   |_        |j"                  |_        Œb |j                  |«       �ŒÖ |S )Nr   r   T)Úinvertedr
   )r6   r|   rP   g{®Gáz„?r‰   r3  r   )rL  Ú	thresholdÚif_not_found_coordsr�   )rÐ   rR   rF  r¸   r¹   r-  rQ   ra  r~  Úto_distance_mapsr   r€   r)   ÚKeypointsOnImageÚfrom_distance_mapsr‹  rÓ   rÔ   )rú   Úkpsoisru  r¾   r¿   ry  ÚhÚwrH  Ú	dist_mapsÚdist_maps_warpedÚkps_augr  Úkp_augÚwithin_images                  r9   r?  z-PiecewiseAffine._augment_keypoints_by_samplesd  s®  € àˆä! &×)‰HˆAˆuØ—;‘;˜q Ð#‰DˆAˆqØ×/Ñ/Ø—‘˜UŸ[™[¨'¯/©/¸!Ñ*<Ø—‘ Ñ" G§N¡N°1Ñ$5ó7ˆKð Ð"¤c¨%¯/©/Ó&:¸aÒ&?Ø—‘˜eÕ$ð	ð* "×2Ñ2¸DÐ2ÓA�	Ü#%§7¡7ØØØØ#'Ø"'§+¡+¨a¡.°%·+±+¸a±.Ü"% e§o¡oÓ"6ð"8ô$Ð ô ×-Ñ-×@Ñ@Ø$Ø!Ø"Ø.0°rÑ(:ä # E§K¡KÓ 0°1Ò 4™¸%¿+¹+Àa¹.ð Aó �ô #& e§o¡o°w×7HÑ7HÖ"I‘J�B˜ð %&¨¯©¦M°¤MÒ$C°a¸2¿4¹4¶mÀ!´m�LÚ#Ø%Ÿx™x˜œØ%Ÿx™x˜�ð #Jð —‘˜eÖ$ðA *ðD ˆrE   c                 óÐ  — |j                  d«      }| j                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }| j
                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }t        j                  |dd «      }t        j                  |dd «      }||z  }	| j                  j                  t        t        j                  |	«      «      df|d	   ¬«      }
g }d
}|	D ]&  }|
|||z   …d d …f   }|j                  |«       ||z  }Œ( t        ||||||¬«      S )NrÜ   iúÿÿÿr�  éûÿÿÿéüÿÿÿéýÿÿÿéþÿÿÿr   r‰   r   )r¸   r¹   r-  r6   r=   rK   )r   r¸   r¡  r¹   r6   r=   rK   r‚   r�  r-  r^   Úsumr~  r+  )rú   r�  rå   ÚrssÚnb_rows_samplesÚnb_cols_samplesrª  r¨  r©  Únb_cellsr-  Újitter_by_imageÚcounterÚ
nb_cells_iÚ
jitter_imgs                  r9   re  zPiecewiseAffine._draw_samples¬  s˜  € Ø×$Ñ$ QÓ'ˆàŸ,™,×3Ñ3°Y°LØADÀRÁð 4ó JˆàŸ,™,×3Ñ3°Y°LØADÀRÁð 4ó JˆàŸ
™
×/Ñ/°°Ø=@À¹Wð 0ó Fˆà—y‘y×-Ñ-¨y¨lØ;>¸r¹7ð .ó Dˆà—y‘y×-Ñ-¨y¨lØ;>¸r¹7ð .ó Dˆô Ÿ'™' /°1°dÓ;ˆÜŸ'™' /°1°dÓ;ˆØ" _Ñ4ˆØ—‘×)Ñ)¬3¬r¯v©v°hÓ/?Ó+@À!Ð*DØ7:¸2±wð *ó @ˆð ˆØˆÛ"ˆJØ ¨°
Ñ(:Ð :ºAÐ =Ñ>ˆJØ×"Ñ" :Ô.Ø�zÑ!‰Gð #ô
 .Ø#¨_Ø"Ø l¸ôGð 	GrE   c                 óì  — t        j                  d|d   |«      }t        j                  d|d   |«      }t        j                  ||«      \  }}	t        j                  |	j                  |j                  g«      d   }
t        j
                  |dkD  «      }|sy t        j                  |«      }| j                  rP|d   dkD  r|d d …df   |d   z  |d d …df<   n	d|d d …df<   |d   dkD  r|d d …df   |d   z  |d d …df<   n	d|d d …df<   |d d …df   |d   z  |d d …df<   |d d …df   |d   z  |d d …df<   t        j                  |
«      }|d d …df   |d d …df   z   |d d …df<   |d d …df   |d d …df   z   |d d …df<   t        j                  |d d …df   d|d   dz
  «      |d d …df<   t        j                  |d d …df   d|d   dz
  «      |d d …df<   t        |dd D �cg c]  }|dk  ‘Œ	 c}«      }|d uxr t        |«      dk(  xr |d   dk(  xs |d uxr t        |«      dk(  xr |d   dk(  }|s|ry t        j                  «       }|j                  |
d d …d d d…f   |d d …d d d…f   «       |S c c}w )Nr   r
   r#  r   r   r‰   )r‚   ÚlinspaceÚmeshgridÚdstackÚflatÚanyrÏ   r7  r�  rQ   r   ÚPiecewiseAffineTransformÚestimate)rú   Úaugmentable_shaperÒ   r¸   r¹   rg  rÔ   rÓ   Úxx_srcÚyy_srcÚ
points_srcÚany_nonzeroÚpoints_destr�   Úhas_low_axisÚhas_zero_channelsr`   s                    r9   rF  z PiecewiseAffine._get_transformerÌ  sð  € ô �K‰K˜Ð,¨QÑ/°Ó9ˆÜ�K‰K˜Ð,¨QÑ/°Ó9ˆô Ÿ™ Q¨Ó*‰ˆ�ô —Y‘Y §¡¨V¯[©[Ð9Ó:¸1Ñ=ˆ
ä—f‘f˜Z¨!™^Ó,ˆÙØô Ÿ™ Ó,ˆJà×"Ò"Ø˜q‘> AÒ%Ø'1²!°Q°$Ñ'7¸+Àa¹.Ñ'H�Jšq !˜tÒ$à'*�Jšq !˜tÑ$à˜q‘> AÒ%Ø'1²!°Q°$Ñ'7¸+Àa¹.Ñ'H�Jšq !˜tÒ$à'*�Jšq !˜tÑ$à)ª!¨Q¨$Ñ/Ð2CÀAÑ2FÑFˆJ’q˜!�tÑØ)ª!¨Q¨$Ñ/Ð2CÀAÑ2FÑFˆJ’q˜!�tÑäŸ'™' *Ó-ˆKØ +ªA¨q¨DÑ 1°JºqÀ!¸tÑ4DÑ DˆKš˜1˜ÑØ +ªA¨q¨DÑ 1°JºqÀ!¸tÑ4DÑ DˆKš˜1˜Ñô !#§¡¨²A°q°DÑ(9Ø()Ð+<¸QÑ+?ÀÑ+Aó!CˆKš˜1˜Ñä "§¡¨²A°q°DÑ(9Ø()Ð+<¸QÑ+?ÀÑ+Aó!CˆKš˜1˜Ñô
 Ð6GÈÈ!Ñ6LÓMÑ6L¨d ¨£	Ð6LÑMÓNˆLð &¨TÐ1ò 3ÜÐ-Ó.°!Ñ3ò3à)¨"Ñ-°Ñ2ò
ð   tÐ+ò -Ü˜KÓ(¨AÑ-ò-à# B™¨1Ñ,ð ñ Ñ0Øä×4Ñ4Ó6�Ø—‘ 
ª1©d°¨d¨7Ñ 3°[ÂÁDÀbÀDÀÑ5IÔJØ�ùò)  Ns   ÇI1c                 ó    — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  gS r¬  )rõ   r¸   r¹   r6   r=   rK   r7  r"  s    r9   r­  zPiecewiseAffine.get_parameters  s<   € ð �J‰J˜Ÿ™ d§l¡l°D·J±JÀÇ	Á	Ø�I‰I�t×*Ñ*ð,ð 	,rE   ))r#  g{®Gáz¤?©r   r   ry  r
   r   r   FNNNr®  r®  )r$  r%  r&  r°  rû   r{  rg  ri  r?  re  rF  r­  r²  r³  s   @r9   r1  r1  /  sO   ø„ ñJðX CIØBGØ#'Ø!%Ø:Fõ	')òT#òL,ò^&òRFòPGò@Nö`,rE   r1  c                   ó   — e Zd Zd„ Zy)Ú#_PerspectiveTransformSamplingResultc                 óJ   — || _         || _        || _        || _        || _        y ró   )rƒ  Úmax_heightsÚ
max_widthsÚcvalsÚmodes)rú   rƒ  r}  r~  r  r€  s         r9   rû   z,_PerspectiveTransformSamplingResult.__init__$  s&   € Ø ˆŒØ&ˆÔØ$ˆŒØˆŒ
Øˆ�
rE   N©r$  r%  r&  rû   r'  rE   r9   r{  r{  #  s   „ órE   r{  c                   ó²   ‡ — e Zd ZdZej
                  ej                  dœZ	 	 	 	 dˆ fd„	Ze	d„ «       Z
d„ Zd„ Zd„ Zd„ Zd	„ Ze	d
„ «       Ze	d„ «       Zd„ Zˆ xZS )ÚPerspectiveTransformak  
    Apply random four point perspective transformations to images.

    Each of the four points is placed on the image using a random distance from
    its respective corner. The distance is sampled from a normal distribution.
    As a result, most transformations don't change the image very much, while
    some "focus" on polygons far inside the image.

    The results of this augmenter have some similarity with ``Crop``.

    Code partially from
    http://www.pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/

    **Supported dtypes**:

    if (keep_size=False):

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; tested
        * ``uint32``: no (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested (3)
        * ``int16``: yes; tested
        * ``int32``: no (2)
        * ``int64``: no (2)
        * ``float16``: yes; tested (4)
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (1)
        * ``bool``: yes; tested (4)

        - (1) rejected by opencv
        - (2) leads to opencv error: cv2.error: ``OpenCV(3.4.4)
              (...)imgwarp.cpp:1805: error: (-215:Assertion failed)
              ifunc != 0 in function 'remap'``.
        - (3) mapped internally to ``int16``.
        - (4) mapped intenally to ``float32``.

    if (keep_size=True):

        minimum of (
            ``imgaug.augmenters.geometric.PerspectiveTransform(keep_size=False)``,
            :func:`~imgaug.imgaug.imresize_many_images`
        )

    Parameters
    ----------
    scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Standard deviation of the normal distributions. These are used to
        sample the random distances of the subimage's corners from the full
        image's corners. The sampled values reflect percentage values (with
        respect to image height/width). Recommended values are in the range
        ``0.0`` to ``0.1``.

            * If a single number, then that value will always be used as the
              scale.
            * If a tuple ``(a, b)`` of numbers, then a random value will be
              uniformly sampled per image from the interval ``(a, b)``.
            * If a list of values, a random value will be picked from the
              list per image.
            * If a ``StochasticParameter``, then that parameter will be
              queried to draw one value per image.

    keep_size : bool, optional
        Whether to resize image's back to their original size after applying
        the perspective transform. If set to ``False``, the resulting images
        may end up having different shapes and will always be a list, never
        an array.

    cval : number or tuple of number or list of number or imaug.ALL or imgaug.parameters.StochasticParameter, optional
        The constant value used to fill up pixels in the result image that
        didn't exist in the input image (e.g. when translating to the left,
        some new pixels are created at the right). Such a fill-up with a
        constant value only happens, when `mode` is ``constant``.
        The expected value range is ``[0, 255]`` for ``uint8`` images.
        It may be a float value.

            * If this is a single int or float, then that value will be used
              (e.g. 0 results in black pixels).
            * If a tuple ``(a, b)``, then a random value is uniformly sampled
              per image from the interval ``[a, b]``.
            * If a list, then a random value will be sampled from that list
              per image.
            * If ``imgaug.ALL``, then equivalent to tuple ``(0, 255)``.
            * If a ``StochasticParameter``, a new value will be sampled from
              the parameter per image.

    mode : int or str or list of str or list of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        Parameter that defines the handling of newly created pixels.
        Same meaning as in OpenCV's border mode. Let ``abcdefgh`` be an image's
        content and ``|`` be an image boundary, then:

            * ``cv2.BORDER_REPLICATE``: ``aaaaaa|abcdefgh|hhhhhhh``
            * ``cv2.BORDER_CONSTANT``: ``iiiiii|abcdefgh|iiiiiii``, where
              ``i`` is the defined cval.
            * ``replicate``: Same as ``cv2.BORDER_REPLICATE``.
            * ``constant``: Same as ``cv2.BORDER_CONSTANT``.

        The datatype of the parameter may be:

            * If a single ``int``, then it must be one of ``cv2.BORDER_*``.
            * If a single string, then it must be one of: ``replicate``,
              ``reflect``, ``reflect_101``, ``wrap``, ``constant``.
            * If a list of ints/strings, then per image a random mode will be
              picked from that list.
            * If ``imgaug.ALL``, then a random mode from all possible modes
              will be picked per image.
            * If ``StochasticParameter``, then the mode will be sampled from
              that parameter per image, i.e. it must return only the above
              mentioned strings.

    fit_output : bool, optional
        If ``True``, the image plane size and position will be adjusted
        to still capture the whole image after perspective transformation.
        (Followed by image resizing if `keep_size` is set to ``True``.)
        Otherwise, parts of the transformed image may be outside of the image
        plane.
        This setting should not be set to ``True`` when using large `scale`
        values as it could lead to very large images.

        Added in 0.4.0.

    polygon_recoverer : 'auto' or None or imgaug.augmentables.polygons._ConcavePolygonRecoverer, optional
        The class to use to repair invalid polygons.
        If ``"auto"``, a new instance of
        :class`imgaug.augmentables.polygons._ConcavePolygonRecoverer`
        will be created.
        If ``None``, no polygon recoverer will be used.
        If an object, then that object will be used and must provide a
        ``recover_from()`` method, similar to
        :class:`~imgaug.augmentables.polygons._ConcavePolygonRecoverer`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.PerspectiveTransform(scale=(0.01, 0.15))

    Apply perspective transformations using a random scale between ``0.01``
    and ``0.15`` per image, where the scale is roughly a measure of how far
    the perspective transformation's corner points may be distanced from the
    image's corner points. Higher scale values lead to stronger "zoom-in"
    effects (and thereby stronger distortions).

    >>> aug = iaa.PerspectiveTransform(scale=(0.01, 0.15), keep_size=False)

    Same as in the previous example, but images are not resized back to
    the input image size after augmentation. This will lead to smaller
    output images.

    )rå  r   c                 ó<  •— t         t        | �  |||	|
¬«       t        j                  |dddd¬«      | _        t        j                  d| j
                  ¬«      | _        d| _        d| _	        t        |«      | _        | j                  |«      | _        || _        || _        || _        |d	k(  rt#        «       | _        t$        j&                  | _        t$        j*                  | _        t$        j.                  | _        t$        j.                  | _        d| _        d| _        y )
Nr1  rõ   r3  Tr>   r   r4  r   r$   )r7  rƒ  rû   r+   rC   rõ   r6  r-  Ú	min_widthÚ
min_heightrD   r=   rM   rK   Ú	keep_sizer  r8  r	   r%   rî  r<  rí  r=  rö  r>  r?  r@  rA  )rú   rõ   r=   rK   r‡  r  r8  rã   rV   rå   r2  rE  s              €r9   rû   zPerspectiveTransform.__init__Û  sþ   ø€ ô 	Ô" DÑ2Ø˜DØ%°]ð 	3ô 	Dô ×0Ñ0Ø�7¨	ÀDØô!ˆŒ
ô —j‘j Q¨d¯j©jÔ9ˆŒð ˆŒØˆŒä$ TÓ*ˆŒ	Ø×)Ñ)¨$Ó/ˆŒ	Ø"ˆŒØ$ˆŒà!2ˆÔØ Ò&Ü%=Ó%?ˆDÔ"ô  #×/Ñ/ˆÔÜ(+×(9Ñ(9ˆÔ%Ü!×1Ñ1ˆÔÜ'*×':Ñ':ˆÔ$ØˆÔØ'(ˆÕ$rE   c                 óþ  — t         j                  t         j                  g}ddg}|t        j                  k(  rt        j                  |«      S t        j                  |«      r.||v sJ dt        |«      |fz  «       ‚t        j                  |«      S t        j                  |«      r0||v sJ dt        |«      ›d|›d�«       ‚t        j                  |«      S t        |t        «      r×t        |D �cg c].  }t        j                  |«      xs t        j                  |«      ‘Œ0 c}«      }|s:J ddj                  |D �cg c]  }t        t        |«      «      ‘Œ c}«      ›d�«       ‚t        |D �cg c]	  }|||z   v ‘Œ c}«      }|s#J d	t        ||z   «      ›dt        |«      ›d�«       ‚t        j                  |«      S t        |t
        j                   «      r|S t#        d
t        |«      ›d�«      ‚c c}w c c}w c c}w )Nrå  r   rç  rè  rã  r(   ré  rG   rê  rë  )r%   rò  rö  r)   r*   r+   r,   r-   r2   r.   rI   r/   r0   r1   rJ   r3   r4   r5   )rM  rK   rû  rü  r8   rù  Úvalid_modess          r9   rM   z%PerspectiveTransform._handle_mode_arg  s  € ä×/Ñ/´×1DÑ1DÐEˆØ*¨JÐ7ÐØ”2—6‘6Š>Ü—:‘:˜oÓ.Ð.Ü×Ñ Ô%Ø˜?Ñ*ð 1Ø4Ü˜Ó(¨$ð80ñ 0ó1Ð*ô ×$Ñ$ TÓ*Ð*Ü�<‰<˜ÔØÐ.Ñ.ñ 5äÐ+Õ,ªdð4ó5Ð.ô ×$Ñ$ TÓ*Ð*Ü�dœDÔ!ÜÙ*.ó0Ù*. 3ô  "×3Ñ3°CÓ8ÒM¼B¿L¹LÈÓ<MÑMØ*.ñ0ó 1ˆKáñ Cð —I‘I¹Ó>¹°#œs¤4¨£9�~¸Ñ>Õ?ðBóC�;ô Ù*.ó0Ù*. 3ð  # oÐ8KÑ&KÒKØ*.ñ0ó 1ˆKáñ Lä˜Ð*=Ñ=Õ>ÄÀDÅ	ðKóL�;ô —:‘:˜dÓ#Ð#Ü�dœC×3Ñ3Ô4ØˆKÝô �T•
ðóð 	ùò0ùò
 ?ùò0s   Ã.3G0Ä;G5Å-G:c           	      óÀ  — |j                  «        | j                  |j                  «       |j                  «       «      }|j                  �!| j                  |j                  |«      |_        |j                  ��| j                  |j                  D �cg c]  }|j                  j                  ‘Œ c}|j                  «       «      }| j                  |j                  d||| j                  | j                  | j                  «      |_        |j                  ��| j                  |j                  D �cg c]  }|j                  j                  ‘Œ c}|j                  «       «      }| j                  |j                  d||| j                  | j                   | j"                  «      |_        |j$                  �Nt'        j(                  | j*                  |¬«      }| j-                  |j$                  || j.                  ¬«      |_        dD ]Q  }	t1        ||	«      }
|
€Œt'        j(                  | j*                  |¬«      }| j3                  |
|«      }t5        ||	|«       ŒS |S c c}w c c}w )Nr_  r_   )Úsamples_imagesr:  r<  )Úadvance_re  Úget_rowwise_shapesrÏ   rf  rg  rh  r_  rR   ri  r@  r>  r<  rj  r_   rA  r?  r=  rc  r=  r>  r?  r@  r8  rk  rA  rŽ  )rú   rr  rå   rs  rt  r‹  r’  ru  rB  rv  rw  rC  s               r9   r{  z$PerspectiveTransform._augment_batch_+  sC  € ð
 	×ÑÔà×+Ñ+¨E×,DÑ,DÓ,FØ,8×,=Ñ,=Ó,?óAˆð �<‰<Ð#Ø×:Ñ:¸5¿<¹<Ø;IóKˆEŒLð �>‰>Ð%Ø×(Ñ(à$)§N¢Nó4Ù$2�[ð ×%Ñ%×+Ó+Ø$2ñ4à×!Ñ!Ó#ó%ˆGð
 "×:Ñ:Ø—‘ 
¨G°^Ø×#Ñ# T×%8Ñ%8¸$×:NÑ:NóPˆEŒNð ×"Ñ"Ð.Ø×(Ñ(à$)×$;Ò$;ó=Ù$;�[ð —‘×&Ó&Ø$;ñ=à×!Ñ!Ó#ó%ˆGð
 '+×&CÑ&CØ×'Ñ'¨°¸Ø×,Ñ,¨d×.JÑ.JØ×-Ñ-ó'/ˆEÔ#ð �>‰>Ð%Ü×$Ñ$Ø×2Ñ2Ø-ô/ˆDð "×AÑAØ—‘ °×0FÑ0Fð Bó HˆEŒNó IˆIÜ  ¨	Ó2ˆJØÑ%Ü ×(Ñ(Ø×6Ñ6Ø#1ô3�ð ×;Ñ;¸JÈÓM�Ü˜˜y¨&Õ1ð Ið ˆùòM4ùò=s   ÂIÄ-Ic                 ó8  — t        j                  |g d¢g d¢| ¬«       |}| j                  st        |«      }t	        t        ||j                  |j                  |j                  |j                  |j                  «      «      }|D �]  \  }\  }}}}	}
}|j                  }|j                  dv r |j                  t        j                  «      }n-|j                  dv r|j                  t        j                   «      }|j"                  d   }|j$                  dk(  }|r|}në|dk  r]t'        j(                  t+        |«      ||	|f|
|¬	«      }|j,                  dk(  r²||   j,                  d
k(  r t        j.                  |d«      }n‰t1        j2                  |«      D �cg c]T  }t'        j(                  t+        |d|f   «      ||	|f|
t5        |t7        |
«      dz
  «         |t&        j8                  ¬«      ‘ŒV }}t        j:                  |d¬«      }| j                  r,|s*|j"                  dd \  }}t=        j>                  |||f«      }|j                  dk(  r|dkD  }n9|j                  j                  |j                  k7  rt        j@                  ||«      }|||<   �Œ |S c c}w )N)r   r   r   r   r   r   r   r   )rl   rn   ro   rp   r   rq   rr   rs   rt   ru   rv   rw   )r   )r   r   r   r   r   )rŽ   r�   r   .r
   ©rŽ   r�   rŒ   r‰   r�   r   r}   )!rS   r~   r‡  r0   rÐ   r‹  rƒ  r}  r~  r  r€  rU   rV   r‘   r‚   r   r   rR   r   r%   ÚwarpPerspectiver   r˜   Úexpand_dimsrš   r›   rZ   rQ   rî  rœ   r)   Úimresize_single_imager„   )rú   rf  ru  r¾   r•  r¿   r„  r`   Ú
max_heightÚ	max_widthr=   rK   r…   r�   Úhas_zero_sized_axisÚwarpedrž   rS  rT  s                      r9   rg  z/PerspectiveTransform._augment_images_by_samplesd  sx  € Ü×ÑØò6ò;ð õ		ð ˆØ�~Š~Ü˜&“\ˆFäœ˜F G×$4Ñ$4°g×6IÑ6IØ#×.Ñ.°·±¸w¿}¹}óNó Oˆô FIÑAˆAÑA��v˜z¨9°d¸DØŸ+™+ˆKØ×Ñ 8Ñ+ØŸ™¤R§X¡XÓ.‘Ø×!Ñ!Ð%8Ñ8ØŸ™¤R§Z¡ZÓ0�ð  Ÿ+™+ a™.ˆKØ#(§:¡:°¡?ÐÙ"Ø‘Ø Ò!Ü×,Ñ,Ü-¨eÓ4ØØ 
Ð+Ø $Ø#ô%�ð —;‘; !Ò#¨¨q©	¯©¸!Ò(;ÜŸ^™^¨F°AÓ6‘Fô  ŸY™Y {Ô3ó
ñ 4˜ô ×'Ñ'Ü1°%¸¸Q¸±-Ó@ØØ" JÐ/Ø$(¬¨Q´°D³	¸!±Ó)<Ñ$=Ø#'Ü!×.Ñ.öð 4ð ð 
ô Ÿ™ &¨rÔ2�à�~Š~Ñ&9Ø—{‘{ 1 QÐ'‘��1Ü×1Ñ1°&¸1¸a¸&ÓA�à×Ñ 6Ò)Ø #™‘Ø—‘×"Ñ" k×&6Ñ&6Ò6Ü×-Ñ-¨f°kÓB�àˆF�1‹Iða FIðd ˆùò1
s   ÆAJc                 ón  — |}| j                   r|j                  }	|j                  }
n|j                  }	|j                  }
t        t	        ||j
                  |j                  |j                  «      «      }|D �]5  \  }\  }}}}t        ||«      }|}|€|j                  |   }|}|€|j                  |   }|j                  d   }d|j                  v }|j                  dk(  }|rŒm|sot        j                  |«      D �cg c]-  }t        j                  t        |d|f   «      |||f|||¬«      ‘Œ/ }}t!        j"                  |d¬«      }t%        |||«       | j                   r&|j                  dd \  }}|j'                  ||f«      }n!|	|   |
|   f|j                  dd  z   }||_	        |||<   �Œ8 |S c c}w )Nr   r   .r�  r‰   r�   )r‡  r}  r~  rÐ   r‹  rƒ  rk  r€  r  rR   r   rš   r›   r%   r�  r   r‚   rœ   rŽ  Úresize)rú   r�  r�  ru  r‹  r=   rK   rŒ   r¾   Úmax_heights_imgsÚmax_widths_imgsr•  r¿   r–  r`   r“  r”  r_   Úmode_iÚcval_ir�   Úimage_has_zero_sized_axisÚmap_has_zero_sized_axisrž   r–  rS  rT  Ú	new_shapes                               r9   ri  z-PerspectiveTransform._augment_maps_by_samples¬  sî  € àˆð �>Š>Ø&×2Ñ2ÐØ%×0Ñ0‰Oà-×9Ñ9ÐØ,×7Ñ7ˆOäœ˜L¨'×*:Ñ*:¸G×<OÑ<OØ#×.Ñ.ó0ó 1ˆô BEÑ=ˆAÑ=�˜v z°9Ü˜-¨Ó7ˆCàˆFØˆ|Ø Ÿ™ qÑ)�àˆFØˆ|Ø Ÿ™ qÑ)�àŸ)™) A™,ˆKØ)*¨m×.AÑ.AÐ)AÐ%Ø'*§x¡x°1¡}Ð#â,Ù.ô "$§¡¨;Ô!7ó
ñ "8˜Aô ×+Ñ+Ü5°c¸#¸q¸&±kÓBØ"Ø&¨
Ð3Ø(.Ø'-Ø"'öð "8ð ð 
ô  ŸX™X f°2Ô6�Fä˜M¨=¸&ÔAà—>’>ØŸ9™9 Q q˜>‘D�A�qØ$1×$8Ñ$8¸!¸Q¸Ó$@‘Mð )¨Ñ+¨_¸QÑ-?ð!à%×+Ñ+¨A¨BÐ/ñ!0�Ið +4�MÔ'à)��q“	ðS BEðV ˆùò5
s   Ã=2F2c                 ó`  — |}t        t        ||j                  |j                  |j                  «      «      }|D ]ñ  \  }\  }}}}	d|j
                  v }
|
rŒ|j
                  }||	f|j
                  dd  z   }||_        |j                  s�|j                  «       }t        j                  t        j                  |gt        j                  ¬«      |«      }|d   }t        |j                  |«      D ]  \  }}|d   |_        |d   |_        Œ | j                   r|j#                  |«      }|||<   Œó |S )Nr   r   r‡  r
   )rÐ   r‹  rƒ  r}  r~  rR   rl  rn  r%   ÚperspectiveTransformr‚   r¢   r   ra  rÓ   rÔ   r‡  Úon_)rú   rR  r‹  r¾   r•  r¿   ry  r`   r“  r”  r�  Ú
shape_origÚ	shape_newÚkps_arrr–  r  rÑ   s                    r9   r?  z2PerspectiveTransform._augment_keypoints_by_samplesì  s&  € Øˆäœ˜FØ*×3Ñ3Ø*×6Ñ6Ø*×5Ñ5ó7ó 8ˆó
 :=Ñ5ˆAÑ5��v˜z¨9Ø)*¨e¯k©kÐ)9Ð%â,Ø"Ÿ[™[�
Ø'¨Ð3°e·k±kÀ!À"°oÑE�	Ø'�”Ø—{’{Ø#×/Ñ/Ó1�GÜ ×5Ñ5ÜŸ™ ' ´"·*±*Ô=¸vóG�Fà# A™Y�FÜ&)¨%¯/©/¸6Ö&B™
˜˜FØ% a™y˜œØ% a™y˜�ð 'Cð —>’>Ø!ŸI™I jÓ1�EØ!��q’	ð# :=ð& ˆrE   c                 ó	  — g }g }g }t        |«      }|j                  d«      }| j                  j                  |df|d   ¬«      }| j                  j                  |f|d   ¬«      }	| j
                  j                  |ddf|d   ¬«      }
|j                  «       }|	j                  j                  dvr*| j                  j                  «       D ]  \  }}||	|	|k(  <   Œ t        j                  t        j                  |
«      d«      }d|d d …ddf   z
  |d d …ddf<   d|d d …ddf   z
  |d d …ddf<   d|d d …ddf   z
  |d d …ddf<   d|d d …ddf   z
  |d d …ddf<   t        ||«      D �]ô  \  }}|dd \  }}|d d …dfxx   |z  cc<   |d d …dfxx   |z  cc<   | j                  |«      }|\  }}}}d }d }|�|| j                   k  ròt        j"                  |d   |d   z
  dz  |d   |d   z
  dz  z   «      }t        j"                  |d   |d   z
  dz  |d   |d   z
  dz  z   «      }t%        t'        ||«      «      }t%        t)        ||«      «      }|| j                   k  rF| j                   |z
  dz  }|dxx   |z  cc<   |dxx   |z  cc<   |dxx   |z  cc<   |dxx   |z  cc<   |€Œâ|| j                   k  rŒòd }d }|�|| j*                  k  ròt        j"                  |d   |d   z
  dz  |d   |d   z
  dz  z   «      }t        j"                  |d   |d   z
  dz  |d   |d   z
  dz  z   «      }t%        t'        ||«      «      }t%        t)        ||«      «      }|| j*                  k  rF| j*                  |z
  dz  }|dxx   |z  cc<   |dxx   |z  cc<   |dxx   |z  cc<   |dxx   |z  cc<   |€Œâ|| j*                  k  rŒòt        j,                  ddg|dg||gd|ggt        j.                  ¬	«      } t1        j2                  || «      }!| j4                  r| j7                  |!||f«      \  }!}}|j9                  |!«       |j9                  |«       |j9                  |«       �Œ÷ |	j;                  t        j<                  «      }	t?        |||||	«      S )
Nr   r   r�  r
   r   r   )r¿   Úur6  r‡  ) rQ   r   r=   r¡  rK   r-  r¤   rU   rG  Ú_BORDER_MODE_STR_TO_INTÚitemsr‚   Úmodr*  r‹  Ú_order_pointsr…  Úsqrtr^   rY   rZ   r†  r¢   r   r%   ÚgetPerspectiveTransformr  Ú_expand_transformr~  r‘   r   r{  )"rú   Úshapesrå   rƒ  r}  r~  r�  r£  r¨  r©  r-  Úcval_samples_cv2rK   Úmapped_modeÚpointsrR   Úpoints_irS  rT  ÚtlÚtrÚbrÚblr…  r”  Ú	width_topÚwidth_bottomÚ	step_sizer†  r“  Úheight_rightÚheight_leftÚdstÚms"                                     r9   re  z"PerspectiveTransform._draw_samples
  sä  € àˆØˆØˆ
Ü˜“Kˆ	Ø×%Ñ% aÓ(ˆà—y‘y×-Ñ-¨y¸!¨nØ;?À¹7ð .ó Dˆà—y‘y×-Ñ-¨y¨lØ;?À¹7ð .ó Dˆà—‘×)Ñ)¨9°a¸Ð*;Ø7;¸A±wð *ó @ˆð (×.Ñ.Ó0Ðð ×Ñ×"Ñ"¨*Ñ4Ø%)×%AÑ%A×%GÑ%GÖ%IÑ!��kØ5@�˜\¨TÑ1Ò2ð &Jô —‘œŸ™˜v›¨Ó*ˆð  ¢q¨!¨Q w¡Ñ/ˆŠq�!�Qˆw‰à ¢q¨!¨Q w¡Ñ/ˆŠq�!�Qˆw‰Ø ¢q¨!¨Q w¡Ñ/ˆŠq�!�Qˆw‰à ¢q¨!¨Q w¡Ñ/ˆŠq�!�Qˆw‰ä" 6¨6×2‰OˆE�8Ø˜˜1�:‰DˆAˆqà’Q˜�T‹N˜aÑ‹NØ’Q˜�T‹N˜aÑ‹Nð ×)Ñ)¨(Ó3ˆHØ'ÑˆR��R˜ð
 ˆIØˆIØÐ# y°4·>±>Ò'AÜŸG™G b¨¡e¨B¨q©E¡k°AÑ%5¸2¸a¹5ÀÀAÁ¹;ÈÑ:JÑ$KÓL�	Ü!Ÿw™w¨¨A©¨r°!©u©°qÑ(8¸bÀ¹eÀBÀqÁE¹kÈAÑ=MÑ'NÓO�Ü¤ I¨|Ó <Ó=�	Ü¤ I¨|Ó <Ó=�	Ø˜tŸ~™~Ò-Ø!%§¡°)Ñ!;¸QÑ >�IØ�q“E˜YÑ&“EØ�q“E˜YÑ&“EØ�q“E˜YÑ&“EØ�q“E˜YÑ&“Eð Ñ# y°4·>±>Ó'Að ˆJØˆJØÐ$¨
°T·_±_Ò(DÜ!Ÿw™w¨¨A©¨r°!©u©°qÑ(8¸bÀ¹eÀBÀqÁE¹kÈAÑ=MÑ'NÓO�Ü Ÿg™g¨¨1©¨b°©e©°aÑ'7¸RÀ¹UÀ2ÀaÁ5¹[È1Ñ<LÑ&MÓN�Ü ¤ \°;Ó!?Ó@�
Ü ¤ \°;Ó!?Ó@�
Ø §¡Ò/Ø!%§¡°:Ñ!=¸qÑ @�IØ�q“E˜YÑ&“EØ�q“E˜YÑ&“EØ�q“E˜YÑ&“EØ�q“E˜YÑ&“Eð Ñ$¨
°T·_±_Ó(Dô& —(‘(Ø�A�Ø˜A�Ø˜JÐ'Ø�J�ð	ô
 —Z‘Zô!ˆCô ×+Ñ+¨H°cÓ:ˆAà�ŠØ+/×+AÑ+AÀ!ÀaÈÀVÓ+LÑ(��9˜jà�O‰O˜AÔØ×Ñ˜zÔ*Ø×Ñ˜iÖ(ðK  3ðN $×*Ñ*¬2¯8©8Ó4ˆÜ2Ø�k :Ð/?Øóð 	rE   c                 óz  — t        j                  dt         j                  ¬«      }|j                  d¬«      }|t        j                  |«         |d<   |t        j
                  |«         |d<   t        j                  |d¬«      }|t        j                  |«         |d<   |t        j
                  |«         |d<   |S )N)r   r   r‡  r
   r�   r   r   r   )r‚   r
  r   r_  ÚargminÚargmaxÚdiff)rM  ÚptsÚpts_orderedÚpointwise_sumrÂ  s        r9   r«  z"PerspectiveTransform._order_points~  s�   € ô —h‘h˜v¬R¯Z©ZÔ8ˆð Ÿ™ Q˜›ˆØœRŸY™Y }Ó5Ñ6ˆ�A‰ØœRŸY™Y }Ó5Ñ6ˆ�A‰ô
 �w‰w�s Ô#ˆØœRŸY™Y t›_Ñ-ˆ�A‰ØœRŸY™Y t›_Ñ-ˆ�A‰ð ÐrE   c                 ó¦  — |\  }}t        j                  ddg|dg||gd|ggt         j                  ¬«      }t        j                  t        j                  |g«      |«      d   }||j                  dd¬«      z  }t        j                  |d¬«      }t        j                  ||«      }|j                  d¬«      \  }}	|t        |«      t        |	«      fS )Nr   r‡  T)r�   Úkeepdims)Údecimalsr�   )
r‚   r¢   r   r%   r¡  rZ   Úaroundr­  rY   r^   )
rM  r`   rR   r§   r¨   Úrectr½  Úmatrix_expandedr”  r“  s
             r9   r®  z&PerspectiveTransform._expand_transform—  sÍ   € à‰ˆ�ô �x‰xØ�ˆFØ�AˆJØ�FˆOØ�ˆKð	ô !#§
¡
ô	,ˆô
 ×&Ñ&¤r§x¡x°°Ó'7¸Ó@ÀÑCˆð
 	ˆs�w‰w˜A¨ˆwÓ-Ñ-ˆÜ�i‰i˜ aÔ(ˆä×5Ñ5°d¸CÓ@ˆØ #§¡¨Q £Ñˆ	�:Ø¤ I£´°J³Ð?Ð?rE   c                 ót   — | j                   | j                  | j                  | j                  | j                  gS r¬  )r-  r‡  r=   rK   r  r"  s    r9   r­  z#PerspectiveTransform.get_parameters­  s,   € à—‘˜TŸ^™^¨T¯Y©Y¸¿	¹	Ø—‘ð!ð 	!rE   )
)r#  g¸…ëQ¸®?r   r   TFr$   NNr®  r®  )r$  r%  r&  r°  r%   rò  rö  r¨  rû   r±  rM   r{  rg  ri  r?  re  r«  r®  r­  r²  r³  s   @r9   rƒ  rƒ  -  sž   ø„ ñfðR ×)Ñ)Ø×'Ñ'ñÐð
 8BØEKØ!%Ø:Fõ')ðV ñ!ó ð!òH6òrEòP=ò@ò<rðh ñó ðð0 ñ@ó ð@ö*!rE   rƒ  c                   ó   — e Zd Zd„ Zy)Ú$_ElasticTransformationSamplingResultc                 óX   — || _         || _        || _        || _        || _        || _        y ró   )Úrandom_statesÚalphasÚsigmasÚordersr  r€  )rú   rÐ  rÑ  rÒ  rÓ  r  r€  s          r9   rû   z-_ElasticTransformationSamplingResult.__init__´  s-   € Ø*ˆÔØˆŒØˆŒØˆŒØˆŒ
Øˆ�
rE   Nr�  r'  rE   r9   rÎ  rÎ  ³  s   „ órE   rÎ  c                   óž  ‡ — e Zd ZdZdZdZdZdZej                  ej                  ej                  ej                  dœZej                  ej                  ej                   ej                   ej                   ej                   dœZ	 	 	 	 	 dˆ fd„	Zed„ «       Zed	„ «       Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zedd„«       Z ˆ xZ!S )ÚElasticTransformationad"  
    Transform images by moving pixels locally around using displacement fields.

    The augmenter has the parameters ``alpha`` and ``sigma``. ``alpha``
    controls the strength of the displacement: higher values mean that pixels
    are moved further. ``sigma`` controls the smoothness of the displacement:
    higher values lead to smoother patterns -- as if the image was below water
    -- while low values will cause indivdual pixels to be moved very
    differently from their neighbours, leading to noisy and pixelated images.

    A relation of 10:1 seems to be good for ``alpha`` and ``sigma``, e.g.
    ``alpha=10`` and ``sigma=1`` or ``alpha=50``, ``sigma=5``. For ``128x128``
    a setting of ``alpha=(0, 70.0)``, ``sigma=(4.0, 6.0)`` may be a good
    choice and will lead to a water-like effect.

    Code here was initially inspired by
    https://gist.github.com/chsasank/4d8f68caf01f041a6453e67fb30f8f5a

    For a detailed explanation, see ::

        Simard, Steinkraus and Platt
        Best Practices for Convolutional Neural Networks applied to Visual
        Document Analysis
        in Proc. of the International Conference on Document Analysis and
        Recognition, 2003

    .. note::

        For coordinate-based inputs (keypoints, bounding boxes, polygons,
        ...), this augmenter still has to perform an image-based augmentation,
        which will make it significantly slower for such inputs than other
        augmenters. See :ref:`performance`.

    **Supported dtypes**:

        * ``uint8``: yes; fully tested (1)
        * ``uint16``: yes; tested (1)
        * ``uint32``: yes; tested (2)
        * ``uint64``: limited; tested (3)
        * ``int8``: yes; tested (1) (4) (5)
        * ``int16``: yes; tested (4) (6)
        * ``int32``: yes; tested (4) (6)
        * ``int64``: limited; tested (3)
        * ``float16``: yes; tested (1)
        * ``float32``: yes; tested (1)
        * ``float64``: yes; tested (1)
        * ``float128``: no
        * ``bool``: yes; tested (1) (7)

        - (1) Always handled by ``cv2``.
        - (2) Always handled by ``scipy``.
        - (3) Only supported for ``order != 0``. Will fail for ``order=0``.
        - (4) Mapped internally to ``float64`` when ``order=1``.
        - (5) Mapped internally to ``int16`` when ``order>=2``.
        - (6) Handled by ``cv2`` when ``order=0`` or ``order=1``, otherwise by
              ``scipy``.
        - (7) Mapped internally to ``float32``.

    Parameters
    ----------
    alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Strength of the distortion field. Higher values mean that pixels are
        moved further with respect to the distortion field's direction. Set
        this to around 10 times the value of `sigma` for visible effects.

            * If number, then that value will be used for all images.
            * If tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the interval ``[a, b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``StochasticParameter``, then that parameter will be used to
              sample a value per image.

    sigma : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Standard deviation of the gaussian kernel used to smooth the distortion
        fields. Higher values (for ``128x128`` images around 5.0) lead to more
        water-like effects, while lower values (for ``128x128`` images
        around ``1.0`` and lower) lead to more noisy, pixelated images. Set
        this to around 1/10th of `alpha` for visible effects.

            * If number, then that value will be used for all images.
            * If tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the interval ``[a, b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``StochasticParameter``, then that parameter will be used to
              sample a value per image.

    order : int or list of int or imaug.ALL or imgaug.parameters.StochasticParameter, optional
        Interpolation order to use. Same meaning as in
        :func:`scipy.ndimage.map_coordinates` and may take any integer value
        in the range ``0`` to ``5``, where orders close to ``0`` are faster.

            * If a single int, then that order will be used for all images.
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the interval ``[a, b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``imgaug.ALL``, then equivalant to list
              ``[0, 1, 2, 3, 4, 5]``.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the order value to use.

    cval : number or tuple of number or list of number or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        The constant intensity value used to fill in new pixels.
        This value is only used if `mode` is set to ``constant``.
        For standard ``uint8`` images (value range ``0`` to ``255``), this
        value may also should also be in the range ``0`` to ``255``. It may
        be a ``float`` value, even for images with integer dtypes.

            * If this is a single number, then that value will be used
              (e.g. ``0`` results in black pixels).
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the interval ``[a, b]``.
            * If a list, then a random value will be picked from that list per
              image.
            * If ``imgaug.ALL``, a value from the discrete range ``[0..255]``
              will be sampled per image.
            * If a ``StochasticParameter``, a new value will be sampled from
              the parameter per image.

    mode : str or list of str or imgaug.ALL or imgaug.parameters.StochasticParameter, optional
        Parameter that defines the handling of newly created pixels.
        May take the same values as in :func:`scipy.ndimage.map_coordinates`,
        i.e. ``constant``, ``nearest``, ``reflect`` or ``wrap``.

            * If a single string, then that mode will be used for all images.
            * If a list of strings, then per image a random mode will be picked
              from that list.
            * If ``imgaug.ALL``, then a random mode from all possible modes
              will be picked.
            * If ``StochasticParameter``, then the mode will be sampled from
              that parameter per image, i.e. it must return only the above
              mentioned strings.

    polygon_recoverer : 'auto' or None or imgaug.augmentables.polygons._ConcavePolygonRecoverer, optional
        The class to use to repair invalid polygons.
        If ``"auto"``, a new instance of
        :class`imgaug.augmentables.polygons._ConcavePolygonRecoverer`
        will be created.
        If ``None``, no polygon recoverer will be used.
        If an object, then that object will be used and must provide a
        ``recover_from()`` method, similar to
        :class:`~imgaug.augmentables.polygons._ConcavePolygonRecoverer`.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.ElasticTransformation(alpha=50.0, sigma=5.0)

    Apply elastic transformations with a strength/alpha of ``50.0`` and
    smoothness of ``5.0`` to all images.

    >>> aug = iaa.ElasticTransformation(alpha=(0.0, 70.0), sigma=5.0)

    Apply elastic transformations with a strength/alpha that comes
    from the interval ``[0.0, 70.0]`` (randomly picked per image) and
    with a smoothness of ``5.0``.

    r   r6  gš™™™™™©?©r   rß  r!   r"   ©r   r
   r   r   r   r'   c                 ó²  •— t         t        | �  |||	|
¬«       t        j                  |dddd¬«      | _        t        j                  |dddd¬«      | _        | j                  |«      | _        t        |«      | _
        | j                  |«      | _        || _        |dk(  rt        «       | _        d| _        d	| _        d
| _        d
| _        d| _        d	| _        y )Nr1  Úalphar3  Tr>   Úsigmar$   r   r   r   r#  )r7  rÕ  rû   r+   rC   rÙ  rÚ  r:   r6   rD   r=   rM   rK   r8  r	   r<  r=  r>  r?  r@  rA  )rú   rÙ  rÚ  r6   r=   rK   r8  rã   rV   rå   r2  rE  s              €r9   rû   zElasticTransformation.__init__Š  sä   ø€ ô
 	Ô# TÑ3Ø˜DØ%°]ð 	4ô 	Dô ×0Ñ0Ø�7¨	ÀDØô!ˆŒ
ô ×0Ñ0Ø�7¨	ÀDØô!ˆŒ
ð ×+Ñ+¨EÓ2ˆŒ
Ü$ TÓ*ˆŒ	Ø×)Ñ)¨$Ó/ˆŒ	à!2ˆÔØ Ò&Ü%=Ó%?ˆDÔ"ð  !ˆÔØ()ˆÔ%Ø(ˆÔØ'1ˆÔ$Ø!ˆÔØ'(ˆÕ$rE   c                 óŒ   — |t         j                  k(  rt        j                  g d¢«      S t        j                  |ddddd¬«      S )Nr×  r6   )r   r'   TFrU  )r)   r*   r+   r,   rX  )rM  r6   s     r9   r:   z'ElasticTransformation._handle_order_arg¯  s>   € à”B—F‘FŠ?Ü—:‘:Ò0Ó1Ð1Ü×(Ñ(Ø�7¨ÀØ¨eô5ð 	5rE   c                 óF  — |t         j                  k(  rt        j                  g d¢«      S t        j                  |«      rt        j
                  |«      S t        j                  |«      r{t        |D �cg c]  }t        j                  |«      ‘Œ c}«      s:J ddj                  |D �cg c]  }t        t        |«      «      ‘Œ c}«      ›d�«       ‚t        j                  |«      S t        |t        j                  «      r|S t        dt        |«      ›d�«      ‚c c}w c c}w )NrÖ  z6Expected mode list to only contain strings, got types rG   r(   rH   )r)   r*   r+   r,   rI   r.   Úis_iterabler1   rJ   r2   r3   r/   r4   r5   )rM  rK   r8   s      r9   rM   z&ElasticTransformation._handle_mode_arg·  sé   € à”2—6‘6Š>Ü—:‘:ÒHÓIÐIÜ�<‰<˜ÔÜ×$Ñ$ TÓ*Ð*Ü�>‰>˜$ÔÜ±TÓ:±T¨cœŸ™ SÕ)°TÑ:Ô;ñ Cð —I‘I¹Ó>¹°#œs¤4¨£9�~¸Ñ>Õ?ðBóCÐ;ô —:‘:˜dÓ#Ð#Ü�dœC×3Ñ3Ô4ØˆKÝä15°dµð>ó?ð 	?ùò ;ùò ?s   Á3DÂ'Dc                 óš  — |j                  |dz   «      }| j                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }| j
                  j                  |f|d   ¬«      }| j                  j                  |f|d   ¬«      }t        |dd |||||«      S )	Nr'   r[  r�  r\  r]  r^  r‰   r   )r   rÙ  r¡  rÚ  r6   r=   rK   rÎ  )	rú   r�  rå   r`  rÑ  rÒ  rÓ  r  r€  s	            r9   re  z#ElasticTransformation._draw_samplesÉ  sÑ   € Ø×$Ñ$ Y¨q¡[Ó1ˆØ—‘×(Ñ(¨)¨ÀCÈÁGÐ(ÓLˆØ—‘×(Ñ(¨)¨ÀCÈÁGÐ(ÓLˆØ—‘×(Ñ(¨)¨ÀCÈÁGÐ(ÓLˆØ—	‘	×&Ñ&¨	 |À#ÀbÁ'Ð&ÓJˆØ—	‘	×&Ñ&¨	 |À#ÀbÁ'Ð&ÓJˆÜ3Ø��"ˆI�v˜v v¨u°eó=ð 	=rE   c                 ó6  — |j                   �'t        j                  |j                   g d¢g d¢| ¬«       |j                  «       }| j	                  t        |«      |«      }t        |«      D �]+  \  }}| j                  |dd |j                  |   |j                  |   |j                  |   ¬«      \  }	}
|j                   �/| j                  |j                   |   |||	|
«      |j                   |<   |j                  �Q| j                  |j                  |   |||	|
d| j                  | j                  | j                   «	      |j                  |<   |j"                  �Q| j                  |j"                  |   |||	|
d| j$                  | j&                  | j(                  «	      |j"                  |<   |j*                  �/| j-                  |j*                  |   |||	|
«      |j*                  |<   |j.                  �/| j1                  |j.                  |   |||	|
«      |j.                  |<   |j2                  �/| j5                  |j2                  |   |||	|
«      |j2                  |<   |j6                  €�Œý| j9                  |j6                  |   |||	|
«      |j6                  |<   �Œ. |S )	N)r   r   r   rl   rn   r   r   r   rq   r   r   r   )ro   rp   rr   rs   rt   ru   rv   rw   r   r   )rÙ  rÚ  rå   r_  r_   )rf  rS   r~   r�  re  rQ   rÐ   Ú_generate_shift_mapsrÑ  rÒ  rÐ  Ú_augment_image_by_samplesrh  Ú_augment_hm_or_sm_by_samplesr@  r>  r<  rj  rA  r?  r=  ra  Ú_augment_kpsoi_by_samplesrb  Ú_augment_bbsoi_by_samplesrc  Ú_augment_psoi_by_samplesrd  Ú_augment_lsoi_by_samples)rú   rr  rå   rs  rt  r¯  ru  r¿   rR   ÚdxÚdys              r9   r{  z%ElasticTransformation._augment_batch_Ô  s‰  € à�<‰<Ð#Ü×ÑØ—‘ò:ò?ð õ	 ð ×)Ñ)Ó+ˆØ×$Ñ$¤S¨£[°,Ó?ˆä! &×)‰HˆAˆuØ×.Ñ.Ø�a˜�
Ø—n‘n QÑ'Ø—n‘n QÑ'Ø$×2Ñ2°1Ñ5ð	 /ó 7‰FˆB�ð �|‰|Ð'Ø"&×"@Ñ"@Ø—L‘L ‘O Q¨°°Ró#9�—‘˜Q‘à�~‰~Ð)Ø$(×$EÑ$EØ—N‘N 1Ñ% q¨'°2°r¸:Ø×'Ñ'¨×)<Ñ)<Ø×(Ñ(ó%*�—‘˜qÑ!ð ×&Ñ&Ð2Ø-1×-NÑ-NØ×+Ñ+¨AÑ.°°7¸BÀÀEØ×0Ñ0°$×2NÑ2NØ×1Ñ1ó.3�×'Ñ'¨Ñ*ð �‰Ð*Ø%)×%CÑ%CØ—O‘O AÑ&¨¨7°B¸ó&<�—‘ Ñ"à×#Ñ#Ð/Ø*.×*HÑ*HØ×(Ñ(¨Ñ+¨Q°¸¸Ró+A�×$Ñ$ QÑ'à�~‰~Ð)Ø$(×$AÑ$AØ—N‘N 1Ñ% q¨'°2°ró%;�—‘˜qÑ!à×!Ñ!Ò-Ø(,×(EÑ(EØ×&Ñ& qÑ)¨1¨g°r¸2ó)?�×"Ñ" 1Ó%ð= *ðB ˆrE   c           	      óî  — t        j                  |j                  «      \  }}}t        t	        |j
                  |   |«      |«      }	|j                  }
|j                  j                  dk(  r|j                  t        j                  «      }| j                  ||||j                  |   |	|j                  |   ¬«      }|j                  j                  |
j                  k7  rt        j                  ||
«      }|S )Nr   ©r6   r=   rK   )rS   rT   rU   rY   rZ   r  rV   r‘   r‚   r   Ú_map_coordinatesrÓ  r€  r„   )rú   r„  Úrow_idxru  rç  rè  ra   rb   rc   r=   r…   Ú	image_augs               r9   rá  z/ElasticTransformation._augment_image_by_samples	  sÓ   € ô ×)Ñ)¨%¯+©+Ó6ñ 	,ˆ	�= )ä”3�w—}‘} WÑ-¨yÓ9¸9ÓEˆà—k‘kˆØ�;‰;×Ñ˜yÒ(Ø—L‘L¤§¡Ó,ˆEà×)Ñ)Ø�2�rØ—.‘. Ñ)ØØ—‘˜wÑ'ð	 *ó )ˆ	ð �;‰;×Ñ˜{×/Ñ/Ò/Ü×,Ñ,¨Y¸ÓDˆIØÐrE   c
                 óà  — |�|n|j                   |   }|�|n|j                  |   }|	�|	n|j                  |   }	t        ||«      }
|
j                  dd |j                  dd k(  r^| j                  |
|||	||¬«      }|	dk\  r3t        |t        j                  «      rt        j                  |dd|¬«      }t        |||«       |S |
j                  dd \  }}|j                  |j                  dd «      }t        ||«      }
| j                  |
|||	||¬«      }|	dk\  r3t        |t        j                  «      rt        j                  |dd|¬«      }t        |||«       |j                  ||f«      }|S )Nr   r   rê  r   r#  r6  rˆ  )r  r€  rÓ  rk  rR   rë  r/   r)   rŒ  r‚   r�  rŽ  r˜  )rú   r’  rì  ru  rç  rè  r�  r=   rK   r6   r_   rJ  Úheight_origÚ
width_origs                 r9   râ  z2ElasticTransformation._augment_hm_or_sm_by_samples  sŠ  € ð Ð'‰t¨W¯]©]¸7Ñ-CˆØÐ'‰t¨W¯]©]¸7Ñ-CˆØÐ*‘°·±¸wÑ0Gˆô �k =Ó1ˆà�9‰9�Q�qˆ>˜[×.Ñ.¨q°Ð3Ò3Ø×.Ñ.Ø�R˜ 5¨t¸$ð /ó @ˆJð
 ˜Šzœj¨´b×6HÑ6HÔIÜŸW™W Z°°c¸zÔJ�
ä�K °
Ô;ð: Ðð- '*§i¡i°°! nÑ#ˆK˜Ø%×,Ñ,¨[×->Ñ->¸qÀÐ-CÓDˆKÜ˜+ }Ó5ˆCð ×.Ñ.Ø�R˜ 5¨t¸$ð /ó @ˆJð
 ˜Šzœj¨´b×6HÑ6HÔIÜŸW™W Z°°c¸zÔJ�
ä�K °
Ô;à%×,Ñ,¨k¸:Ð-FÓGˆKàÐrE   c           	      óî  — |j                   dd \  }}|j                  |   }|j                  |   }	d|j                   v }
|| j                  k  xs |	| j                  k  }|j
                  s|
s|r|S |j                  D �]ô  }d|j                  cxk  xr |k  nc xr d|j                  cxk  xr |k  nc }|sŒ=|j                  | j                  | j                  d¬«      }t        j                  |d d …df   «      j                  t        j                  «      }t        j                  |d d …df   «      j                  t        j                  «      }t        j                   t        j                   d|k  ||k  «      t        j                   d|k  ||k  «      «      }||   }||   }t        j"                  |d d …t        j$                  f   |d d …t        j$                  f   gd¬«      }t        j&                  |«      j                  t        j(                  «      }|d d …dfxx   |||f   z  cc<   |d d …dfxx   |||f   z  cc<   t+        j,                  |«      }|d   |_        |d   |_        �Œ÷ |S )Nr   r   T)Úreturn_arrayr
   r�   )rR   rÑ  rÒ  ÚKEYPOINT_AUG_ALPHA_THRESHÚKEYPOINT_AUG_SIGMA_THRESHrl  ra  rÓ   rÔ   Ú!generate_similar_points_manhattanÚNB_NEIGHBOURING_KEYPOINTSÚNEIGHBOURING_KEYPOINTS_DISTANCEr‚   r’   r‘   r   Úlogical_andÚconcatenater™   rÏ   r   r)   Úcompute_geometric_median)rú   ry  rì  ru  rç  rè  r§   r¨   rÙ  rÚ  Úimage_has_zero_sized_axesÚparams_below_threshr  Úwithin_image_planeÚkp_neighborhoodÚxxÚyyÚinside_image_maskÚxxyyÚxxyy_augÚmeds                        r9   rã  z/ElasticTransformation._augment_kpsoi_by_samplesT  s9  € àŸ™ A aÐ(‰ˆ�Ø—‘˜wÑ'ˆØ—‘˜wÑ'ˆð &'¨%¯+©+Ð%5Ð!à�T×3Ñ3Ñ3ò 7Ø˜×6Ñ6Ñ6ð 	ð �;Š;Ñ3Ñ7Jð ˆLà—/•/ˆBØ"# r§t¡tÖ"3¨eÔ"3Ò"J¸¸R¿T¹TÖ8JÀFÔ8JÐÚ!Ø"$×"FÑ"FØ×2Ñ2Ø×8Ñ8Ø!%ð #Gó #�ô —X‘X˜oªa°¨dÑ3Ó4×;Ñ;¼B¿H¹HÓE�Ü—X‘X˜oªa°¨dÑ3Ó4×;Ñ;¼B¿H¹HÓE�Ü$&§N¡NÜ—N‘N 1¨¡7¨B°©JÓ7Ü—N‘N 1¨¡7¨B°©KÓ8ó%Ð!ð Ð)Ñ*�ØÐ)Ñ*�ä—~‘~Øšœ2Ÿ:™:˜Ñ&¨ª1¬b¯j©j¨=Ñ(9Ð:Øô�ô Ÿ7™7 4›=×/Ñ/´·
±
Ó;�Øš˜A˜“ " R¨ V¡*Ñ,“Øš˜A˜“ " R¨ V¡*Ñ,“ä×1Ñ1°(Ó;�ð ˜1‘v�”Ø˜1‘v�–ðI "ðL ˆrE   c                 ó†   — t        j                  | j                  ||||¬«      }| j                  ||| j                  ¬«      S )N©rì  ru  rç  rè  r:  )r=  r>  rã  r@  r8  )rú   Úpsoirì  ru  rç  rè  rB  s          r9   rå  z.ElasticTransformation._augment_psoi_by_samples“  sI   € ä× Ñ  ×!?Ñ!?Ø)0¸'ÀbÈRôQˆà×3Ñ3Ø�$ $×"8Ñ"8ð 4ó :ð 	:rE   c                 ón   — t        j                  | j                  ||||¬«      }| j                  ||«      S ©Nr  ©r=  r>  rã  rA  )rú   Úlsoirì  ru  rç  rè  rB  s          r9   ræ  z.ElasticTransformation._augment_lsoi_by_samples›  s7   € ä× Ñ  ×!?Ñ!?Ø)0¸'ÀbÈRôQˆà×1Ñ1°$¸Ó=Ð=rE   c                 ón   — t        j                  | j                  ||||¬«      }| j                  ||«      S r	  r
  )rú   Úbbsoirì  ru  rç  rè  rB  s          r9   rä  z/ElasticTransformation._augment_bbsoi_by_samples¢  s7   € ä× Ñ  ×!?Ñ!?Ø)0¸'ÀbÈRôQˆà×1Ñ1°%¸Ó>Ð>rE   c                 ót   — | j                   | j                  | j                  | j                  | j                  gS r¬  )rÙ  rÚ  r6   r=   rK   r"  s    r9   r­  z$ElasticTransformation.get_parameters¨  s'   € à—
‘
˜DŸJ™J¨¯
©
°D·I±I¸t¿y¹yÐIÐIrE   c                 ó¾  — t        |«      dk(  sJ d|›d�«       ‚t        j                  |«      }|dz  dk(  r|dz   n|}|}|dd \  }}|d|z  z   }	|d|z  z   }
|j                  d|	z  |
f«      dz  dz
  }|d|	…d d …f   }||	d …d d …f   }t        j                  ||«      |z  }t        j                  ||«      |z  }|dkD  r||| …|| …f   }||| …|| …f   }||fS )Nr   zExpected 2d shape, got r(   r   r
   )rQ   Úblur_libÚ_compute_gaussian_blur_ksizer   Úblur_gaussian_)rM  rR   rÙ  rÚ  rå   ÚksizeÚpaddingrS  rT  Úh_padÚw_padÚdxdy_unsmoothedÚdx_unsmoothedÚdy_unsmoothedrç  rè  s                   r9   rà  z*ElasticTransformation._generate_shift_maps¬  s0  € ô �5‹z˜QŠÑIÂÐ!HÓIˆä×5Ñ5°eÓ<ˆØ" Q™Y¨!š^�˜’	°ˆàˆØ�Q�qˆz‰ˆˆ1Ø�A�g‘I‘ˆØ�A�g‘I‘ˆð
 '×-Ñ-¨q°5©y¸%Ð.@ÓAÀAÑEÈÑIˆà'¨¨%¨²¨
Ñ3ˆØ'¨©²¨	Ñ2ˆô ×$Ñ$ ]°EÓ:¸UÑBˆÜ×$Ñ$ ]°EÓ:¸UÑBˆà�QŠ;Ø�G˜W˜HÐ$ g¨w¨hÐ&6Ð6Ñ7ˆBØ�G˜W˜HÐ$ g¨w¨hÐ&6Ð6Ñ7ˆBà�2ˆvˆrE   c           
      ó¶  — |j                   dk(  rt        j                  |«      S |dk(  r<|j                  j                  dv r$t        d||j                  j                  fz  «      ‚|j                  }|j                  j                  dk(  r |j                  t        j                  «      }n¸|dk(  r8|j                  j                  dv r |j                  t        j                  «      }n{|dk\  r9|j                  j                  dk(  r |j                  t        j                  «      }n=|dk\  r8|j                  j                  d	k(  r|j                  t        j                  «      }d
}d}	|dk(  r|j                  j                  dv }
n6|dk(  r|j                  j                  dv }
n|j                  j                  dv }
|j                  d   |k\  xs |j                  d   |k\  }|j                  d   |k\  xs |j                  d   |k\  }|
s|s|rd}	|j                  dk(  sJ d|j                  fz  «       ‚t        j                  |«      }|j                  dd \  }}|	dk(  �r'|j                  dd \  }}t        j                  t        j                  |«      j                  t        j                  «      t        j                  |«      j                  t        j                  «      d¬«      \  }}|d|z  z   }|d|z  z   }t        j                  |j                  d   «      D ]c  }t         j"                  j%                  |d|f   |j'                  «       |j'                  «       f|||¬«      }|j)                  ||f«      }||d|f<   Œe �n|j                  \  }}}t        j                  t        j                  |«      j                  t        j                  «      t        j                  |«      j                  t        j                  «      d¬«      \  }}|d|z  z   }|d|z  z   }|j                  j*                  dk(  rt-        |«      }nt/        |«      }| j0                  |   }| j2                  |   }|t4        j6                  k(  }t5        j8                  ||t4        j:                  |¬«      \  }}|dk  r[t5        j<                  t?        |«      |||||||f¬«      }|j                  dk(  r¸|j                  dk(  r©|dt        j@                  f   }n“d}g }||k  rs|d||dz   …f   } t5        j<                  t?        | «      |||||||f¬«      }!|!j                  dk(  r|!dt        j@                  f   }!|jC                  |!«       |dz  }||k  rŒst        jD                  |d¬«      }|j                  j                  |j                  k7  rtG        jH                  ||«      }|S )a@  Remap pixels in an image according to x/y shift maps.

        **Supported dtypes**:

        if (backend="scipy" and order=0):

            * ``uint8``: yes
            * ``uint16``: yes
            * ``uint32``: yes
            * ``uint64``: no (1)
            * ``int8``: yes
            * ``int16``: yes
            * ``int32``: yes
            * ``int64``: no (2)
            * ``float16``: yes
            * ``float32``: yes
            * ``float64``: yes
            * ``float128``: no (3)
            * ``bool``: yes

            - (1) produces array filled with only 0
            - (2) produces array filled with <min_value> when testing
                  with <max_value>
            - (3) causes: 'data type no supported'

        if (backend="scipy" and order>0):

            * ``uint8``: yes (1)
            * ``uint16``: yes (1)
            * ``uint32``: yes (1)
            * ``uint64``: yes (1)
            * ``int8``: yes (1)
            * ``int16``: yes (1)
            * ``int32``: yes (1)
            * ``int64``: yes (1)
            * ``float16``: yes (1)
            * ``float32``: yes (1)
            * ``float64``: yes (1)
            * ``float128``: no (2)
            * ``bool``: yes

            - (1) rather loose test, to avoid having to re-compute the
                  interpolation
            - (2) causes: 'data type no supported'

        if (backend="cv2" and order=0):

            * ``uint8``: yes
            * ``uint16``: yes
            * ``uint32``: no (1)
            * ``uint64``: no (2)
            * ``int8``: yes
            * ``int16``: yes
            * ``int32``: yes
            * ``int64``: no (2)
            * ``float16``: yes
            * ``float32``: yes
            * ``float64``: yes
            * ``float128``: no (3)
            * ``bool``: no (4)

            - (1) causes: src data type = 6 is not supported
            - (2) silently converts to int32
            - (3) causes: src data type = 13 is not supported
            - (4) causes: src data type = 0 is not supported

        if (backend="cv2" and order=1):

            * ``uint8``: yes
            * ``uint16``: yes
            * ``uint32``: no (1)
            * ``uint64``: no (2)
            * ``int8``: no (2)
            * ``int16``: no (2)
            * ``int32``: no (2)
            * ``int64``: no (2)
            * ``float16``: yes
            * ``float32``: yes
            * ``float64``: yes
            * ``float128``: no (3)
            * ``bool``: no (4)

            - (1) causes: src data type = 6 is not supported
            - (2) causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805:
                  error: (-215:Assertion failed) ifunc != 0 in function
                  'remap'
            - (3) causes: src data type = 13 is not supported
            - (4) causes: src data type = 0 is not supported

        if (backend="cv2" and order>=2):

            * ``uint8``: yes
            * ``uint16``: yes
            * ``uint32``: no (1)
            * ``uint64``: no (2)
            * ``int8``: no (2)
            * ``int16``: yes
            * ``int32``: no (2)
            * ``int64``: no (2)
            * ``float16``: yes
            * ``float32``: yes
            * ``float64``: yes
            * ``float128``: no (3)
            * ``bool``: no (4)

            - (1) causes: src data type = 6 is not supported
            - (2) causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805:
                  error: (-215:Assertion failed) ifunc != 0 in function
                  'remap'
            - (3) causes: src data type = 13 is not supported
            - (4) causes: src data type = 0 is not supported

        r   )rn   rq   zldtypes uint64 and int64 are only supported in ElasticTransformation for order=0, got order=%d with dtype=%s.r   r
   )r   r   r   r   r   r   éÿ  r%   )rl   rn   rq   ru   r   )rl   rn   r   r   r   rq   ru   r   )rl   rn   r   r   rq   ru   r   Úscipyr   z0Expected 3-dimensional image, got %d dimensions.Úij)Úindexingr‰   .rê  Úf)Únninterpolationr   )Úinterpolationr�   rŽ   r�   )%r   r‚   rÏ   rU   rV   r5   r‘   r   r   r   rR   r˜   rj  r¶   rš   r›   r   r!  Úmap_coordinatesr´   rá   rG  Úfloatr^   Ú_MAPPING_MODE_SCIPY_CV2Ú_MAPPING_ORDER_SCIPY_CV2r%   rí  ÚconvertMapsÚCV_16SC2Úremapr   r™   r~  rù  rS   r„   )"rM  r„  rç  rè  r6   r=   rK   r…   Úshrt_maxr7   Úbad_dtype_cv2Úbad_dx_shape_cv2Úbad_dy_shape_cv2r¾   r§   r¨   rS  rT  rÔ   rÓ   Ú	x_shiftedÚ	y_shiftedrž   Úremapped_flatÚremappedr�   Úborder_moder!  Úis_nearest_neighbourÚmap1Úmap2Úcurrent_chan_idxÚchannelsÚresult_cs"                                     r9   rë  z&ElasticTransformation._map_coordinatesÌ  sM  € ðh �:‰:˜Š?Ü—7‘7˜5“>Ð!à�AŠ:˜%Ÿ+™+×*Ñ*Ð.AÑAÜðà$ e§k¡k×&6Ñ&6Ð7ñ8ó9ð 9ð
 —k‘kˆØ�;‰;×Ñ˜vÒ%Ø—L‘L¤§¡Ó,‰EØ�aŠZ˜EŸK™K×,Ñ,Ð0JÑJØ—L‘L¤§¡Ó,‰EØ�aŠZ˜EŸK™K×,Ñ,°Ò6Ø—L‘L¤§¡Ó*‰EØ�aŠZ˜EŸK™K×,Ñ,°Ò7Ø—L‘L¤§¡Ó,ˆEàˆØˆØ�AŠ:à—‘× Ñ ð %ð ñ ð �aŠZà—‘× Ñ ð %ð ñ ð —‘× Ñ ð %ð ð ð ŸH™H Q™K¨8Ñ3ÒN°r·x±xÀ±{ÀhÑ7NÐØŸH™H Q™K¨8Ñ3ÒN°r·x±xÀ±{ÀhÑ7NÐÙÑ,Ñ0@ØˆGà�z‰z˜QŠð 	PØ>À%Ç*Á*ÀÑNó	Pˆä—‘˜“ˆØŸ™ A aÐ(‰ˆ�Ø�gÓØ—;‘;˜q Ð#‰DˆAˆqÜ—;‘;Ü—	‘	˜!“×#Ñ#¤B§J¡JÓ/Ü—	‘	˜!“×#Ñ#¤B§J¡JÓ/Øô‰DˆAˆqð ˜R 2™I™ˆIØ˜R 2™I™ˆIä—Y‘Y˜uŸ{™{¨1™~Ö.�Ü '× 5Ñ 5× EÑ EØ˜#˜q˜&‘MØ×&Ñ&Ó(¨)×*;Ñ*;Ó*=Ð>ØØØð !Fó !�ð )×0Ñ0°&¸%°ÓA�Ø!)��s˜A�v’ò /ð !&§¡ÑˆAˆq�+ä—;‘;Ü—	‘	˜!“×#Ñ#¤B§J¡JÓ/Ü—	‘	˜!“×#Ñ#¤B§J¡JÓ/Øô‰DˆAˆqð ˜R 2™I™ˆIØ˜R 2™I™ˆIà�{‰{×Ñ 3Ò&Ü˜T“{‘ä˜4“y�Ø×5Ñ5°dÑ;ˆKØ×8Ñ8¸Ñ?ˆMà$1´S×5FÑ5FÑ$FÐ ÜŸ™Ø˜9¤c§l¡lØ 4ô6‰JˆD�$ð ˜aÒÜŸ™Ü-¨eÓ4Ø˜$¨mØ*¸¸tÀTÐ8JôL�ð —:‘: ’? v§{¡{°aÒ'7Ø# C¬¯© OÑ4‘Fà#$Ð Ø�Ø&¨Ò4Ø$ SÐ*:Ð;KÈAÑ;MÐ*MÐ%MÑN�HÜ"Ÿy™yÜ1°(Ó;Ø˜d°-Ø#.¸TÀ4ÈÐ<Nô P�Hð  —}‘}¨Ò)Ø#+¨C´·±¨OÑ#<˜Ø—M‘M (Ô+Ø$¨Ñ)Ð$ð '¨Ó4ô Ÿ™¨°QÔ7�à�<‰<×Ñ × 0Ñ 0Ò0Ü×)Ñ)¨&°+Ó>ˆFàˆrE   )
)r#  g      D@)g      @g       @r   r   r   r$   NNr®  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:   rM   re  r{  rá  râ  rã  rå  ræ  rä  r­  rà  rë  r²  r³  s   @r9   rÕ  rÕ  À  s&  ø„ ñpðd !"ÐØ&)Ð#Ø $Ðð !$Ðð ×'Ñ'Ø×'Ñ'Ø×)Ñ)Ø—‘ñ	Ðð ×ÑØ×ÑØ�?‰?Ø�?‰?Ø�?‰?Ø�?‰?ñ Ðð KLØ Ø#)Ø!%Ø:Fõ	#)ðJ ñ5ó ð5ð ñ?ó ð?ò"=ò2òjò*3òl<ò~:ò>ò?òJð ñó ðð> òló ôlrE   rÕ  c                   óX   ‡ — e Zd ZdZ	 	 	 d	ˆ fd„	Zd„ Zd„ Zed„ «       Zd„ Z	d„ Z
d„ Zˆ xZS )
ÚRot90a¦  
    Rotate images clockwise by multiples of 90 degrees.

    This could also be achieved using ``Affine``, but ``Rot90`` is
    significantly more efficient.

    **Supported dtypes**:

    if (keep_size=False):

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; tested
        * ``uint32``: yes; tested
        * ``uint64``: yes; tested
        * ``int8``: yes; tested
        * ``int16``: yes; tested
        * ``int32``: yes; tested
        * ``int64``: yes; tested
        * ``float16``: yes; tested
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: yes; tested
        * ``bool``: yes; tested

    if (keep_size=True):

        minimum of (
            ``imgaug.augmenters.geometric.Rot90(keep_size=False)``,
            :func:`~imgaug.imgaug.imresize_many_images`
        )

    Parameters
    ----------
    k : int or list of int or tuple of int or imaug.ALL or imgaug.parameters.StochasticParameter, optional
        How often to rotate clockwise by 90 degrees.

            * If a single ``int``, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the discrete interval ``[a..b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``imgaug.ALL``, then equivalant to list ``[0, 1, 2, 3]``.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the value to use.

    keep_size : bool, optional
        After rotation by an odd-valued `k` (e.g. 1 or 3), the resulting image
        may have a different height/width than the original image.
        If this parameter is set to ``True``, then the rotated
        image will be resized to the input image's size. Note that this might
        also cause the augmented image to look distorted.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.Rot90(1)

    Rotate all images by 90 degrees.
    Resize these images afterwards to keep the size that they had before
    augmentation.
    This may cause the images to look distorted.

    >>> aug = iaa.Rot90([1, 3])

    Rotate all images by 90 or 270 degrees.
    Resize these images afterwards to keep the size that they had before
    augmentation.
    This may cause the images to look distorted.

    >>> aug = iaa.Rot90((1, 3))

    Rotate all images by 90, 180 or 270 degrees.
    Resize these images afterwards to keep the size that they had before
    augmentation.
    This may cause the images to look distorted.

    >>> aug = iaa.Rot90((1, 3), keep_size=False)

    Rotate all images by 90, 180 or 270 degrees.
    Does not resize to the original image size afterwards, i.e. each image's
    size may change.

    c                 ó°   •— t         t        | �  ||||¬«       |t        j                  k(  rg d¢}t        j                  |dd ddd¬«      | _        || _        y )Nr1  )r   r
   r   r   ÚkTFrU  )	r7  r9  rû   r)   r*   r+   rX  r;  r‡  )rú   r;  r‡  rã   rV   rå   r2  rE  s          €r9   rû   zRot90.__init__"  s_   ø€ ô 	Œe�TÑ#Ø˜DØ%°]ð 	$ô 	Dð ”—‘Š;ÚˆAÜ×*Ñ*Øˆs °tØ¨eô5ˆŒð #ˆ�rE   c                 ó>   — | j                   j                  |f|¬«      S )Nr�  )r;  r¡  )rú   r�  rå   s      r9   re  zRot90._draw_samples1  s   € Ø�v‰v×"Ñ" I <¸lÐ"ÓKÐKrE   c                 ó0  — | j                  |j                  |«      }|j                  �;| j                  |j                  || j                  t
        j                  «      |_        |j                  �"| j                  |j                  d|«      |_        |j                  �"| j                  |j                  d|«      |_	        dD ]Q  }t        ||«      }|€Œt        j                  | j                  |¬«      }| j                  ||«      }	t        |||	«       ŒS |S )Nr_  r_   r`  )Úks)re  r¸   rf  Ú_augment_arrays_by_samplesr‡  r)   r’  rh  ri  rj  rk  r=  r>  r?  rA  rŽ  )
rú   rr  rå   rs  rt  r>  rv  rw  rB  rC  s
             r9   r{  zRot90._augment_batch_5  s  € à×Ñ §¡¨|Ó<ˆà�<‰<Ð#Ø×:Ñ:Ø—‘˜b $§.¡.´"×2JÑ2JóLˆEŒLð �>‰>Ð%Ø!×:Ñ:Ø—‘ 
¨Bó0ˆEŒNð ×"Ñ"Ð.Ø&*×&CÑ&CØ×'Ñ'¨°ó'4ˆEÔ#ó*ˆIä  ¨	Ó2ˆJØÑ%Ü ×(Ñ(Ø×6Ñ6Øô�ð ×;Ñ;¸JÈÓM�Ü˜˜y¨&Õ1ð*ð ˆrE   c                 óÔ  — t        j                  |«      }|r|j                  nd }g }t        ||«      D ]i  \  }}	t	        j
                  ||	d¬«      }
|xr |j                  |
j                  k7  xr |d u}|r ||
|j                  dd «      }
|j                  |
«       Œk |rA|r?t        |D �ch c]  }|j                  ’Œ c}«      }|dk(  rt	        j                  ||¬«      }|S c c}w )N)r
   r   )Úaxesr   r   r
   r‡  )
r)   r}  rU   r‹  r‚   Úrot90rR   r~  rQ   r¢   )rM  r“  r>  r‡  Úresize_funcr‚  r…   r”  r_   Úk_ir—  Ú	do_resizeÚn_shapess                r9   r?  z Rot90._augment_arrays_by_samplesQ  sâ   € ô Ÿ.™.¨Ó.ˆÙ$3�d—j’j¸ˆØˆÜ˜D "ž‰HˆC�ä—h‘h˜s C¨fÔ5ˆGð ò ,Ø—I‘I §¡Ñ.ò,à tÐ+ð ñ Ù% g¨s¯y©y¸¸1¨~Ó>�Ø�O‰O˜GÕ$ð &ñ ™Ü±Ó:±¨#˜CŸI›I°Ñ:Ó;ˆHØ˜1Š}ÜŸ8™8 H°KÔ@�Øˆùò ;s   Â-C%c           	      óÚ  — |D �cg c]  }t        ||«      ‘Œ }}| j                  ||| j                  d «      }g }t        ||||«      }|D ]™  \  }	}
}}|
j                  }t        |	||«       | j                  r|	j                  |dd «      }	nG|dz  dk(  r>|	j                  dd \  }}t        ||gt        |	j                  dd  «      z   «      |	_        n	 |j                  |	«       Œ› |S c c}w )Nr   r   r
   )
rk  r?  r‡  r‹  rR   rŽ  r˜  r]   r0   r~  )rú   r�  r�  r>  Úmap_ir“  r”  Úmaps_augr•  r–  r_   r—  rD  r£  rS  rT  s                   r9   ri  zRot90._augment_maps_by_samplesi  s   € á;GÓH¹<°%”˜˜}Õ-¸<ˆÐHØ×2Ñ2Ø�"�d—n‘n dó,ˆð ˆÜ�,  h°Ó3ˆÛ03Ñ,ˆM˜3 ¨ØŸ™ˆJÜ�M =°'Ô:Ø�~Š~Ø -× 4Ñ 4°ZÀÀ!°_Ó E‘Ø�q‘˜A’Ø$×*Ñ*¨1¨QÐ/‘��1Ü&+Ø˜�FœT -×"5Ñ"5°a°bÐ"9Ó:Ñ:ó'<�Õ#ð
 Ø�O‰O˜MÕ*ð 14ð ˆùò) Is   …C(c           	      ó†  — g }t        ||«      D �].  \  }}|j                  }|dz  dk(  r|j                  |«       Œ-t        |«      dz  }|j                  dd \  }}|dz  dk(  r||fn||f\  }	}
|j                  D ]U  }|j
                  |j                  }}||}}||}}t        j                  |«      D ]  }||z
  |}}||}}Œ ||_        ||_        ŒW t        |	|
gt        |j                  dd  «      z   «      }||_        | j                  r!||f|	|
fk7  r|j                  |«      }||_        |j                  |«       �Œ1 |S )Nr   r   r   )r‹  rR   r~  r^   ra  rÔ   rÓ   rš   r›   r]   r0   r‡  r¢  )rú   r  r>  r¾   Úkpsoi_irD  r£  rS  rT  Úh_augÚw_augr  rÔ   rÓ   ÚyrÚxrÚwrÚhrr™  Ú	shape_augs                       r9   r?  z#Rot90._augment_keypoints_by_samples‚  sS  € àˆÜÐ 3°R×8‰LˆG�SØ Ÿ™ˆJà�a‘˜AŠ~Ø—‘˜gÕ&ä˜#“h ‘l�Ø—}‘} Q qÐ)‘��1Ø*-°©'°aª  1™v¸aÀ¸V‘��uà!×+Ô+�BØŸ4™4 §¡�q�AØ ˜�BØ ˜�BÜŸY™Y sž^˜ð
 "$ b¡¨"˜B˜Ø!# R˜B™ð ,ð �B”DØ�B•Dð ,ô " 5¨% .´4¸¿¹ÀaÀbÐ8IÓ3JÑ"JÓK�	Ø )�”à—>’> q¨! f°¸°Ò&>Ø%Ÿk™k¨*Ó5�GØ$.�G”Mà—‘˜gÖ&ð? 9ð@ ˆrE   c                 ó2   — | j                   | j                  gS r¬  )r;  r‡  r"  s    r9   r­  zRot90.get_parameters§  s   € à—‘˜Ÿ™Ð'Ð'rE   )r
   TNNr®  r®  )r$  r%  r&  r°  rû   re  r{  r±  r?  ri  r?  r­  r²  r³  s   @r9   r9  r9  ¼  sI   ø„ ñcðJ '+Ø!%Ø:Fõ#òLòð8 ñó ðò.ò2#öJ(rE   r9  c                   óæ  ‡ — e Zd ZdZ	 	 d"ˆ fd„	Zd„ Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z d„ Z!d„ Z"d „ Z#d!„ Z$ˆ xZ%S )#ÚWithPolarWarpingaÉ  Augmenter that applies other augmenters in a polar-transformed space.

    This augmenter first transforms an image into a polar representation,
    then applies its child augmenter, then transforms back to cartesian
    space. The polar representation is still in the image's input dtype
    (i.e. ``uint8`` stays ``uint8``) and can be visualized. It can be thought
    of as an "unrolled" version of the image, where previously circular lines
    appear straight. Hence, applying child augmenters in that space can lead
    to circular effects. E.g. replacing rectangular pixel areas in the polar
    representation with black pixels will lead to curved black areas in
    the cartesian result.

    This augmenter can create new pixels in the image. It will fill these
    with black pixels. For segmentation maps it will fill with class
    id ``0``. For heatmaps it will fill with ``0.0``.

    This augmenter is limited to arrays with a height and/or width of
    ``32767`` or less.

    .. warning::

        When augmenting coordinates in polar representation, it is possible
        that these are shifted outside of the polar image, but are inside the
        image plane after transforming back to cartesian representation,
        usually on newly created pixels (i.e. black backgrounds).
        These coordinates are currently not removed. It is recommended to
        not use very strong child transformations when also augmenting
        coordinate-based augmentables.

    .. warning::

        For bounding boxes, this augmenter suffers from the same problem as
        affine rotations applied to bounding boxes, i.e. the resulting
        bounding boxes can have unintuitive (seemingly wrong) appearance.
        This is due to coordinates being "rotated" that are inside the
        bounding box, but do not fall on the object and actually are
        background.
        It is recommended to use this augmenter with caution when augmenting
        bounding boxes.

    .. warning::

        For polygons, this augmenter should not be combined with
        augmenters that perform automatic polygon recovery for invalid
        polygons, as the polygons will frequently appear broken in polar
        representation and their "fixed" version will be very broken in
        cartesian representation. Augmenters that perform such polygon
        recovery are currently ``PerspectiveTransform``, ``PiecewiseAffine``
        and ``ElasticTransformation``.

    Added in 0.4.0.

    **Supported dtypes**:

        * ``uint8``: yes; fully tested
        * ``uint16``: yes; tested
        * ``uint32``: no (1)
        * ``uint64``: no (2)
        * ``int8``: yes; tested
        * ``int16``: yes; tested
        * ``int32``: yes; tested
        * ``int64``: no (2)
        * ``float16``: yes; tested (3)
        * ``float32``: yes; tested
        * ``float64``: yes; tested
        * ``float128``: no (1)
        * ``bool``: yes; tested (4)

        - (1) OpenCV produces error
          ``TypeError: Expected cv::UMat for argument 'src'``
        - (2) OpenCV produces array of nothing but zeros.
        - (3) Mapepd to ``float32``.
        - (4) Mapped to ``uint8``.

    Parameters
    ----------
    children : imgaug.augmenters.meta.Augmenter or list of imgaug.augmenters.meta.Augmenter or None, optional
        One or more augmenters to apply to images after they were transformed
        to polar representation.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.WithPolarWarping(iaa.CropAndPad(percent=(-0.1, 0.1)))

    Apply cropping and padding in polar representation, then warp back to
    cartesian representation.

    >>> aug = iaa.WithPolarWarping(
    >>>     iaa.Affine(
    >>>         translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
    >>>         rotate=(-35, 35),
    >>>         scale=(0.8, 1.2),
    >>>         shear={"x": (-15, 15), "y": (-15, 15)}
    >>>     )
    >>> )

    Apply affine transformations in polar representation.

    >>> aug = iaa.WithPolarWarping(iaa.AveragePooling((2, 8)))

    Apply average pooling in polar representation. This leads to circular
    bins.

    c                 ó€   •— t         t        | �  ||||¬«       t        j                  || j
                  d«      | _        y )Nr1  Úthen)r7  rU  rû   r   Úhandle_children_listrV   Úchildren)rú   rY  rã   rV   rå   r2  rE  s         €r9   rû   zWithPolarWarping.__init__*  sA   ø€ ô 	Ô Ñ.Ø˜DØ%°]ð 	/ô 	Dô ×1Ñ1°(¸D¿I¹IÀvÓNˆ�rE   c                 óâ  — |j                   �'t        j                  |j                   g d¢g d¢| ¬«       |j                  | ||«      5  | j	                  |«      \  }}i }|j
                  D ]W  }t        | d|j                  ›d�«      } ||j                  «      \  }	}
t        ||j                  |	«       |
||j                  <   ŒY | j                  j                  ||| gz   |¬«      }|j
                  D ]S  }t        | d|j                  ›d�«      } ||j                  ||j                     «      }t        ||j                  |«       ŒU | j                  ||«      }d d d «       |S # 1 sw Y   |S xY w)Nr‡   rˆ   rw   Ú_warp_r™  ©rs  rt  Ú_invert_warp_)rf  rS   r~   Úpropagation_hooks_ctxÚ_convert_bbs_to_polygons_Úcolumnsrk  rV   ÚvaluerŽ  Ú	attr_namerY  Úaugment_batch_Ú _invert_convert_bbs_to_polygons_)rú   rr  rå   rs  rt  Úinv_data_bbsÚinv_dataÚcolumnrB  Úcol_augÚinv_data_colÚ	col_unaugs               r9   r{  z WithPolarWarping._augment_batch_3  sW  € Ø�<‰<Ð#Ü×ÑØ—‘ò:ò?ð õ	 ð ×(Ñ(¨¨u°gÕ>Ø"&×"@Ñ"@ÀÓ"GÑˆE�<àˆHØŸ-œ-�Ü™t°F·K³KÐ%AÓB�Ù(,¨V¯\©\Ó(:Ñ%�˜Ü˜˜v×/Ñ/°Ô9Ø(4�˜Ÿ™Ò%ð	 (ð —M‘M×0Ñ0°Ø9@ÀDÀ6Ñ9IØ7<ð 1ó >ˆEð  Ÿ-œ-�Ü™t¸6¿;»;Ð%HÓI�Ù  §¡¨x¸¿¹Ñ/DÓE�	Ü˜˜v×/Ñ/°Õ;ð (ð
 ×9Ñ9¸%ÀÓNˆE÷% ?ð( ˆ÷) ?ð( ˆús   ÁDE$Å$E.c                 óž  — |j                   d u}|j                  €|d|ffS |j                  D �cg c]  }|j                  «       ‘Œ }}|D �cg c]  }|j                  d«      ‘Œ }}|D ];  }|j                   D ]*  }|j                  €d|_        Œ|j                  dz   |_        Œ, Œ= |j                   €||_         n~t        |j                   |«      D ]e  \  }}|j                  |j                  k(  s"J d|j                  ›d|j                  ›d�«       ‚|j                   j                  |j                   «       Œg d |_        |d|ffS c c}w c c}w )	NFr   ú$$IMGAUG_BB_AS_POLYGONú;$$IMGAUG_BB_AS_POLYGONzHExpected polygons and bounding boxes to have the same .shape value, got z and r(   T)rc  rb  Úto_polygons_on_imageÚ
subdivide_Úlabelr‹  rR   Úextend)rM  rr  Úbatch_contained_polygonsr  Úpsoisr  ÚpolygonÚbbs_as_psois           r9   r_  z*WithPolarWarping._convert_bbs_to_polygons_W  sO  € à#(§>¡>¸Ð#=Ð Ø×ÑÐ'Ø˜5Ð":Ð;Ð;Ð;à;@×;OÒ;OÓPÑ;O°%�×+Ñ+Õ-Ð;OˆÐPÙ05Ó6±¨�—‘ Õ#°ˆÐ6ó ˆDØŸ=œ=�Ø—=‘=Ð(Ø$<�G•Mà$+§M¡MÐ4MÑ$M�G•Mñ	 )ð ð �>‰>Ð!Ø"ˆE�Nä%(¨¯©¸Ö%?Ñ!��kØ—z‘z [×%6Ñ%6Ò6ñ Jà6:·j³jØ6A×6GÓ6GðIóJÐ6ð
 —‘×$Ñ$ [×%9Ñ%9Õ:ð &@ð  $ˆÔà�tÐ5Ð6Ð6Ð6ùò3 QùÚ6s   ¯EÁE
c                 ó*  — |\  }}|s|S g }|j                   D ]è  }g }g }|j                   D ]š  }	d}
|	j                  €d}
nT|	j                  dk(  r
d |	_        d}
n;|	j                  j                  d«      r |	j                  d t        d«        |	_        d}
|
r |j	                  |	j                  «       «       ŒŠ|j	                  |	«       Œœ ||_         t        j                  ||j                  ¬«      }|j	                  |«       Œê ||_	        |sd |_         |S )NFrl  Trm  )rR   )
rc  rp  ÚendswithrQ   r~  Úto_bounding_boxr)   ÚBoundingBoxesOnImagerR   rb  )rM  rr  rf  Úbatch_contained_bbsrr  Úbbsoisr  rc  Úbbsrt  Úis_bbr  s               r9   rd  z1WithPolarWarping._invert_convert_bbs_to_polygons_y  s  € à8@Ñ5ÐÐ5á"ØˆLàˆØ—N”NˆDØˆHØˆCØŸ=œ=�Ø�Ø—=‘=Ð(Ø!‘EØ—]‘]Ð&>Ò>Ø$(�G”MØ ‘EØ—]‘]×+Ñ+Ð,EÔFàŸ™Ð&F¬Ð,EÓ(FÐ'FÐGð ”Mà �EáØ—J‘J˜w×6Ñ6Ó8Õ9à—O‘O GÕ,ð )ð" %ˆDŒMÜ×+Ñ+¨C°t·z±zÔBˆEØ�M‰M˜%Õ ð- #ð0  &ˆÔá'Ø!ˆEŒNàˆrE   c                 ó&   — | j                  |d«      S r¯  )Ú_warp_arrays)rM  rf  s     r9   Ú_warp_images_zWithPolarWarping._warp_images_¡  s   € à×Ñ ¨Ó.Ð.rE   c                 ó(   — | j                  |d|«      S r¯  )Ú_invert_warp_arrays)rM  Úimages_warpedrf  s      r9   Ú_invert_warp_images_z%WithPolarWarping._invert_warp_images_¦  s   € à×&Ñ& }°e¸XÓFÐFrE   c                 ó(   — | j                  |dd«      S ©Nr_  F©Ú_warp_maps_)rM  rh  s     r9   Ú_warp_heatmaps_z WithPolarWarping._warp_heatmaps_«  s   € à�‰˜x¨°UÓ;Ð;rE   c                 ó*   — | j                  |dd|«      S r†  ©Ú_invert_warp_maps_)rM  Úheatmaps_warpedrf  s      r9   Ú_invert_warp_heatmaps_z'WithPolarWarping._invert_warp_heatmaps_°  s   € à×%Ñ% o°zÀ5Ø&.ó0ð 	0rE   c                 ó(   — | j                  |dd«      S ©Nr_   Tr‡  )rM  rj  s     r9   Ú_warp_segmentation_maps_z)WithPolarWarping._warp_segmentation_maps_¶  s   € à�‰Ð0°%¸Ó>Ð>rE   c                 ó*   — | j                  |dd|«      S r�  r‹  )rM  Úsegmentation_maps_warpedrf  s      r9   Ú_invert_warp_segmentation_maps_z0WithPolarWarping._invert_warp_segmentation_maps_»  s!   € ð ×%Ñ%Ð&>ÀÀtØ&.ó0ð 	0rE   c                 ó$   — | j                  |«      S ró   ©Ú_warp_cbaois_)rM  rR  s     r9   Ú_warp_keypoints_z!WithPolarWarping._warp_keypoints_Â  s   € à× Ñ  Ó(Ð(rE   c                 ó&   — | j                  ||«      S ró   ©Ú_invert_warp_cbaois_)rM  Úkpsois_warpedÚimage_shapes_origs      r9   Ú_invert_warp_keypoints_z(WithPolarWarping._invert_warp_keypoints_Ç  s   € à×'Ñ'¨Ð7HÓIÐIrE   c                 ó   — |�J d«       ‚y ©Nz0Expected BBs to have been converted to polygons.r'  )rM  r{  s     r9   Ú_warp_bounding_boxes_z&WithPolarWarping._warp_bounding_boxes_Ì  s   € àˆ~ð 	0ð !/ó 	0ˆ~àrE   c                 ó   — |�J d«       ‚y r   r'  )rM  Úbbsois_warpedÚ_image_shapes_origs      r9   Ú_invert_warp_bounding_boxes_z-WithPolarWarping._invert_warp_bounding_boxes_Ó  s   € àÐ$ð 	7ð (6ó 	7Ð$àrE   c                 ó$   — | j                  |«      S ró   r–  )rM  rs  s     r9   Ú_warp_polygons_z WithPolarWarping._warp_polygons_Ú  ó   € à× Ñ  Ó'Ð'rE   c                 ó&   — | j                  ||«      S ró   rš  )rM  Úpsois_warpedr�  s      r9   Ú_invert_warp_polygons_z'WithPolarWarping._invert_warp_polygons_ß  ó   € à×'Ñ'¨Ð6GÓHÐHrE   c                 ó$   — | j                  |«      S ró   r–  )rM  Úlsoiss     r9   Ú_warp_line_strings_z$WithPolarWarping._warp_line_strings_ä  r¨  rE   c                 ó&   — | j                  ||«      S ró   rš  )rM  Úlsois_warpedr�  s      r9   Ú_invert_warp_line_strings_z+WithPolarWarping._invert_warp_line_strings_é  r¬  rE   c                 ó  — |€yt         j                  t         j                  z   }|r|t         j                  z  }g }g }|D �]B  }d|j                  v r-|j                  |«       |j                  |j                  «       Œ?|j                  j                  }|dk(  r#|j                  t        j                  «      dz  }n$|dk(  r|j                  t        j                  «      }|j                  dd \  }}	|dk  r|	dk  sJ d|j                  ›d	�«       ‚d
}
|	dz  |dz  f}t        j                  |dz  dz  |	dz  dz  z   «      }|j                  dk(  r}|j                  d   dkD  rkt        j                  t        j                  |j                  d   «      D �cg c])  }t        j                   t#        |d|f   «      |
|||«      ‘Œ+ c}d¬«      }nZt        j                   t#        |«      |
|||«      }|j                  dk(  r)|j                  dk(  r|d d …d d …t        j$                  f   }|dk(  r|dkD  }n$|dk(  r|j                  t        j&                  «      }|j                  |«       |j                  |j                  «       �ŒE ||fS c c}w )N©NNr   r   r<   r   r   r  úlWithPolarWarping._warp_arrays() can currently only handle arrays with axis sizes below 32767, but got shape ú. This is an OpenCV limitation.©r   r   r  r   r‰   é   .r�   é€   )r%   ÚWARP_FILL_OUTLIERSÚWARP_POLAR_LINEARrí  rR   r~  rU   rV   r‘   r‚   r   r   r¬  r˜   rœ   r¶   Ú	warpPolarr   r™   r   )rM  ÚarraysÚinterpolation_nearestrŒ   Úarrays_warpedÚshapes_origr_   r…   r§   r¨   Ú	dest_sizeÚ	center_xyÚ
max_radiusÚc_idxrJ  s                  r9   r  zWithPolarWarping._warp_arraysî  se  € àˆ>Øä×&Ñ&¬×)>Ñ)>Ñ>ˆÙ Ø”S×&Ñ&Ñ&ˆEàˆØˆÜˆCØ�C—I‘I‰~Ø×$Ñ$ SÔ)Ø×"Ñ" 3§9¡9Ô-ØàŸ)™)Ÿ.™.ˆKØ˜fÒ$Ø—j‘j¤§¡Ó*¨SÑ0‘Ø 	Ò)Ø—j‘j¤§¡Ó,�àŸI™I a¨˜N‰MˆF�Eð ˜U’? u°¢~ñ ;ð /2¯i«ið:ó;Ð5ð
 ˆIØ˜q™ &¨¡(Ð+ˆIÜŸ™ &¨¡*¨sÑ!2°e¸C±iÀ#Ñ5EÑ!EÓFˆJà�x‰x˜1Š} §¡¨2¡°Ò!4ÜŸX™Xô #%§)¡)¨C¯I©I°b©MÔ":ó<á":˜ô —]‘]Ô#<¸SÀÀeÀ¹_Ó#MØ#,¨i¸ÀUõLà":ñ<ð ô	‘
ô !Ÿ]™]Ô+DÀSÓ+IØ+4°iÀØ+0ó2�
ð —?‘? aÒ'¨C¯H©H¸ªMØ!+ªAªq´"·*±*Ð,<Ñ!=�Jà˜fÒ$Ø(¨3Ñ.‘
Ø 	Ò)Ø'×.Ñ.¬r¯z©zÓ:�
à× Ñ  Ô,Ø×Ñ˜sŸy™yÖ)ðW ðX ˜kÐ)Ð)ùò%<s   Æ.J

c                 ó  — |}|€y t         j                  t         j                  z   t         j                  z   }|r|t         j                  z  }g }t        ||«      D �]!  \  }}d|j                  v r|j                  |«       Œ'|j                  j                  }	|	dk(  r#|j                  t        j                  «      dz  }n$|	dk(  r|j                  t        j                  «      }|dd \  }
}|j                  d   dk  r|j                  d   dk  sJ d|j                  ›d	�«       ‚||
f}|dz  |
dz  f}t        j                  |
d
z  d
z  |d
z  d
z  z   «      }|j                  dk(  r}|j                  d   dkD  rkt        j                   t        j"                  |j                  d   «      D �cg c])  }t        j$                  t'        |d|f   «      ||||«      ‘Œ+ c}d¬«      }nZt        j$                  t'        |«      ||||«      }|j                  dk(  r)|j                  dk(  r|d d …d d …t        j(                  f   }|	dk(  r|dkD  }n$|	dk(  r|j                  t        j*                  «      }|j                  |«       �Œ$ |S c c}w )Nr   r   r<   r   r   r  r
   rµ  r¶  r  r   r‰   r¸  .r�   r¹  )r%   rº  r»  ÚWARP_INVERSE_MAPrí  r‹  rR   r~  rU   rV   r‘   r‚   r   r   r¬  r˜   rœ   r¶   r¼  r   r™   r   )rM  r¿  r¾  rf  rÀ  rŒ   Ú
arrays_invrJ  r£  r…   r§   r¨   rÁ  rÂ  rÃ  rÄ  Úarr_invs                    r9   r‚  z$WithPolarWarping._invert_warp_arrays(  s’  € ð ˆØÐ Øä×'Ñ'¬#×*?Ñ*?Ñ?Ü×'Ñ'ñ(ˆá Ø”S×&Ñ&Ñ&ˆEð ˆ
Ü&)¨-¸×&EÑ"ˆJ˜
Ø�J×$Ñ$Ñ$Ø×!Ñ! *Ô-Øà$×*Ñ*×/Ñ/ˆKØ˜fÒ$Ø'×.Ñ.¬r¯x©xÓ8¸3Ñ>‘
Ø 	Ò)Ø'×.Ñ.¬r¯z©zÓ:�
à& q¨˜O‰MˆF�Eð ×$Ñ$ QÑ'¨5Ò0Ø"×(Ñ(¨Ñ+¨uÒ4ñ0ð
 '×,Ó,ð/ó0ð 5ð  ˜ˆIØ˜q™ &¨¡(Ð+ˆIÜŸ™ &¨¡*¨sÑ!2°e¸C±iÀ#Ñ5EÑ!EÓFˆJà�‰ !Ò#¨
×(8Ñ(8¸Ñ(<¸sÒ(BÜŸ(™(ô #%§)¡)¨J×,<Ñ,<¸RÑ,@Ô"AóCñ #B˜ô —]‘]Ü1°*¸SÀ%¸ZÑ2HÓIØ! 9¨j¸%õAð #BñCð ô‘ô Ÿ-™-Ü-¨jÓ9Ø˜y¨*°eó=�ð —<‘< 1Ò$¨¯©¸AÒ)=Ø%¢aª¬B¯J©JÐ&6Ñ7�Gà˜fÒ$Ø" S™=‘Ø 	Ò)Ø!Ÿ.™.¬¯©Ó4�à×Ñ˜gÖ&ðY 'FðZ Ðùò%Cs   Æ+.J
c                 óF  — |€ydgt        |«      z  }g }g }t        |«      D ]ž  \  }}d|j                  v rUd||<   |j                  t	        j
                  dt        j                  ¬«      «       |j                  |j                  «       Œi|j                  t        ||«      «       |j                  |j                  «       Œ  | j                  ||«      \  }	}
| j                  |«      }t        |«      D ]%  \  }}||   rŒ||   |_        t        |||	|   «       Œ' |||
|ffS )Nr´  Fr   Tr·  r‡  )rQ   rÐ   rR   r~  r‚   r
  r   rk  r  Ú_warp_shape_tuplesrŽ  )rM  Úmapsr�  r¾  Úskippedr½  Úshapes_imgs_origr¿   rH  r¿  Úwarparr_inv_dataÚshapes_imgs_warpeds               r9   rˆ  zWithPolarWarping._warp_maps_g  s  € àˆ<Øà�'œC ›IÑ%ˆØˆØÐÜ! $ž‰HˆAˆuØ�E—K‘KÑØ!�˜‘
Ø—‘œbŸh™h v´R·X±XÔ>Ô?Ø ×'Ñ'¨¯©Õ4à—‘œg e¨]Ó;Ô<Ø ×'Ñ'¨¯©Õ4ð (ð +.×*:Ñ*:ØÐ)ó++Ñ'ˆÐ'à ×3Ñ3Ð4DÓEÐä! $ž‰HˆAˆuØ˜1“:Ø0°Ñ3�”Ü˜˜}¨m¸AÑ.>Õ?ð (ð
 Ð&Ð(8¸'ÐBÐBÐBrE   c                 óx  — |€y |\  }}}g }t        |«      D ]Z  \  }	}
||	   r5|j                  t        j                  dt        j                  ¬«      «       Œ@|j                  t        |
|«      «       Œ\ | j                  |||«      }t        |«      D ]%  \  }	}||	   rŒ||	   |_        t        ||||	   «       Œ' |S )Nr·  r‡  )	rÐ   r~  r‚   r
  r   rk  r‚  rR   rŽ  )rM  Úmaps_warpedr�  r¾  Úinvert_datarÍ  rÎ  rÌ  r¿  r¿   Ú
map_warpedrÇ  rH  s                r9   rŒ  z#WithPolarWarping._invert_warp_maps_„  sÆ   € ð ÐØà6AÑ3ÐÐ*¨GàˆÜ& {Ö3‰MˆAˆzØ�qŠzØ×$Ñ$¤R§X¡X¨f¼B¿H¹HÔ%EÕFà×$Ñ$¤W¨Z¸Ó%GÕHð	 4ð ×,Ñ,¨]Ø-BØ-=ó?ˆ
ô " +Ö.‰HˆAˆuØ˜1“:Ø.¨qÑ1�”Ü˜˜}¨j¸©mÕ<ð /ð
 ÐrE   c                 óz  — |€y| j                  |«      }t        j                  }g }t        |||«      D ]‚  \  }}}d|v r|j	                  |«       Œ|dd \  }	}
|d   |d   f}|
dz  |	dz  f}t        j                  |	dz  dz  |
dz  dz  z   «      }| j                  |||||«      }|j	                  |«       Œ„ ||fS )Nr´  r   r   r
   r  )rÊ  r%   r»  r‹  r~  r‚   r¬  ÚwarpPolarCoords)rM  rÑ   r  Úimage_shapes_warpedrŒ   Úcoords_warpedÚcoords_irR   Úshape_warpedr§   r¨   rÁ  rÂ  rÃ  Úcoords_i_warpeds                  r9   Ú_warp_coordszWithPolarWarping._warp_coordsŸ  só   € àˆ>Øà!×4Ñ4°\ÓBÐä×%Ñ%ˆàˆÜ-0°¸Ø1Dö.FÑ)ˆH�e˜\à�E‰zØ×$Ñ$ XÔ.Øà! ! A˜J‰MˆF�EØ% a™¨,°q©/Ð:ˆIØ˜q™ &¨¡(Ð+ˆIÜŸ™ &¨¡*¨sÑ!2°e¸C±iÀ#Ñ5EÑ!EÓFˆJà!×1Ñ1Ø˜) Y°
¸EóCˆOð × Ñ  Õ1ð.Fð ˜lÐ*Ð*rE   c                 óœ  — |}|€y t         j                  t         j                  z   }g }t        t	        ||«      «      }|D ]‰  \  }\  }	}
d|
v r|j                  |	«       Œ||   }|
dd \  }}|d   |d   f}|dz  |dz  f}t        j                  |dz  dz  |dz  dz  z   «      }| j                  |	||||«      }|j                  |«       Œ‹ |S )Nr   r   r
   r  )	r%   r»  rÆ  rÐ   r‹  r~  r‚   r¬  rÕ  )rM  r×  Úimage_shapes_after_augrf  r�  rŒ   Ú
coords_invr•  r¿   rÚ  r£  rÙ  r§   r¨   rÁ  rÂ  rÃ  Úcoords_i_invs                     r9   Ú_invert_warp_coordsz$WithPolarWarping._invert_warp_coords»  s  € ð %ÐØÐ Øä×%Ñ%¬×(<Ñ(<Ñ<ˆØˆ
Üœ˜MÐ+<Ó=Ó>ˆÛ03Ñ,ˆAÑ,� Ø�J‰Ø×!Ñ! /Ô2Øà1°!Ñ4ˆLØ& q¨˜O‰MˆF�EØ% a™¨,°q©/Ð:ˆIØ˜q™ &¨¡(Ð+ˆIÜŸ™ &¨¡*¨sÑ!2°e¸C±iÀ#Ñ5EÑ!EÓFˆJà×.Ñ.¨Ø/8¸)Ø/9¸5óBˆLð ×Ñ˜lÕ+ð 14ð  ÐrE   c                 ó\  — |€y|D �cg c]  }|j                  «       ‘Œ }}|D �cg c]  }|j                  ‘Œ }}| j                  |«      }| j                  ||«      \  }}t	        t        ||«      «      D ](  \  }\  }}	|j                  |	«      }||   |_        |||<   Œ* ||fS c c}w c c}w )Nr´  )rn  rR   rÊ  rÛ  rÐ   r‹  rp  )
rM  rC  rx  rÑ   r  rÖ  r×  rf  r¿   rÚ  s
             r9   r—  zWithPolarWarping._warp_cbaois_Ø  sÉ   € àˆ>Øá39Ó:±6¨%�%×#Ñ#Õ%°6ˆÐ:Ù17Ó8±¨˜Ÿ›°ˆÐ8Ø!×4Ñ4°\ÓBÐà"%×"2Ñ"2°6¸<Ó"HÑˆ�xÜ+4´S¸Ø9Fó6Hö ,IÑ'ˆAÑ'��à×-Ñ-¨oÓ>ˆEØ-¨aÑ0ˆEŒKØˆF�1ŠIð	,Ið �xÐÐùò ;ùÚ8s
   ˆB$¥B)c                 ó6  — |€y |D �cg c]  }|j                  «       ‘Œ }}|D �cg c]  }|j                  ‘Œ }}| j                  |||«      }|}t        t	        ||«      «      D ](  \  }\  }}	|j                  |	«      }||   |_        |||<   Œ* |S c c}w c c}w ró   )rn  rR   rà  rÐ   r‹  rp  )
rM  Úcbaois_warpedr�  rx  rÑ   rÝ  r×  rC  r¿   rÚ  s
             r9   r›  z%WithPolarWarping._invert_warp_cbaois_ë  s¾   € àÐ Øá3@ÓA±=¨%�%×#Ñ#Õ%°=ˆÐAÙ;HÓ!I¹=°% %§+£+¸=ÐÐ!Ià×/Ñ/°Ð8NØ0AóCˆð ˆÜ+4´S¸Ø9Fó6Hö ,IÑ'ˆAÑ'��à×-Ñ-¨oÓ>ˆEØ+¨AÑ.ˆEŒKØˆF�1ŠIð	,Ið ˆùò BùÚ!Is
   ˆB¥Bc                 ó�  — t         j                  }g }|D ]®  }d|v r|j                  |«       Œ|dd \  }}t        j                  |dz  dz  |dz  dz  z   «      }t	        t        j
                  |«      «      }t	        t        j
                  ||z  «      «      }|j                  t        ||gt        |dd  «      z   «      «       Œ° |S )Nr   r   r  )r‚   Úpir~  r¬  r^   r’   r]   r0   )rM  r¯  rå  r¾   rR   r§   r¨   rÃ  s           r9   rÊ  z#WithPolarWarping._warp_shape_tuples   s½   € ô �U‰UˆØˆÛˆEØ�E‰zØ—‘˜eÔ$Øà! ! A˜J‰MˆF�EÜŸ™ &¨¡*¨sÑ!2°e¸C±iÀ#Ñ5EÑ!EÓFˆJô œŸ™ Ó,Ó-ˆEÜœŸ™ *¨r¡/Ó2Ó3ˆFØ�M‰Mœ% ¨ ´$°u¸Q¸R°y³/Ñ AÓBÕCð! ð" ˆrE   c                 ó”  — |d   dkD  sJ ‚|d   dkD  sJ ‚|d   }|d   }|d   }|d   }	t        j                  |t        j                  «      �r	|d d …df   }
|d d …df   }|dt         j                  z  z  }||z  }t        j
                  |t        j                  «      r1|t        j                  |«      z  }t        j                  |
|z  «      }n
||z  }|
|z  }||t        j                  |«      z  z   }|	|t        j                  |«      z  z   }|d d …t         j                  f   }|d d …t         j                  f   }t        j                  ||gd¬«      S |d d …df   }|d d …df   }|dt         j                  z  z  }||z  }||z
  ||	z
  }}t        j                  ||«      \  }}||z  }||z  }
t        j                  |
|gd¬«      S )Nr   r
   r   r�   )r‚   rø  r%   rÆ  rå  Úbitwise_andÚWARP_POLAR_LOGÚlogÚexpÚcosÚsinr™   rù  ÚcartToPolar)rM  Úsrcr‹   ÚcenterÚ	maxRadiusrŒ   Údsize_widthÚdsize_heightÚcenter_xÚcenter_yÚrhoÚphiÚKangleÚangleRadÚKlogÚ	magnitudeÚKlinrÓ   rÔ   ÚI_xÚI_yÚmagnitude_IÚangle_Is                          r9   rÕ  z WithPolarWarping.warpPolarCoords  sË  € ð �Q‰x˜!Š|Ðˆ|Ø�Q‰x˜!Š|Ðˆ|à˜A‘hˆØ˜Q‘xˆà˜!‘9ˆØ˜!‘9ˆä�>‰>˜%¤×!5Ñ!5Õ6Ø’a˜�d‘)ˆCØ’a˜�d‘)ˆCØ! Q¤r§u¡u¡WÑ-ˆFØ˜V‘|ˆHÜ�~‰~˜e¤S×%7Ñ%7Ô8Ø"¤R§V¡V¨IÓ%6Ñ6�ÜŸF™F 3¨¡:Ó.‘	à" YÑ.�Ø $™J�	Ø˜9¤r§v¡v¨hÓ'7Ñ7Ñ7ˆAØ˜9¤r§v¡v¨hÓ'7Ñ7Ñ7ˆAà’!”R—Z‘Z�-Ñ ˆAØ’!”R—Z‘Z�-Ñ ˆAä—>‘> 1 a &¨qÔ1Ð1à’A�q�D‘	ˆAØ’A�q�D‘	ˆAà! Q¤r§u¡u¡WÑ-ˆFØ Ñ*ˆDà˜H™ a¨(¡l�ˆCÜ#&§?¡?°3¸Ó#<Ñ ˆK˜Ø˜7Ñ"ˆCà˜Ñ$ˆCä—>‘> 3¨ *°1Ô5Ð5rE   c                 ó   — g S r¬  r'  r"  s    r9   r­  zWithPolarWarping.get_parametersN  s   € àˆ	rE   c                 ó   — | j                   gS )zASee :func:`~imgaug.augmenters.meta.Augmenter.get_children_lists`.)rY  r"  s    r9   Úget_children_listsz#WithPolarWarping.get_children_listsS  s   € à—‘ˆÐrE   c                 ó°   — | j                  «       }|j                  j                  «       |_        d|_        | j                  j                  «       |_        |S )NT)rÏ   rY  Úto_deterministicr2  rå   Úderive_rng_)rú   Úaugs     r9   Ú_to_deterministicz"WithPolarWarping._to_deterministicX  sE   € Ø�i‰i‹kˆØ—|‘|×4Ñ4Ó6ˆŒØ ˆÔØ×,Ñ,×8Ñ8Ó:ˆÔØˆ
rE   c                 ó|   — d}|| j                   j                  | j                  | j                  | j                  fz  S )Nz*%s(name=%s, children=%s, deterministic=%s))rE  r$  rV   rY  r2  )rú   Úpatterns     r9   Ú__str__zWithPolarWarping.__str__`  sA   € ðð 	ð ˜$Ÿ.™.×1Ñ1°4·9±9ØŸ-™-¨×);Ñ);ð=ñ =ð 	=rE   )NNr®  r®  )&r$  r%  r&  r°  rû   r{  r±  r_  rd  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³  s   @r9   rU  rU  ­  sI  ø„ ñyðz "&Ø:FõOò!ðH ñ7ó ð7ðB ñ$ó ð$ðN ñ/ó ð/ð ñGó ðGð ñ<ó ð<ð ñ0ó ð0ð
 ñ?ó ð?ð ñ0ó ð0ð ñ)ó ð)ð ñJó ðJð ñó ðð ñó ðð ñ(ó ð(ð ñIó ðIð ñ(ó ð(ð ñIó ðIð ñ6*ó ð6*ðr ñ;ó ð;ð| ñCó ðCð8 ñó ðð4 ñ+ó ð+ð6 ñó ðð8 ñ ó ð ð$ ñó ðð( ñó ðð0 ñ16ó ð16òhò
ò
ö=rE   rU  c                   ó~   ‡ — e Zd ZdZ	 	 	 	 d
ˆ fd„	Zd„ Zd„ Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zd	„ Zˆ xZS )ÚJigsawaY  Move cells within images similar to jigsaw patterns.

    .. note::

        This augmenter will by default pad images until their height is a
        multiple of `nb_rows`. Analogous for `nb_cols`.

    .. note::

        This augmenter will resize heatmaps and segmentation maps to the
        image size, then apply similar padding as for the corresponding images
        and resize back to the original map size. That also means that images
        may change in shape (due to padding), but heatmaps/segmaps will not
        change. For heatmaps/segmaps, this deviates from pad augmenters that
        will change images and heatmaps/segmaps in corresponding ways and then
        keep the heatmaps/segmaps at the new size.

    .. warning::

        This augmenter currently only supports augmentation of images,
        heatmaps, segmentation maps and keypoints. Other augmentables,
        i.e. bounding boxes, polygons and line strings, will result in errors.

    Added in 0.4.0.

    **Supported dtypes**:

    See :func:`~imgaug.augmenters.geometric.apply_jigsaw`.

    Parameters
    ----------
    nb_rows : int or list of int or tuple of int or imgaug.parameters.StochasticParameter, optional
        How many rows the jigsaw pattern should have.

            * If a single ``int``, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the discrete interval ``[a..b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the value to use.

    nb_cols : int or list of int or tuple of int or imgaug.parameters.StochasticParameter, optional
        How many cols the jigsaw pattern should have.

            * If a single ``int``, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the discrete interval ``[a..b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the value to use.

    max_steps : int or list of int or tuple of int or imgaug.parameters.StochasticParameter, optional
        How many steps each jigsaw cell may be moved.

            * If a single ``int``, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a random value will be uniformly
              sampled per image from the discrete interval ``[a..b]``.
            * If a list, then for each image a random value will be sampled
              from that list.
            * If ``StochasticParameter``, then that parameter is queried per
              image to sample the value to use.

    allow_pad : bool, optional
        Whether to allow automatically padding images until they are evenly
        divisible by ``nb_rows`` and ``nb_cols``.

    seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
        Old name for parameter `seed`.
        Its usage will not yet cause a deprecation warning,
        but it is still recommended to use `seed` now.
        Outdated since 0.4.0.

    deterministic : bool, optional
        Deprecated since 0.4.0.
        See method ``to_deterministic()`` for an alternative and for
        details about what the "deterministic mode" actually does.

    Examples
    --------
    >>> import imgaug.augmenters as iaa
    >>> aug = iaa.Jigsaw(nb_rows=10, nb_cols=10)

    Create a jigsaw augmenter that splits images into ``10x10`` cells
    and shifts them around by ``0`` to ``2`` steps (default setting).

    >>> aug = iaa.Jigsaw(nb_rows=(1, 4), nb_cols=(1, 4))

    Create a jigsaw augmenter that splits each image into ``1`` to ``4``
    cells along each axis.

    >>> aug = iaa.Jigsaw(nb_rows=10, nb_cols=10, max_steps=(1, 5))

    Create a jigsaw augmenter that moves the cells in each image by a random
    amount between ``1`` and ``5`` times (decided per image). Some images will
    be barely changed, some will be fairly distorted.

    c	                 ó  •— t         t        | �  ||||¬«       t        j                  |ddddd¬«      | _        t        j                  |ddddd¬«      | _        t        j                  |dd	ddd¬«      | _        || _        y )
Nr1  r¸   )r
   NTFrU  r¹   râ   r3  )	r7  r  rû   r+   rX  r¸   r¹   râ   Ú	allow_pad)
rú   r¸   r¹   râ   r  rã   rV   rå   r2  rE  s
            €r9   rû   zJigsaw.__init__Õ  s”   ø€ ô 	Œf�dÑ$Ø˜DØ%°]ð 	%ô 	Dô ×0Ñ0Ø�Y¨IÈØ¨eô5ˆŒô ×0Ñ0Ø�Y¨IÈØ¨eô5ˆŒô ×2Ñ2Ø�{°	Ø!°$ÀUôLˆŒð #ˆ�rE   c           	      óæ  — | j                  ||«      }| j                  |«      \  }}| j                  rœt        j                  t        |j                  «      «      D ]q  }t        j                  |j                  |   |j                  |   |¬«      }|j                  |g«      }	|j                  |	|| gz   |¬«      }	|j                  |g|	«      }Œs |j                  �9t        |j                  «      D ]!  \  }}
t!        |
|j                  |   «      |
d<   Œ# |j"                  �Et        |j"                  «      D ]-  \  }}t!        |j$                  |j                  |   «      |_        Œ/ |j&                  �Et        |j&                  «      D ]-  \  }}t!        |j(                  |j                  |   «      |_        Œ/ |j*                  �ft        |j*                  «      D ]N  \  }}|j-                  «       }t/        ||j                  |   |j0                  ¬«      |d<   |j3                  |«       ŒP t5        dD �cg c]  }t7        ||«      d u‘Œ c}«      }|rt9        d«      ‚| j;                  ||«      }|S c c}w )N)Úwidth_multipleÚheight_multiplerã   r\  .)rÒ   )rb  rc  rd  zªJigsaw currently only supports augmentation of images, heatmaps, segmentation maps and keypoints. Explicitly not supported are: bounding boxes, polygons and line strings.)re  Ú_resize_mapsr  r‚   r¶   rQ   r·   Úsize_libÚCenterPadToMultiplesOfr¹   r¸   Úsubselect_rows_by_indicesrc  Ú!invert_subselect_rows_by_indices_rf  rÐ   rÍ   rh  r_  rj  r_   ra  rn  rØ   rR   rp  rm  rk  ÚNotImplementedErrorÚ_invert_resize_maps)rú   rr  rå   rs  rt  ru  Úmaps_shapes_origr¿   ÚpadderÚrowr„  ÚheatmapÚsegmapry  Úxyrb  Úhas_other_cbaois                    r9   r{  zJigsaw._augment_batch_é  sl  € Ø×$Ñ$ U¨LÓ9ˆð #'×"3Ñ"3°EÓ":ÑˆÐà�>Š>ô —Y‘Yœs 7×#7Ñ#7Ó8Ö9�Ü!×8Ñ8Ø#*§?¡?°1Ñ#5Ø$+§O¡O°AÑ$6Ø%ô�ð
 ×5Ñ5°q°cÓ:�Ø×+Ñ+¨C¸ÀDÀ6Ñ9IØ27ð ,ó 9�à×?Ñ?ÀÀÀSÓI‘ð :ð �<‰<Ð#Ü% e§l¡lÖ3‘��5Ü)¨%°×1EÑ1EÀaÑ1HÓI��c’
ð 4ð �>‰>Ð%Ü'¨¯©Ö7‘
��7Ü#/°×0@Ñ0@Ø07×0DÑ0DÀQÑ0Gó$I�Õ ð 8ð ×"Ñ"Ð.Ü& u×'>Ñ'>Ö?‘	��6Ü)¨&¯*©*°g×6JÑ6JÈ1Ñ6MÓN�•
ð @ð �?‰?Ð&Ü% e§o¡oÖ6‘��5Ø×&Ñ&Ó(�Ü0°Ø18×1EÑ1EÀaÑ1HØ=B¿[¹[ôJ��3‘ð ×)Ñ)¨"Õ-ð 7ô ñ#3ó4ñ#3ð $-ô  ' u¨iÓ8ÀÒDð#3ñ4ó 5ˆñ Ü%ð$ó%ð %ð ×(Ñ(¨Ð0@ÓAˆàˆùò#4s   È1I.c           	      ót  — |j                   }| j                   j                  |f|¬«      }| j                  j                  |f|¬«      }| j                  j                  |f|¬«      }g }t	        j
                  |«      D ])  }|j                  t        ||   ||   ||   |¬«      «       Œ+ t        ||||«      }	|	S )Nr�  )rã   )	r¸   r¡  r¹   râ   r‚   r¶   r~  rï   Ú_JigsawSamples)
rú   rr  rå   r�  r¸   r¹   râ   r·   r¿   ru  s
             r9   re  zJigsaw._draw_samples2  sÉ   € Ø—M‘Mˆ	Ø—,‘,×+Ñ+¨Y¨LØ9Eð ,ó Gˆà—,‘,×+Ñ+¨Y¨LØ9Eð ,ó Gˆà—N‘N×/Ñ/°°Ø=Ið 0ó Kˆ	àˆÜ—‘˜9Ö%ˆAØ×ÑÜ,Ø˜A‘J ¨¡
¨I°a©LØ%ô'õð &ô ! ¨'°9¸lÓKˆØˆrE   c                 óú   — |j                   €|j                  €|dfS |j                  «       }| j                  |j                   d|«      \  |_         }| j                  |j                  d|«      \  |_        }|||ffS )Nr´  r_  r_   )rh  rj  r�  Ú_resize_maps_single_list)rM  rr  r  Úheatmaps_shapes_origÚsm_shapes_origs        r9   r  zJigsaw._resize_mapsF  s�   € ð �>‰>Ð! e×&=Ñ&=Ð&EØ˜,Ð&Ð&à×/Ñ/Ó1ˆØ/2×/KÑ/KØ�N‰N˜J¨ó06Ñ,ˆŒÐ,à25×2NÑ2NØ×#Ñ# U¨Ló3:Ñ/ˆÔ ð Ð+¨^Ð<Ð<Ð<rE   c                 óØ   — |€yg }g }t        ||«      D ]Q  \  }}t        ||«      j                  }|j                  |dd «      }	|j	                  |	«       |j	                  |«       ŒS ||fS )Nr´  r   r   )r‹  rk  rR   r˜  r~  )
rM  r�  r�  r  rÀ  Úaugms_resizedr’  rÒ   r£  Úaugm_rss
             r9   r#  zJigsaw._resize_maps_single_listU  s€   € ð ÐØàˆØˆÜ(+¨L¸,Ö(GÑ$ˆK˜Ü  ¨mÓ<×BÑBˆJØ!×(Ñ(¨°Q°qÐ)9Ó:ˆGØ× Ñ  Ô)Ø×Ñ˜zÕ*ð	 )Hð
 ˜kÐ)Ð)rE   c                 ó–   — | j                  |j                  |d   «      |_        | j                  |j                  |d   «      |_        |S )Nr   r
   )Ú_invert_resize_maps_single_listrh  rj  )rM  rr  rÀ  s      r9   r  zJigsaw._invert_resize_mapse  sJ   € à×<Ñ<Ø�N‰N˜K¨™Nó,ˆŒà"%×"EÑ"EØ×#Ñ# [°¡^ó#5ˆÔð ˆrE   c                 ó~   — |€y g }t        ||«      D ](  \  }}|j                  |j                  |dd «      «       Œ* |S )Nr   r   )r‹  r~  r˜  )rM  r�  rÀ  r'  r’  r£  s         r9   r*  z&Jigsaw._invert_resize_maps_single_listo  sL   € àÐØàˆÜ'*¨<¸Ö'EÑ#ˆK˜Ø× Ñ  ×!3Ñ!3°J¸qÀ°OÓ!DÕEð (FàÐrE   c                 ó^   — | j                   | j                  | j                  | j                  gS ró   )r¸   r¹   râ   r  r"  s    r9   r­  zJigsaw.get_parametersz  s!   € Ø—‘˜dŸl™l¨D¯N©N¸D¿N¹NÐKÐKrE   )©r   r5  r-  r
   TNNr®  r®  )r$  r%  r&  r°  rû   r{  re  r±  r  r#  r  r*  r­  r²  r³  s   @r9   r  r  i  s�   ø„ ñhðV DEØØ!%Ø:Fõ#ò(FòRð( ñ=ó ð=ð ñ*ó ð*ð ñó ðð ñó ðöLrE   r  c                   ó   — e Zd Zd„ Zy)r!  c                 ó<   — || _         || _        || _        || _        y ró   )r¸   r¹   râ   r·   )rú   r¸   r¹   râ   r·   s        r9   rû   z_JigsawSamples.__init__�  s   € ØˆŒØˆŒØ"ˆŒØ(ˆÕrE   Nr�  r'  rE   r9   r!  r!    s   „ ó)rE   r!  )r
   r   r   Nr$   )r   )rJ  )Qr°  Ú
__future__r   r   r   r  r=  Únumpyr‚   r  r   rO   r   r   r%   Ú	six.movesÚmovesrš   Úimgaugr)   Úimgaug.imgaugr   Úimgaug.augmentables.polysr	   Ú r   r   r  r   r  r   r+   r   rS   r   rÞ   rW   rX   rí  rî  rï  r•   rö  rò  ró  rô  rõ  r“   r:   rD   rM   ri   r[   r\   r±   rÍ   rØ   rï   Úobjectrñ   r-  Ú	Augmenterr/  rµ  r¾  rÁ  rÊ  rÍ  rÒ  rØ  rÛ  r+  r1  r{  rƒ  rÎ  rÕ  r9  rU  r  r!  r'  rE   r9   Ú<module>r:     s\  ðñ÷* AÑ @ã Û ã Ý Ý #Û 
Ý ã Ý 3Ý >Ý Ý Ý Ý  Ý Ý !ò%Ð ò!)Ð ð ×ÑØ
×ÑØ
‡�Ø
‡�Ø
‡�ñ.Ð *ð  ×#Ñ#Ø× Ñ Ø×#Ñ#Ø×%Ñ%Ø�O‰OñÐ ò)9òXò;ð$ BCØ06ó8òvòBHòV òBXòv>ðD /0óGôTi
˜Fô i
óX?ôDAˆT�^‰^ô DAôNJDˆVô JDôZJDˆVô JDô\WD�ô WDôvWD�ô WDôtHDˆVô HDôVHDˆVô HDôVHDˆVô HDôVf
�—‘ô f
ôR Vô ô q,�d—n‘nô q,ôh¨&ô ôC
!˜4Ÿ>™>ô C
!ôL¨6ô ôy˜DŸN™Nô yôxm(ˆD�N‰Nô m(ôby
=�t—~‘~ô y
=ôxRLˆT�^‰^ô RLôl)�Võ )rE   