diff options
| author | Christian C <cc@localhost> | 2025-03-06 15:40:14 -0800 | 
|---|---|---|
| committer | Christian C <cc@localhost> | 2025-03-06 15:40:14 -0800 | 
| commit | 75594765aee66eed792a51cdbba4cc3aa64145d2 (patch) | |
| tree | 13cfcda64fa9cf41abbd6717e494e919cd330cf6 | |
| parent | 9c6ca913d0b7f9b9ae95f72d6187944a8a940228 (diff) | |
Annotate flow of program
| -rw-r--r-- | src/main.c | 34 | 
1 files changed, 29 insertions, 5 deletions
@@ -33,6 +33,9 @@ int main(int argc, char** argv)    char* png_file = "../out.png";    char* bin_file = "../out.bin";    bool_t silent = FALSE; +  //----------------------------------------------- +  //-GET-COMMAND-LINE-ARGUMENTS-------------------- +  //-----------------------------------------------    while ((opt = getopt(argc, argv, "d:b:p:s")) != -1) {      switch (opt) {      case 's': @@ -76,7 +79,7 @@ int main(int argc, char** argv)    TIME(ts_g_start);    struct AVLNode* root = NULL;    //----------------------------------------------- -  //-LIST-FILES-IN-DIRECTORY----------------------- +  //-PROCESS-FILES-IN-DIRECTORY--------------------    //-----------------------------------------------    char** file_list = NULL;    uint32_t width, height; @@ -134,26 +137,36 @@ int main(int argc, char** argv)    }    uint16_t* new_masks; -  // Regenerate contiguous labels +  //----------------------------------------------- +  //-FIND-CONTIGUOUS-REGIONS----------------------- +  //-----------------------------------------------    reduce_contiguous_regions(&masks, width, height, &starting_label);    if (!silent) {      printf("%u labels found\n", starting_label-1);      printf("Mask dimensions: %u %u\n", width, height);    }    TIME(ts_filter_start); +  //----------------------------------------------- +  //-FILTER-SMALL-REGIONS-OUT---------------------- +  //-----------------------------------------------    filter_small_masks(masks, width, height, 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));    } -  // Regenerate contiguous labels +  //----------------------------------------------- +  //-FIND-CONTIGUOUS-REGIONS----------------------- +  //-----------------------------------------------    reduce_contiguous_regions(&masks, width, height, &starting_label);    if (!silent) {      printf("%u remaining labels found\n", starting_label-1);      printf("Mask dimensions: %u %u\n", width, height);    } -  // Regenerate information after relabeling +  //----------------------------------------------- +  //-OPTIONAL:------------------------------------- +  //-GET-MASK-META-INFORMATION--------------------- +  //-----------------------------------------------    root = get_mask_data(masks, width, height);  #ifdef AVL_INFO    if (!silent) { @@ -166,16 +179,21 @@ int main(int argc, char** argv)    uint16_t *new_labels;    TIME(ts_start); +  //----------------------------------------------- +  //-CLOSE-UP-SMALL-GAPS-BETWEEN-REGIONS----------- +  //-----------------------------------------------    closeup(&masks, width, height, N_DILATIONS);    TIME(ts_end);    if (!silent) {      printf("Closing up took %f ms\n", 1000*diff_time(&ts_end, &ts_start));    }    //----------------------------------------------- +  //-END-OF-PROCESSING----------------------------- +  //-----------------------------------------------  #ifdef VISUAL    //----------------------------------------------- -  //-RAYLIB-INIT +  //-RAYLIB-INIT-----------------------------------    //-----------------------------------------------    SetTraceLogLevel(LOG_ERROR);    SetConfigFlags(FLAG_WINDOW_RESIZABLE); @@ -247,6 +265,9 @@ int main(int argc, char** argv)      //-----------------------------------------------    } +  //----------------------------------------------- +  //-SAVE-MASK-AS-BINARY-AND-PNG------------------- +  //-----------------------------------------------    if (masks != NULL) {      for (size_t y = 0; y < height; y++) {        for (size_t x = 0; x < width; x++) { @@ -265,6 +286,9 @@ int main(int argc, char** argv)    }    CloseWindow();  #else +  //----------------------------------------------- +  //-SAVE-MASK-AS-BINARY-AND-PNG------------------- +  //-----------------------------------------------    if (masks != NULL) {      struct bitmap_t* bitmap = uint16_to_bitmap(masks, width, height);      if (bitmap != NULL) {  | 
