BinarizeByQuantile

class hybrid_learning.datasets.transforms.image_transforms.BinarizeByQuantile(quantile=None, num_pixels=None)[source]

Bases: ImageTransform

Set all but the given highest number of pixels / q-th quantile in an image to zero, rest to 1. Mind for RGB images: A pixel here means a pixel in one channel.

Public Data Attributes:

settings

Settings to reproduce the instance.

Inherited from : py: class:Transform

IDENTITY_CLASS

The identity class or classes for composition / addition.

settings

Settings to reproduce the instance.

Public Methods:

apply_to(img)

Binarize img by setting a quantile or number of pixels to one, the rest to 0.

Inherited from : py: class:ImageTransform

apply_to(img)

Binarize img by setting a quantile or number of pixels to one, the rest to 0.

Inherited from : py: class:Transform

apply_to(img)

Binarize img by setting a quantile or number of pixels to one, the rest to 0.

Special Methods:

__init__([quantile, num_pixels])

Init.

Inherited from : py: class:ImageTransform

__call__(img)

Application of transformation.

Inherited from : py: class:Transform

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

__copy__()

Return a shallow copy of self using settings.

__add__(other)

Return a flat composition of self with other.

__radd__(other)

Return a flat composition of other and self.

__call__(img)

Application of transformation.


Parameters
  • quantile (float) –

  • num_pixels (int) –

__init__(quantile=None, num_pixels=None)[source]

Init.

Parameters
  • quantile (Optional[float]) – quantile of pixels to set to 1, rest is set to 0; overridden by num_pixels

  • num_pixels (Optional[int]) – number of pixels with highest value to set to one, rest is set to 0

apply_to(img)[source]

Binarize img by setting a quantile or number of pixels to one, the rest to 0. See quantile respectively num_pixels.

Parameters

img (Tensor) – target tensor to binarize

Return type

Tensor

num_pixels: float

Number of pixels with highest values to set to one.

quantile: float

Quantile of pixels to set to one, rest is set to 0; overridden by num_pixels

property settings: Dict[str, Any]

Settings to reproduce the instance.