Morphological
Morphologyzer Transformer component
MorphologyzerImage
MorphologyzerImage.
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
add_border(size, fill_value=0)
Add a border to the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
int
|
border thickness in all directions (top, bottom, left, right). |
required |
fill_value
|
int
|
border color as filled value. Defaults to 0. |
0
|
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
blur(kernel=(5, 5), iterations=1, method='average', sigmax=0)
Blur the image
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
tuple
|
blur kernel size. Defaults to (5, 5). |
(5, 5)
|
iterations
|
int
|
number of iterations. Defaults to 1. |
1
|
method
|
str
|
blur method. Must be in ["average", "median", "gaussian", "bilateral"]. Defaults to "average". |
'average'
|
sigmax
|
float
|
sigmaX value for the gaussian blur. Defaults to 0. |
0
|
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
dilate(kernel=(5, 5), iterations=1, dilate_black_pixels=True)
Dilate the image by making the black pixels expand in the image. The dilatation can be parametrize thanks to the kernel and iterations arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
tuple
|
kernel to dilate. Defaults to (5, 5). |
(5, 5)
|
iterations
|
int
|
number of dilatation iterations. Defaults to 1. |
1
|
dilate_black_pixels
|
bool
|
whether to dilate black pixels or not |
True
|
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
erode(kernel=(5, 5), iterations=1, erode_black_pixels=True)
Erode the image by making the black pixels shrink in the image. The anti-dilatation can be parametrize thanks to the kernel and iterations arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
tuple
|
kernel to erode. Defaults to (5, 5). |
(5, 5)
|
iterations
|
int
|
number of iterations. Defaults to 1. |
1
|
erode_black_pixels
|
bool
|
whether to erode black pixels or not |
True
|
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
resize(factor, interpolation=cv2.INTER_AREA, copy=False)
Resize the image to a new size using a scaling factor value that will be applied to all dimensions (width and height).
Applying this method can not result in a distorted image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor
|
float
|
factor in [0, 5] to resize the image. A value of 1 does not change the image. A value of 2 doubles the image size. A maximum value of 5 is set to avoid accidentally producing a gigantic image. |
required |
interpolation
|
int
|
resize interpolation. Defaults to cv2.INTER_AREA. |
INTER_AREA
|
copy
|
bool
|
whether to return a new image or not. |
False
|
Source code in otary/image/components/transformer/components/morphologyzer/morphologyzer.py
resize_fixed(dim, interpolation=cv2.INTER_AREA, copy=False)
Resize the image using a fixed dimension well defined. This function can result in a distorted image if the ratio between width and height is different in the original and the new image.
If the dim argument has a negative value in height or width, then a proportional ratio is applied based on the one of the two dimension given.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
tuple[int, int]
|
a tuple with two integers in the following order (width, height). |
required |
interpolation
|
int
|
resize interpolation. Defaults to cv2.INTER_AREA. |
INTER_AREA
|
copy
|
bool
|
whether to return a new image or not. |
False
|