diff options
author | Christian C <cc@localhost> | 2025-03-05 17:42:37 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-05 17:42:37 -0800 |
commit | b68a9a6263610bb0a5ada53695e025daf1209fcb (patch) | |
tree | d04274b0ad6f4b1a54c4d49e3f93c4e0cb2e0cf9 /src/main.c | |
parent | d0fc2842a790cdd2d11fec8ce667564bc88d057f (diff) |
Get contiguous regions from final mask in case concatenation lead to splitting up masks
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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); |