aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-23 17:47:36 -0700
committerChristian C <cc@localhost>2025-03-23 17:47:36 -0700
commit848a0f6e2d634001e30cbfebef05d93f7301facd (patch)
tree45b062c90d59e6f48284bc73c42d17d7fde19740 /src
parent2fe858c22d27722130339c0d26de00aa78ef1f4d (diff)
Migration to Mask
Diffstat (limited to 'src')
-rw-r--r--src/prog.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/prog.c b/src/prog.c
index 3335268..0f59530 100644
--- a/src/prog.c
+++ b/src/prog.c
@@ -75,8 +75,8 @@ int main(int argc, char** argv)
break;
}
}
- if (!silent) {
- for (;optind < argc; optind++) {
+ for (;optind < argc; optind++) {
+ if (!silent) {
printf("Extra arguments: %s\n", argv[optind]);
}
}
@@ -85,9 +85,7 @@ int main(int argc, char** argv)
//-PROCESS-FILES-IN-DIRECTORY--------------------
//-----------------------------------------------
char** file_list = NULL;
- uint32_t width, height;
MaskData_t starting_label = 1;
- MaskData_t *masks = NULL;
Mask *masks_im = NULL;
// Expect a directory to be passed as the first argument
if (directory != NULL) {
@@ -118,13 +116,13 @@ int main(int argc, char** argv)
//-----------------------------------------------
//-PROCESS-TIFF-TO-LABELS------------------------
//-----------------------------------------------
- Mask *file_im = tif_to_labels(fpath, &width, &height, &starting_label);
- MaskData_t *file_labels = file_im->image[0];
- if (file_labels == NULL) {
- free(fpath);
- free(file_list[index]);
+ Mask *file_im =
+ tif_to_labels(fpath, &starting_label);
+ if (file_im == NULL) {
+ free(fpath);
+ free(file_list[index]);
continue;
- }
+ }
//-----------------------------------------------
//-COMBINE-LABELS-TO-GLOBAL-MASK-----------------
//-----------------------------------------------
@@ -137,16 +135,18 @@ int main(int argc, char** argv)
}
}
}
- masks = masks_im->image[0];
- if (masks == NULL) {
+ if (masks_im == NULL) {
fprintf(stderr, "No masks found!\n");
return 1;
}
+ uint32_t width = (uint32_t)masks_im->width;
+ uint32_t height = (uint32_t)masks_im->height;
+
//-----------------------------------------------
//-FIND-CONTIGUOUS-REGIONS-----------------------
//-----------------------------------------------
- reduce_contiguous_regions(&masks, width, height, &starting_label);
+ reduce_contiguous_regions(masks_im, &starting_label);
if (!silent) {
printf("%u labels found\n", starting_label-1);
printf("Mask dimensions: %u %u\n", width, height);
@@ -155,7 +155,7 @@ int main(int argc, char** argv)
//-FILTER-SMALL-REGIONS-OUT----------------------
//-----------------------------------------------
TIME(ts_filter_start);
- filter_small_masks(masks, width, height, min_area, min_perimeter);
+ filter_small_masks(masks_im, min_area, min_perimeter);
TIME(ts_filter_end);
if (!silent) {
printf("Removing small labels took %f ms\n", 1000*diff_time(&ts_filter_end, &ts_filter_start));
@@ -165,7 +165,7 @@ int main(int argc, char** argv)
//-----------------------------------------------
//--to-make-labels-span-1-to-n-------------------
//-----------------------------------------------
- reduce_contiguous_regions(&masks, width, height, &starting_label);
+ reduce_contiguous_regions(masks_im, &starting_label);
if (!silent) {
printf("%u remaining labels found\n", starting_label-1);
printf("Mask dimensions: %u %u\n", width, height);
@@ -176,7 +176,7 @@ int main(int argc, char** argv)
//-GET-MASK-META-INFORMATION---------------------
//-----------------------------------------------
AVLNode* root = NULL;
- root = get_mask_data(masks, width, height);
+ root = get_mask_data(masks_im);
if (!silent) {
printf("Inorder traversal of AVL tree: ");
print_label(root);
@@ -188,7 +188,7 @@ int main(int argc, char** argv)
//-CLOSE-UP-SMALL-GAPS-BETWEEN-REGIONS-----------
//-----------------------------------------------
TIME(ts_start);
- closeup(&masks, width, height, closeup_pixel_count);
+ closeup(masks_im,closeup_pixel_count);
TIME(ts_end);
if (!silent) {
printf("Closing (%lu) up took %f ms\n", closeup_pixel_count, 1000*diff_time(&ts_end, &ts_start));
@@ -200,14 +200,14 @@ int main(int argc, char** argv)
//-----------------------------------------------
//-SAVE-MASK-AS-BINARY-AND-PNG-------------------
//-----------------------------------------------
- if (masks != NULL) {
- Bitmap* bitmap = image_mask_data_to_bitmap(masks, width, height);
+ if (masks_im != NULL) {
+ Bitmap* bitmap = image_mask_data_to_bitmap(masks_im->image[0], width, height);
if (bitmap != NULL) {
save_png(bitmap, png_file);
free(bitmap);
}
- write_array(bin_file, masks, width*height*sizeof(MaskData_t));
- free(masks);
+ write_array(bin_file, masks_im->image[0], width*height*sizeof(MaskData_t));
+ free_image_mask(masks_im);
}
TIME(ts_g_end);
if (!silent) {