diff options
author | Christian C <cc@localhost> | 2025-03-23 17:47:36 -0700 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-23 17:47:36 -0700 |
commit | 848a0f6e2d634001e30cbfebef05d93f7301facd (patch) | |
tree | 45b062c90d59e6f48284bc73c42d17d7fde19740 /lib/seg/mask_data.c | |
parent | 2fe858c22d27722130339c0d26de00aa78ef1f4d (diff) |
Migration to Mask
Diffstat (limited to 'lib/seg/mask_data.c')
-rw-r--r-- | lib/seg/mask_data.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/seg/mask_data.c b/lib/seg/mask_data.c index 97e9165..6033c3b 100644 --- a/lib/seg/mask_data.c +++ b/lib/seg/mask_data.c @@ -227,16 +227,17 @@ AVLNode* get_small_labels(AVLNode* removal_tree, AVLNode* label_tree, size_t min } // Get mask label data -AVLNode* get_mask_data(MaskData_t* masks, uint32_t width, uint32_t height) +AVLNode *get_mask_data(Mask *mask) { + uint32_t width = mask->width; + uint32_t height = mask->height; AVLNode* root = NULL; for (size_t y = 0; y < height; y++) { for (size_t x = 0; x < width; x++) { - size_t coord = x + y*width; - if (masks[coord] != 0) { - root = increase_label_area_alloc(root, masks[coord]); - if (is_on_mask_boundary(masks, width, height, x, y)) { - increase_label_perimeter(root, masks[coord]); + if (mask->image[y][x] != 0) { + root = increase_label_area_alloc(root, mask->image[y][x]); + if (is_on_mask_boundary(mask, x, y)) { + increase_label_perimeter(root, mask->image[y][x]); } } } @@ -245,16 +246,17 @@ AVLNode* get_mask_data(MaskData_t* masks, uint32_t width, uint32_t height) } // Filter out small masks in mask -void filter_small_masks(MaskData_t* masks, uint32_t width, uint32_t height, size_t min_area, size_t min_perimeter) +void filter_small_masks(Mask *mask, size_t min_area, size_t min_perimeter) { - AVLNode* root = get_mask_data(masks, width, height); + uint32_t width = mask->width; + uint32_t height = mask->height; + AVLNode* root = get_mask_data(mask); AVLNode* small_label_tree = NULL; small_label_tree = get_small_labels(NULL, root, min_area, min_perimeter); for (size_t y = 0; y < height; y++) { for (size_t x = 0; x < width; x++) { - size_t coord = x + y*width; - if (in_image_mask_data_t_tree(small_label_tree, masks[coord])) { - masks[coord] = 0; + if (in_image_mask_data_t_tree(small_label_tree, mask->image[y][x])) { + mask->image[y][x] = 0; } } } |