junn.common.functions package¶
Submodules¶
junn.common.functions.affine module¶
Additional affine transformation functions written as TensorFlow-tf.functions.
- junn.common.functions.affine.radians(degrees)¶
Convert degrees to radians.
- Parameters
degrees – Degrees to convert
- Returns
Resulting radians
- junn.common.functions.affine.shape_to_h_w(shape)¶
Extract height and width from a shape tuple with between 1 and 4 dimensions.
- Parameters
shape – The input shape
- Returns
A tuple of height and width.
- junn.common.functions.affine.tfm_identity(shape=(0, 0))¶
Generate an identity matrix for use with the affine transformation matrices.
- Parameters
shape – The parameter is ignored and only present for call-compatibility with the other functions.
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_reflect(x=0.0, y=0.0, shape=(0, 0))¶
Generate a reflection affine transformation matrix.
- Parameters
x – Whether to reflect in horizontal direction, a value of 1 leads to a reflection, any other value not.
y – Whether to reflect in vertical direction, a value of 1 leads to a reflection, any other value not.
shape – The shape of the image to be transformed
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_rotate(angle=0.0, shape=(0, 0))¶
Generate a rotation affine transformation matrix.
- Parameters
angle – The angle to r
shape – The shape of the image to be transformed
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_scale(xs=1.0, ys=None, shape=(0, 0))¶
Generate a scaling affine transformation matrix.
- Parameters
xs – The scale factor for the horizontal direction
ys – The scale factor for the vertical direction, if None, then the image will be uniformly scaled
shape – The shape of the image to be transformed
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_shear(x_angle=0.0, y_angle=0.0, shape=(0, 0))¶
Generate a shear transformation matrix.
- Parameters
x_angle – The angle to shear the image in horizontal direction
y_angle – The angle to shear the image in vertical direction
shape – The shape of the image to be transformed
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_shift(x=0.0, y=0.0, shape=None)¶
Generate a shift affine transformation matrix.
- Parameters
x – Shift value in horizontal direction
y – Shift value in vertical direction
shape – The parameter is ignored and only present for call-compatibility with the other functions.
- Returns
The affine transformation matrix
- junn.common.functions.affine.tfm_to_tf_transform(mat)¶
Truncate an affine transformation matrix to the parameters used by tf transform.
- Parameters
mat – Input matrix
- Returns
Truncated output matrix