utils/geometry_processing
module¶
geometry_processing
¶
Functions¶
get_max_iou_shapely
¶
get_max_iou_shapely(ref_box: shapely.geometry.box, target_boxes: list[shapely.geometry.box]) -> tuple[float, int, shapely.geometry.box]
Find the target box with the highest IoU compared to a reference box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_box
|
shapely.geometry.box
|
The reference bounding box. |
required |
target_boxes
|
list of shapely.geometry.box
|
List of candidate boxes. |
required |
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing: - Maximum IoU (float) - Index of the box with the maximum IoU (int) - The corresponding target box (shapely.geometry.box) |
Source code in color_correction/utils/geometry_processing.py
box_to_xyxy
¶
Convert a Shapely box to (x1, y1, x2, y2) format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box
|
shapely.geometry.box
|
Input Shapely box. |
required |
Returns:
Type | Description |
---|---|
tuple[int, int, int, int]
|
Coordinates in (x1, y1, x2, y2) format. |
Source code in color_correction/utils/geometry_processing.py
box_centroid_xy
¶
Get the centroid coordinates of a Shapely box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box
|
shapely.geometry.box
|
Input Shapely box. |
required |
Returns:
Type | Description |
---|---|
tuple[int, int]
|
Coordinates of the centroid (x, y). |
Source code in color_correction/utils/geometry_processing.py
generate_expected_patches
¶
Generate a grid of expected patch coordinates within a card box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
card_box
|
tuple[int, int, int, int]
|
Coordinates of the card in (x1, y1, x2, y2) format. |
required |
Returns:
Type | Description |
---|---|
list[box_tuple]
|
List of patch coordinates arranged in a grid. |
Source code in color_correction/utils/geometry_processing.py
extract_intersecting_patches
¶
extract_intersecting_patches(ls_patches: list[box_tuple], ls_grid_card: list[box_tuple]) -> list[tuple[box_tuple, tuple[int, int]]]
Extract patches that intersect with each grid card and compute centroids.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ls_patches
|
list[box_tuple]
|
List of detected patch coordinates. |
required |
ls_grid_card
|
list[box_tuple]
|
List of grid card coordinates. |
required |
Returns:
Type | Description |
---|---|
list[tuple[box_tuple, tuple[int, int]]]
|
Each element is a tuple of the intersecting patch coordinates and its centroid. |
Source code in color_correction/utils/geometry_processing.py
calculate_patch_statistics
¶
Calculate mean differences in positions and sizes for patches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ls_ordered_patch
|
list[box_tuple]
|
List of patch coordinates. |
required |
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing mean dx, mean dy, mean width, and mean height. |
Source code in color_correction/utils/geometry_processing.py
suggest_missing_patch_coordinates
¶
Suggest coordinates for missing patches based on neighboring patches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ls_ordered_patch
|
list[box_tuple]
|
List of ordered patch coordinates (with None for missing patches). |
required |
Returns:
Type | Description |
---|---|
dict[int, box_tuple]
|
A dictionary where keys are indices of missing patches and values are the suggested coordinates. |
Source code in color_correction/utils/geometry_processing.py
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|