aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-05 17:42:37 -0800
committerChristian C <cc@localhost>2025-03-05 17:42:37 -0800
commitb68a9a6263610bb0a5ada53695e025daf1209fcb (patch)
treed04274b0ad6f4b1a54c4d49e3f93c4e0cb2e0cf9 /src
parentd0fc2842a790cdd2d11fec8ce667564bc88d057f (diff)
Get contiguous regions from final mask in case concatenation lead to splitting up masks
Diffstat (limited to 'src')
-rw-r--r--src/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 1709452..e199c43 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,6 +60,25 @@ int main(int argc, char** argv)
fprintf(stderr, "No masks found!\n");
return 1;
}
+ starting_label = 1;
+ uint16_t* labels = (uint16_t*)calloc(width*height, sizeof(uint16_t));
+ if (labels == NULL) {
+ fprintf(stderr, "Memory allocation error\n");
+ free(masks);
+ }
+ for (size_t y = 0; y < height; y++) {
+ for (size_t x = 0; x < width; x++) {
+ size_t coord = x + y*width;
+ uint8_t channels = 2;
+ if (flood((uint8_t*)masks, labels, width, height, channels, x, y, &(((uint8_t*)masks)[coord*channels]), starting_label)) {
+ starting_label++;
+ }
+ }
+ }
+ uint16_t *temp = labels;
+ labels = masks;
+ masks = temp;
+ free(labels);
printf("%u labels found\n", starting_label-1);
printf("Mask dimensions: %u %u\n", width, height);
TIME(ts_start);