mt.geo2d.similarity2d

Functions

  • cv2cg(): Gets the transformation to convert image coordinates between OpenCV and OpenGL conventions.

mt.geo2d.similarity2d.cv2cg(height: int)

Gets the transformation to convert image coordinates between OpenCV and OpenGL conventions.

OpenCV has y-axis pointing downward. OpenGL has y-axis pointing upward.

Since the transformation and its inverse are the same, you can use the same transformation for both ways.

Parameters:

height (int) – the number of rows of the image coordinate system

Returns:

tfm – The output transformation

Return type:

Sim2d

Notes

This function is essentially the same as mt.geo2d.flipUD2d(), just different return values.

Classes

  • Sim2d: Similarity (angle-preserving) transformation in 2D.

class mt.geo2d.similarity2d.Sim2d(offset=array([0., 0.]), scale=1, angle=0, on=False)

Similarity (angle-preserving) transformation in 2D.

Consider the following family of 2D transformations: y = Sim2d(offset, scale, angle, on)(x) = Translate(offset)*UniformScale(scale)*Rotate(angle)*ReflectX(on)(x), where ‘x’ is a vector of coordinates in 2D, ‘on’ is a boolean, ReflectX is the reflection through the X axis (the axis of the first dimension), ‘angle’ is an angle in radian, Rotate is the 2D rotation, ‘scale’ is a positive scalar, UniformScale is uniform scaling, ‘offset’ is a vector of 2D coordinates and Translate is the translation.

This family forms a Lie group of 2 disconnected components, those without reflection and those with reflection. The Lie group multiplication and inverse operators are derived as below:

  • multiplication: Sim2d(offset_x, scale_x, angle_x, on_x)*Sim2d(offset_y, scale_y, angle_y, on_y) = Sim2d(offset_x + UniformScale(scale_x)*Rotate(angle_x)*ReflectX(on_x)(offset_y), scale_x*scale_y, angle_x + (-1)^{on_x} angle_y, on_x xor on_y)

  • inverse: ~Sim2d(offset, scale, angle, on) = Sim2d(-linear(scale, angle, on) offset, 1/scale, -(-1)^{on} angle, on)

References

[1] Pham et al, Distances and Means of Direct Similarities, IJCV, 2015. (not really, cheeky

MT is trying to advertise his paper!)

Inheritance

digraph inheritance57d4bf973d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Aff" [URL="../mt.geond/mt.geond.affine.html#mt.geond.affine.Aff",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A transformer to perform affine transformations using the same transformation matrix in n-dim space."]; "LieTransformer" -> "Aff" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GeometricObject" -> "Aff" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Dliso" [URL="../mt.geond/mt.geond.dilated_isometry.html#mt.geond.dilated_isometry.Dliso",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Dilated isometry = Isometry following a uniform scaling."]; "Aff" -> "Dliso" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GeometricObject" [URL="../mt.geo/mt.geo.object.html#mt.geo.object.GeometricObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A geometric object which lives in a d-dimensional Euclidean space."]; "InvertibleTransformer" [URL="../mt.geo/mt.geo.transformation.html#mt.geo.transformation.InvertibleTransformer",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A mixin asserting that this is a class of invertible transformers. "]; "Transformer" -> "InvertibleTransformer" [arrowsize=0.5,style="setlinewidth(0.5)"]; "LieTransformer" [URL="../mt.geo/mt.geo.transformation.html#mt.geo.transformation.LieTransformer",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A mixin asserting that this is a class of transformers living in a Lie group, supporting the associative multiplication operator and the inversion operator. "]; "InvertibleTransformer" -> "LieTransformer" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Sim2d" [URL="#mt.geo2d.similarity2d.Sim2d",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Similarity (angle-preserving) transformation in 2D."]; "Dliso" -> "Sim2d" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Transformer" [URL="../mt.geo/mt.geo.transformation.html#mt.geo.transformation.Transformer",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A mixin asserting that this is a class of transformers."]; }
__init__(offset=array([0., 0.]), scale=1, angle=0, on=False)
__repr__()

Return repr(self).

property bias_dim

Returns the dimension of the bias vector.

static get_linear(angle, on, scale=1.0)

Forms the linear part of the transformation matrix representing scaling*rotation*reflection.

invert()

Lie inverse

property linear

Returns the linear part of the affine transformation matrix of the dilated isometry.

multiply(other)

a*b = Lie operator

property unitary

The unitary matrix of the dilated isometry.

property weight_shape

Returns the shape of the weight matrix.