1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
|
#ifndef INC_LIB_SEG_MASK_DATA_H
#define INC_LIB_SEG_MASK_DATA_H
#include <lib/algo/avl_tree.h>
#include <lib/data/image_types.h>
#include <lib/monad.h>
typedef struct MaskData {
MaskData_t label;
size_t area;
size_t perimeter;
} MaskData;
// Allocate Mask Data for Label
MaskData* create_mask_data(MaskData_t label);
// Compare mask data labels
bool_t compare_labels(MaskData* left, MaskData* right);
// Create AVL Mask node
AVLNode* create_avl_mask_node(MaskData* data);
// Insert MaskData into the AVL Tree
Result insert_mask(AVLNode* node, MaskData* data);
// Allocate a label's Mask data in a tree
// If it already exists, skip the allocation
AVLNode* insert_mask_alloc(AVLNode* node, MaskData_t label);
// Print AVL Node Mask Data Label
void print_label(AVLNode* root);
// Increase the label's area
bool_t increase_label_area(AVLNode* root, MaskData_t label);
// Increase the label's perimeter
bool_t increase_label_perimeter(AVLNode* root, MaskData_t label);
// Increase the label's area
// Create an AVL node if it doesn't exist
AVLNode* increase_label_area_alloc(AVLNode* root, MaskData_t label);
// Increase the label's perimeter
// Create an AVL node if it doesn't exist
AVLNode* increase_label_perimeter_alloc(AVLNode* root, MaskData_t label);
// Comparison of MaskData_ts
bool_t compare_image_mask_data_t(MaskData_t* s1, MaskData_t* s2);
// In-order traversal print pointer
void print_in_order_image_mask_data_t(AVLNode* root);
// Check if MaskData_t in AVLTree with MaskData_t* data
bool_t in_image_mask_data_t_tree(AVLNode* root, MaskData_t value);
// Filter out small masks
// Assumption: Contiguous labeling
AVLNode* get_small_labels(AVLNode* removal_tree, AVLNode* label_tree, size_t min_area, size_t min_perimeter);
// Get mask label data
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);
#endif
|