cilissa.transformations - Image transformations and distortions

Classes

class cilissa.transformations.Blur(gaussian: bool = True, kernel_size: Tuple[int, int] = (0, 0), sigma: float = 1.0)[source]

Blurs an image.

Parameters
  • gaussian (bool) – If True, uses a Gaussian filter to blur the image. If False, uses normalized box filter.

  • kernel_size (Tuple[int, int]) – Gaussian/blurring kernel size. Elements in tuple can differ but they both must be positive and odd. If using Gaussian filter they can be zero’s and then they are computed from sigma.

  • sigma (float) – Gaussian kernel standard deviation in X direction. Used only with Gaussian filter.

References

class cilissa.transformations.Sharpen(amount: float = 1.5, kernel_size: Tuple[int, int] = (0, 0), sigma: float = 1.0)[source]

Sharpens an image using an unsharp mask.

Parameters
  • amount (float) – Amount of sharpening applied.

  • threshold (int) – Threshold for the low-constrast mask. Pixels for which the difference between the input and blurred images is less than threshold will remain unchanged.

  • kwargs (Any) – Arguments passed as kwargs will be passed to the blur transformation.

References

class cilissa.transformations.Linear(contrast: Optional[Union[float, int]] = None, brightness: Optional[Union[float, int]] = None)[source]

Changes brightness of the image with a simple linear transformation.

g(x) = a * f(x) + b, where a controls contrast and b controls brightness

Brightness refers to the overall lightness or darkness of the image. Increasing the brightness every pixel in the frame gets lighter.

Contrast is the difference in brightness between objects in the image. Increasing the contrast makes light areas lighter and dark area in the frame becomes much darker.

Parameters
  • contrast (int/float/None) – Value by which to change the contrast. 1 and None is the original image. A float from interval (0, 1) reduces the contrast. Values above 1 increase the contrast.

  • brightness (int/float/None) – Value by which to change the brightness. 0 and None is the original image. Negative values reduce the brightness. Positive values increase the brightness.

References

class cilissa.transformations.Translation(x: int = 0, y: int = 0)[source]

Shifts an image by given amount in pixels along X and/or Y axis.

Uses an affine transformation to perform image translation.

Parameters
  • x (int) – Value (in px) to move the image along X-axis. Positive - right, negative - left.

  • y (int) – Value (in px) to move the image along Y-axis. Positive - down, negative - up.

References

class cilissa.transformations.Equalization(nbins: int = 256)[source]

Constrast adjustment using histogram equalization.

CV2 equalization is limited to 8-bit images so we use the NumPy CDF function.

References