cr.vision.geom_transform package

Submodules

cr.vision.geom_transform.projective2d_actions module

cr.vision.geom_transform.projective2d_actions.rotate(img, theta)[source]

Rotates an image from its center. Adjust the size of the output image so that rotated image is fully contained inside it.

Steps - Estimate the size of the bounding box for the rotated image. - Locate the center of the target image - Rotate the image about its center - Move its center to the target image center

cr.vision.geom_transform.projective2d_actions.translate(img, translation, target_size=None)[source]

Translates an image by a particular amount.

translation: x, y

target_size: w, h

cr.vision.geom_transform.projective2d_matrices module

A set of classes to represent projective transformations

class cr.vision.geom_transform.projective2d_matrices.Identity[source]

Bases: object

An identity transform definition

matrix()[source]

Returns the transformation matrix for identity transformation

class cr.vision.geom_transform.projective2d_matrices.Transform(previous)[source]

Bases: object

A projective transformation matrix definition

matrix()[source]

Returns the transformation matrix

class cr.vision.geom_transform.projective2d_matrices.Translation(previous, t_x, t_y)[source]

Bases: cr.vision.geom_transform.projective2d_matrices.Transform

matrix()[source]

Returns the transformation matrix

cr.vision.geom_transform.scaling module

cr.vision.geom_transform.scaling.resize(image, target_width=None, target_height=None, interpolation=4)[source]

Resize image to target width or height or both

If only target_width is specified, then target_height is automatically calculated. If only target_height is specified, then target_width is automatically calculated. In these two cases, aspect ratio is preserved.

Otherwise, image is resized as per specified target width and height.

cr.vision.geom_transform.scaling.resize_by_height(image, target_height, interpolation=4)[source]

Resize image to target_height (preserving aspect ratio).

cr.vision.geom_transform.scaling.resize_by_width(image, target_width, interpolation=4)[source]

Resize image to target_width (preserving aspect ratio).

Module contents

Package for functions and classes related to geometric transformations of images