diff options
Diffstat (limited to 'src')
-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); |