peal.data.transformations.CircularCut

class peal.data.transformations.CircularCut[source]

Bases: object

Black out everything outside the ellipse inscribed in a PIL image.

A white ellipse spanning the full image is rasterized with pygame and combined with the input by an element-wise minimum, so pixels outside the ellipse become black while the inside is unchanged.

Methods

__call__(sample)[source]

Apply the elliptical cut.

Parameters:

sample (PIL.Image.Image) – RGB input image.

Returns:

Image with the corners outside the inscribed ellipse set to black.

Return type:

PIL.Image.Image

Raises:

ImportError – If the optional pygame dependency is not installed.