+
    ùäûj¨3  ã                   óÄ   € ^ RI HtHtHtHt ^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHt RR R	 lltR
 R lt ! R R]
4      t ! R R]
4      t ! R R]
4      tR# )é    )ÚAnyÚDictÚOptionalÚTupleN)Úrandom_generator)ÚIntensityAugmentationBase2D)Údiamond_square)Ú_clamp_unit_rangeÚ_to_device_nonblocking)Ú_clip_unit_freshc                óì   € V ^8„  d   QhR\         \        R3,          R\        P                  R\        P                  R\        P
                  R\        \        ,          R\        R\        P                  /# )	é   Úshape.Ú	roughnessÚdeviceÚdtypeÚchannelsÚsame_on_batchÚreturn)r   ÚintÚtorchÚTensorr   r   r   Úbool)Úformats   "ÚdC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\plasma.pyÚ__annotate__r      ss   € ÷ Jñ JÜ”�c��?ðJä�|‰|ðJô �L‰LðJô �;‰;ð	Jô
 ”s�mðJô ðJô ‡\�\ñJó    c                 óD  € \        V 4      ^8X  d   V w  rgr‰M'\        V 4      ^8X  d	   V w  rhp	^pM\        RV  R24      hVf   TMTp
T;'       d    V^8„  pV'       d   ^MTpV'       d
   VR,          MTp\        WÊW‰3WÒVR7      pV'       d   VP                  VRRR4      # T# )é   zExpected a 3D or 4D shape. Got Ú.:Né   N©r   r   éÿÿÿÿ)ÚlenÚ
ValueErrorr	   Úexpand)r   r   r   r   r   r   Ú
batch_sizeÚshape_channelsÚheightÚwidthÚnum_channelsÚ	share_mapÚmap_batch_sizeÚmap_roughnessÚplasmas   &&&&&&         r   Ú_generate_plasmar0      s­   € ô ˆ5ƒz�Q„Ø49Ñ1ˆ
 F¨EÜ	ˆU‹�qŒØ$)Ñ!ˆ
˜EØ‰äÐ:¸5¸'ÀÐCÓDÐDà%-Ò%5‘>¸8€LØ×0Ð0 *¨q¡.€Iß#‘Q¨€Nß%.�I˜b–M°I€MÜ˜^¸6ÐIÈ=ÐotÔu€Fß4=ˆ6�=‰=˜ R¨¨RÓ0ÐIÀ6ÐIr   c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r   r/   Úimager   )r   r   )r   s   "r   r   r   5   s2   € ÷ pñ pœeŸl™lð p´5·<±<ð pÄEÇLÁLñ pr   c                 ó¤   € \        V R RVP                  R,          1RVP                  R,          13,          VP                  VP                  4      # ).Néþÿÿÿr#   )r   r   r   r   )r/   r2   s   &&r   Ú_plasma_for_inputr5   5   sG   € Ü! &¨Ð.?°·±¸BµÐ.?ÐARÀ5Ç;Á;ÈrÅ?ÐARÐ)RÕ"SÐUZ×UaÑUaÐch×cnÑcnÓoÐor   c                   ót   a a€ ] tR t^9t oRtR	V3R lV 3R llltV3R lV 3R lltR
V3R lR lltRtVt	V ;t
# )ÚRandomPlasmaBrightnessa6  Shift brightness by a diamond-square fractal map, applied per sample with probability ``p`` (default 0.5).

``output = RandomPlasmaBrightness(roughness, intensity, ...)(input)`` adds a sampled fractal field to each
selected image ``(B, C, H, W)`` and clamps it to ``[0, 1]``.

.. image:: _static/img/RandomPlasmaBrightness.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.

This is based on the original paper: TorMentor: Deterministic dynamic-path, data augmentations with fractals.
See: :cite:`tormentor` for more details.

.. note::
    This function internally uses :func:`kornia.contrib.diamond_square`.

Args:
    roughness: value to scale during the recursion in the generation of the fractal map.
    intensity: value that scales the intensity values of the generated maps.
    same_on_batch: apply the same transformation across the batch.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).

Convention:
    - input values are clamped into ``[0, 1]`` before the operation, and the result is clamped
      into the same range. This applies only to samples selected by the probability gate.
    - the sampled fractal map is recorded as ``_params["plasma"]``, so a forward replayed with ``params=``
      reproduces the first output bitwise.
    - the result is clamped into ``[0, 1]``, so the output stays inside that range even when the input
      does not.
    - a one-pixel spatial axis is accepted, down to a ``1 x 1`` image.

See Also:
    - :class:`RandomGaussianIllumination`: uses a smooth Gaussian field instead of a fractal field.
    - :class:`RandomLinearIllumination`: uses a linear illumination ramp.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> img = torch.ones(1, 1, 3, 4)
    >>> RandomPlasmaBrightness(roughness=(0.1, 0.7), p=1.)(img)
    tensor([[[[0.3677, 0.5169, 0.4346, 0.6906],
              [0.7740, 0.7483, 0.7752, 0.9332],
              [1.0000, 0.9797, 0.9848, 1.0000]]]])

c                óh   <€ V ^8„  d   QhRS[ S[S[3,          RS[ S[S[3,          RS[RS[RS[RR/# )r   r   Ú	intensityr   ÚpÚkeepdimr   N©r   Úfloatr   )r   Ú__classdict__s   "€r   r   Ú#RandomPlasmaBrightness.__annotate__h   sY   ø€ ÷ 
ñ 
á™¡˜Õ&ð
ñ ™¡˜Õ&ð
ñ ð	
ñ
 ð
ñ ð
ð 
ñ
r   c                ót   <€ \         SV `  WCR VR7       \        P                  ! VRRR3VRRR34      V n        R# )ç      ð?©r:   r   Úp_batchr;   r   Nr9   ©ÚsuperÚ__init__ÚrgÚPlainUniformGeneratorÚ_param_generator)Úselfr   r9   r   r:   r;   Ú	__class__s   &&&&&&€r   rF   ÚRandomPlasmaBrightness.__init__h   sE   ø€ ô 	‰Ñ˜1À3ÐPWÐÔXÜ "× 8Ò 8Ø˜ T¨4Ð0°9¸kÈ4ÐQUÐ2Vó!
ˆÖr   c                ód   <€ V ^8„  d   QhRS[ S[R3,          RS[S[S[P
                  3,          /# ©r   r   .r   ©r   r   r   Ústrr   r   )r   r>   s   "€r   r   r?   u   ó1   ø€ ÷ ñ ©©s°C¨x­ð ¹TÁ#ÁuÇ|Á|ÐBSÕ=Tñ r   c                óâ   <€ \         SV `  V4      pVR ,          P                  V P                  V P                  R7      p\        WV P                  V P                  V P                  R7      VR&   V# ©r   r"   )r   r/   ©rE   Úgenerate_parametersÚtor   r   r0   r   ©rJ   r   Úparamsr   rK   s   &&  €r   rU   Ú*RandomPlasmaBrightness.generate_parametersu   ó]   ø€ Ü‘Ñ,¨UÓ3ˆØ˜;Õ'×*Ñ*°$·+±+ÀTÇZÁZÐ*ÓPˆ	Ü+¨E¸d¿k¹kÈ4Ï:É:Ðei×ewÑewÔxˆˆxÑØˆr   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# ©r   r2   rX   ÚflagsÚ	transformr   ©r   r   r   rP   r   r   )r   r>   s   "€r   r   r?   {   sd   ø€ ÷ 8ñ 8á�|‰|ð8ñ ‘S™%Ÿ,™,Ð&Õ'ð8ñ ‘C™�H�~ð	8ñ
 ™EŸL™LÕ)ð8ñ 
�‰ñ8r   c                ó   € \        V4      p\        VR ,          VP                  VP                  4      P	                  R^^^4      p^\        VR,          V4      ,          ^,
          pWe,          p\        W,           4      # )r9   r/   r#   )r
   r   r   r   Úviewr5   r   )rJ   r2   rX   r]   r^   r9   Úbrightness_maps   &&&&&  r   Úapply_transformÚ&RandomPlasmaBrightness.apply_transform{   sp   € ô " %Ó(ˆÜ*¨6°+Õ+>ÀÇÁÈeÏkÉkÓZ×_Ñ_Ð`bÐdeÐghÐjkÓlˆ	ØÔ.¨v°hÕ/?ÀÓGÕGÈ!ÕKˆØ'Õ3ˆÜ Õ 6Ó7Ð7r   ©rI   )©gš™™™™™¹?gffffffæ?©ç        rA   Fç      à?F©N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rF   rU   rc   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©rK   r>   s   @@r   r7   r7   9   s.   ù‡ € ñ,÷\
õ 
÷ó ÷8÷ 8ò 8r   r7   c                   ót   a a€ ] tR t^‰t oRtR	V3R lV 3R llltV3R lV 3R lltR
V3R lR lltRtVt	V ;t
# )ÚRandomPlasmaContrasta¾  Scale contrast by a diamond-square fractal map, applied per sample with probability ``p`` (default 0.5).

``output = RandomPlasmaContrast(roughness, ...)(input)`` scales contrast locally with a sampled fractal field on
selected ``(B, C, H, W)`` images.

.. image:: _static/img/RandomPlasmaContrast.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.

This is based on the original paper: TorMentor: Deterministic dynamic-path, data augmentations with fractals.
See: :cite:`tormentor` for more details.

.. note::
    This function internally uses :func:`kornia.contrib.diamond_square`.

Args:
    roughness: value to scale during the recursion in the generation of the fractal map.
    same_on_batch: apply the same transformation across the batch.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).

Convention:
    - input values are clamped into ``[0, 1]`` before the operation, and the result is clamped
      into the same range. This applies only to samples selected by the probability gate.
    - the sampled fractal map is recorded as ``_params["plasma"]``, so a forward replayed with ``params=``
      reproduces the first output bitwise.
    - the result is clamped into ``[0, 1]``, so the output stays inside that range even when the input
      does not.
    - a one-pixel spatial axis is accepted, down to a ``1 x 1`` image.

See Also:
    - :class:`RandomPlasmaBrightness`: offsets brightness with a fractal map.
    - :class:`RandomPlasmaShadow`: uses a fractal map to darken selected areas.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> img = torch.ones(1, 1, 3, 4)
    >>> RandomPlasmaContrast(roughness=(0.1, 0.7), p=1.)(img)
    tensor([[[[1.0000, 1.0000, 0.6770, 0.8711],
              [1.0000, 1.0000, 1.0000, 1.0000],
              [1.0000, 1.0000, 1.0000, 1.0000]]]])

c          
      óL   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RR/# )r   r   r   r:   r;   r   Nr<   )r   r>   s   "€r   r   Ú!RandomPlasmaContrast.__annotate__·   sM   ø€ ÷ _ñ _á™¡˜Õ&ð_ñ ð_ñ ð	_ñ
 ð_ð 
ñ_r   c                ój   <€ \         SV `  W2R VR7       \        P                  ! VRRR34      V n        R# )rA   rB   r   NrD   )rJ   r   r   r:   r;   rK   s   &&&&&€r   rF   ÚRandomPlasmaContrast.__init__·   s8   ø€ ô 	‰Ñ˜1À3ÐPWÐÔXÜ "× 8Ò 8¸)À[ÐRVÐX\Ð9]Ó ^ˆÖr   c                ód   <€ V ^8„  d   QhRS[ S[R3,          RS[S[S[P
                  3,          /# rN   rO   )r   r>   s   "€r   r   rx   Á   rQ   r   c                óâ   <€ \         SV `  V4      pVR ,          P                  V P                  V P                  R7      p\        WV P                  V P                  V P                  R7      VR&   V# rS   rT   rW   s   &&  €r   rU   Ú(RandomPlasmaContrast.generate_parametersÁ   rZ   r   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# r\   r_   )r   r>   s   "€r   r   rx   Ç   sk   ø€ ÷ 	Dñ 	Dá�|‰|ð	Dñ ‘S™%Ÿ,™,Ð&Õ'ð	Dñ ‘C™�H�~ð		Dñ
 ™EŸL™LÕ)ð	Dñ 
�‰ñ	Dr   c                óŒ   € \        V4      p^\        VR,          V4      ,          p\        VR,
          V,          R,           4      # )r   r/   ri   )r
   r5   r   )rJ   r2   rX   r]   r^   Úcontrast_maps   &&&&& r   rc   Ú$RandomPlasmaContrast.apply_transformÇ   s>   € ô " %Ó(ˆØÔ,¨V°HÕ-=¸uÓEÕEˆÜ ¨¥°Õ <¸sÕ BÓCÐCr   re   )rf   Fri   Frj   rk   rt   s   @@r   rv   rv   ‰   s3   ù‡ € ñ+÷Z_õ _÷ó ÷	D÷ 	Dò 	Dr   rv   c                   ót   a a€ ] tR t^Ót oRtR	V3R lV 3R llltV3R lV 3R lltR
V3R lR lltRtVt	V ;t
# )ÚRandomPlasmaShadowaz  Add shadows from a diamond-square fractal map, applied per sample with probability ``p`` (default 0.5).

``output = RandomPlasmaShadow(roughness, shade_intensity, ...)(input)`` darkens areas chosen by a sampled
fractal field in selected ``(B, C, H, W)`` images.

.. image:: _static/img/RandomPlasmaShadow.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.

This is based on the original paper: TorMentor: Deterministic dynamic-path, data augmentations with fractals.
See: :cite:`tormentor` for more details.

.. note::
    This function internally uses :func:`kornia.contrib.diamond_square`.

Args:
    roughness: value to scale during the recursion in the generation of the fractal map.
    shade_intensity: value that scales the intensity values of the generated maps.
    shade_quantity: value to select the pixels to mask.
    same_on_batch: apply the same transformation across the batch.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).

Convention:
    - input values are clamped into ``[0, 1]`` before the operation, and the result is clamped
      into the same range. This applies only to samples selected by the probability gate.
    - the sampled fractal map is recorded as ``_params["plasma"]`` with a single channel, ``(B, 1, H, W)``: one
      shade mask is applied to every channel of a sample. A forward replayed with ``params=`` reproduces the
      first output bitwise.
    - the result is clamped into ``[0, 1]``, so the output stays inside that range even when the input
      does not.
    - a one-pixel spatial axis is accepted, down to a ``1 x 1`` image.

See Also:
    - :class:`RandomPlasmaBrightness`: offsets brightness with a fractal map.
    - :class:`RandomPlasmaContrast`: scales contrast with a fractal map.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> img = torch.ones(1, 1, 3, 4)
    >>> RandomPlasmaShadow(roughness=(0.1, 0.7), p=1.)(img)
    tensor([[[[1., 1., 1., 1.],
              [1., 1., 1., 1.],
              [1., 1., 1., 1.]]]])

c                ó„   <€ V ^8„  d   QhRS[ S[S[3,          RS[ S[S[3,          RS[ S[S[3,          RS[RS[RS[RR/# )	r   r   Úshade_intensityÚshade_quantityr   r:   r;   r   Nr<   )r   r>   s   "€r   r   ÚRandomPlasmaShadow.__annotate__  sl   ø€ ÷ 
ñ 
á™¡˜Õ&ð
ñ ™u¡e˜|Õ,ð
ñ ™e¡U˜lÕ+ð	
ñ
 ð
ñ ð
ñ ð
ð 
ñ
r   c                ó~   <€ \         SV `  WTR VR7       \        P                  ! VRRR3VRRR3VRRR34      V n        R# )rA   rB   r   Nr…   r†   rD   )rJ   r   r…   r†   r   r:   r;   rK   s   &&&&&&&€r   rF   ÚRandomPlasmaShadow.__init__  sS   ø€ ô 	‰Ñ˜1À3ÐPWÐÔXÜ "× 8Ò 8Ø˜ T¨4Ð0ØÐ/°°tÐ<ØÐ-¨t°TÐ:ó!
ˆÖr   c                ód   <€ V ^8„  d   QhRS[ S[R3,          RS[S[S[P
                  3,          /# rN   rO   )r   r>   s   "€r   r   r‡     s1   ø€ ÷ ñ ©©s°C¨x­ð ¹TÁ#ÁuÇ|Á|ÐBSÕ=Tñ r   c           	     óä   <€ \         SV `  V4      pVR ,          P                  V P                  V P                  R7      p\        WV P                  V P                  ^V P                  R7      VR&   V# )r   r"   )r   r   r/   rT   rW   s   &&  €r   rU   Ú&RandomPlasmaShadow.generate_parameters  sd   ø€ Ü‘Ñ,¨UÓ3ˆØ˜;Õ'×*Ñ*°$·+±+ÀTÇZÁZÐ*ÓPˆ	Ü+Ø˜dŸk™k¨4¯:©:ÀÐQU×QcÑQcô
ˆˆxÑð ˆr   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# r\   r_   )r   r>   s   "€r   r   r‡     sd   ø€ ÷ 3ñ 3á�|‰|ð3ñ ‘S™%Ÿ,™,Ð&Õ'ð3ñ ‘C™�H�~ð	3ñ
 ™EŸL™LÕ)ð3ñ 
�‰ñ3r   c                ó�  € \        V4      p\        VR ,          VP                  VP                  4      P	                  R^^^4      p\        VR,          VP                  VP                  4      P	                  R^^^4      p\        VR,          V4      pWv8  P                  VP                  4      V,          p\        W,           4      # )r…   r†   r/   r#   )r
   r   r   r   ra   r5   rV   r   )rJ   r2   rX   r]   r^   r…   r†   Ú	shade_maps   &&&&&   r   rc   Ú"RandomPlasmaShadow.apply_transform  s±   € ô " %Ó(ˆÜ0°Ð8IÕ1JÈEÏLÉLÐZ_×ZeÑZeÓf×kÑkÐlnÐpqÐstÐvwÓxˆÜ/°Ð7GÕ0HÈ%Ï,É,ÐX]×XcÑXcÓd×iÑiÐjlÐnoÐqrÐtuÓvˆÜ% f¨XÕ&6¸Ó>ˆ	ØÑ/×3Ñ3°E·K±KÓ@À?ÕRˆ	Ü Õ 1Ó2Ð2r   re   )rf   )g      ð¿rh   rg   Fri   Frj   rk   rt   s   @@r   rƒ   rƒ   Ó   s.   ù‡ € ñ.÷`
õ 
÷ ó ÷3÷ 3ò 3r   rƒ   )NF)Útypingr   r   r   r   r   Úkornia.augmentationr   rG   Ú&kornia.augmentation._2d.intensity.baser   Úkornia.contribr	   Úkornia.core.utilsr
   r   Úkornia.enhance.adjustr   r0   r5   r7   rv   rƒ   © r   r   Ú<module>r˜      s\   ð÷$ .Ó -ã å 6Ý NÝ )ß GÝ 2÷Jõ0pôM8Ð8ô M8ô`GDÐ6ô GDôTU3Ð4ö U3r   