+
    ùäûj  ã                   ót   € ^ RI HtHt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  ! R R]4      tR# )	é    )ÚAnyÚDictÚListÚOptionalÚTupleÚUnionN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_clamp_unit_range)Úsolarizec                   ó\   a a€ ] tR t^t oRtRV3R lV 3R llltRV3R lR lltRtVtV ;t	# )	ÚRandomSolarizeaŽ  Solarize images at a random threshold and addition, applied per sample with probability ``p`` (default 0.5).

``output = RandomSolarize(thresholds, additions, ...)(input)`` offsets then inverts selected image values above a
sampled threshold, after clamping the selected input to ``[0, 1]``.

.. image:: _static/img/RandomSolarize.png

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

Args:
    p: probability of applying the transformation to each sample.
    thresholds:
        If float x, threshold will be generated from (0.5 - x, 0.5 + x).
        If tuple (x, y), threshold will be generated from (x, y).
    additions:
        If float x, addition will be generated from (-x, x).
        If tuple (x, y), addition will be generated from (x, y).
    same_on_batch: apply the same transformation across the batch.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).

Shape:
    - Input: ``(C, H, W)`` or ``(B, C, H, W)``, Optional: ``(B, 3, 3)``
    - Output: ``(B, C, H, W)``

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 addition comes first: the drawn ``additions`` value is added to the whole image and the sum
      is clamped into ``[0, 1]``, and only then is everything at or above the drawn ``thresholds``
      replaced by ``1 - value``.
    - the scalar forms are centered, not absolute: a scalar ``thresholds`` is a half-width around
      ``0.5`` and a scalar ``additions`` a half-width around ``0``, so the class defaults center on
      :func:`kornia.enhance.solarize`'s own default threshold rather than equalling it.
    - an explicit ``additions`` range is checked against the closed ``[-0.5, 0.5]`` at construction, so a
      range that reaches an endpoint is applied rather than rejected.

.. note::
    This function internally uses :func:`kornia.enhance.solarize`.

See Also:
    - :class:`RandomInvert`: inverts every pixel rather than values above a threshold.
    - :class:`RandomPosterize`: reduces bit depth rather than applying a threshold.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 5, 5)
    >>> solarize = RandomSolarize(0.1, 0.1, p=1.)
    >>> solarize(input)
    tensor([[[[0.4132, 0.1412, 0.1790, 0.2226, 0.3980],
              [0.2754, 0.4194, 0.0130, 0.4538, 0.2771],
              [0.4394, 0.4923, 0.1129, 0.2594, 0.3844],
              [0.3909, 0.2118, 0.1094, 0.2516, 0.3728],
              [0.2278, 0.0000, 0.4876, 0.0353, 0.5100]]]])

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> input = torch.randn(1, 3, 32, 32)
    >>> aug = RandomSolarize(0.1, 0.1, p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

c                óì   <€ V ^8„  d   QhRS[ S[P                  S[S[S[S[3,          S[S[,          3,          RS[ S[P                  S[S[S[S[3,          S[S[,          3,          RS[RS[RS[RR/# )é   Ú
thresholdsÚ	additionsÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚtorchÚTensorÚfloatr   r   Úbool)ÚformatÚ__classdict__s   "€ÚfC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\solarize.pyÚ__annotate__ÚRandomSolarize.__annotate__\   s…   ø€ ÷ 
ñ 
á™%Ÿ,™,©©u±U¹E°\Õ/BÁDÉÅKÐOÕPð
ñ ™Ÿ™¡u©e±E¹5°LÕ.AÁ4ÉÅ;ÐNÕOð
ñ ð	
ñ
 ð
ñ ð
ð 
ñ
ó    c                ór   <€ \         SV `  WCVR 7       \        P                  ! VRRR3VRRR34      V n        R# ))r   r   r   r   ç      à?ç        r   N)r#   g      ð?)g      à¿r"   )ÚsuperÚ__init__ÚrgÚPlainUniformGeneratorÚ_param_generator)Úselfr   r   r   r   r   Ú	__class__s   &&&&&&€r   r%   ÚRandomSolarize.__init__\   sC   ø€ ô 	‰Ñ˜1À7ÐÔKÜ "× 8Ò 8Ø˜ s¨JÐ7¸)À[ÐRUÐWbÐ9có!
ˆÖ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   ÚinputÚparamsÚflagsÚ	transformr   )r   r   r   Ústrr   r   )r   r   s   "€r   r   r   i   sd   ø€ ÷ 6ñ 6á�|‰|ð6ñ ‘S™%Ÿ,™,Ð&Õ'ð6ñ ‘C™�H�~ð	6ñ
 ™EŸL™LÕ)ð6ñ 
�‰ñ6r    c                ód   € \        V4      pVR ,          pVP                  R4      p\        WV4      # )r   r   )r   Úgetr   )r)   r-   r.   r/   r0   r   r   s   &&&&&  r   Úapply_transformÚRandomSolarize.apply_transformi   s3   € ô " %Ó(ˆØ˜LÕ)ˆ
à—J‘J˜{Ó+ˆ	Ü˜¨9Ó5Ð5r    )r(   )çš™™™™™¹?r6   Fr"   F)N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   r4   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r*   r   s   @@r   r   r      s$   ù‡ € ñ=÷~
õ 
÷6÷ 6ò 6r    r   )Útypingr   r   r   r   r   r   r   Úkornia.augmentationr	   r&   Ú&kornia.augmentation._2d.intensity.baser
   Úkornia.core.utilsr   Úkornia.enhancer   r   © r    r   Ú<module>rE      s+   ð÷$ ;× :ã å 6Ý NÝ /Ý #ôX6Ð0ö X6r    