Geometric
Geometry Transformer component
GeometrizerImage
GeometrizerImage class
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
__rotate_exact(angle, is_degree=False, is_clockwise=True, reshape=True, border_fill_value=0.0)
Rotate the image by a given angle. This method is more accurate than the rotate method but way slower (about 10 times slower).
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
|
scipy reshape option. Defaults to True. |
True
|
border_fill_value
|
float
|
value to fill the border of the image after the rotation in case reshape is True. Can only be a single integer. Does not support tuple of 3 integers for RGB image. Defaults to 0.0 which is black. |
0.0
|
Source code in otary/image/components/transformer/components/geometrizer/geometrizer.py
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,), fast=True)
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
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 165 166 |
|
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,)
|