Geometric
Geometry Transformer component
GeometrizerImage
GeometrizerImage class
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
center_to_point(point)
Shift the image so that the input point ends up in the middle of the new image
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
NDArray
|
point as (2,) shape numpy array |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
translation Vector |
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
center_to_segment(segment)
Shift the image so that the segment middle point ends up in the middle of the new image
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment
|
NDArray
|
segment as numpy array of shape (2, 2) |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
vector_shift |
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
restrict_rect_in_frame(rectangle)
Create a new rectangle that is contained within the image borders. If the input rectangle is outside the image, the returned rectangle is a image frame-fitted rectangle that preserve the same shape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rectangle
|
Rectangle
|
input rectangle |
required |
Returns:
Type | Description |
---|---|
Rectangle
|
geo.Rectangle: new rectangle |
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
rotate(angle, is_degree=False, is_clockwise=True, reshape=True, fill_value=(0.0,))
Rotate the image by a given angle.
For the rotation with reshape, meaning preserving the whole image, we used the code from the imutils library: https://github.com/PyImageSearch/imutils/blob/master/imutils/convenience.py#L41
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle
|
float
|
angle to rotate the image |
required |
is_degree
|
bool
|
whether the angle is in degree or not. If not it is considered to be in radians. Defaults to False which means radians. |
False
|
is_clockwise
|
bool
|
whether the rotation is clockwise or counter-clockwise. Defaults to True. |
True
|
reshape
|
bool
|
whether to preserve the original image or not. If True, the complete image is preserved hence the width and height of the rotated image are different than in the original image. Defaults to True. |
True
|
fill_value
|
Sequence[float]
|
value to fill the border of the image after the rotation in case reshape is True. Can be a tuple of 3 integers for RGB image or a single integer for grayscale image. Defaults to (0.0,) which is black. |
(0.0,)
|
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
shift(shift, fill_value=(0.0,))
Shift the image by performing a translation operation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shift
|
NDArray
|
Vector for translation |
required |
fill_value
|
int | tuple[int, int, int]
|
value to fill the border of the image after the rotation in case reshape is True. Can be a tuple of 3 integers for RGB image or a single integer for grayscale image. Defaults to (0.0,) which is black. |
(0.0,)
|