aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-04 16:07:43 -0800
committerChristian C <cc@localhost>2025-03-04 16:07:43 -0800
commit7a88cf3aaf55fc59ebe6de24c91d03c7ce09e1c0 (patch)
tree81931646f9c44ef45584ba2d256f0a47108f6d63 /src
parentdbf394567aac7e95924f61428ab6fe07e91a02db (diff)
Commenting
Diffstat (limited to 'src')
-rw-r--r--src/main.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 4f2809c..3fb681a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,21 +75,33 @@ bool_t flood(uint8_t* image, uint16_t* mask, size_t width, size_t height, size_t
int main()
{
+ //-----------------------------------------------
+ //-RAYLIB-INIT
+ //-----------------------------------------------
+ SetTraceLogLevel(LOG_ERROR);
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
const char* gui_title = "Image Manip - Useful for segmentations!";
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, gui_title);
+ //-----------------------------------------------
+ //-----------------------------------------------
+ //-TIFF-IMAGE-OPEN-------------------------------
+ //-----------------------------------------------
TIFF *tif = TIFFOpen("./data/test.tif", "r");
if (!tif) {
fprintf(stderr, "Failed to open TIFF file\n");
return 1;
}
+ //-----------------------------------------------
+ //-----------------------------------------------
+ //-TIFF-FIND-DIMENSIONS--------------------------
+ //-----------------------------------------------
uint32_t width, height;
size_t channels = 1;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
- void* buffer;
+ //-----------------------------------------------
tmsize_t STRIP_LENGTH = TIFFStripSize(tif);
tmsize_t STRIP_COUNT = TIFFNumberOfStrips(tif);
if (width*height*3 == STRIP_LENGTH*STRIP_COUNT) {
@@ -97,10 +109,16 @@ int main()
} else if (width*height*4 == STRIP_LENGTH*STRIP_COUNT) {
channels = 4;
}
- printf("%llu\n", STRIP_LENGTH*STRIP_COUNT);
- printf("%lu %hhu\n", width*height*channels, channels);
+ //-----------------------------------------------
+
+ printf("Total Strip Size: %llu\n", STRIP_LENGTH*STRIP_COUNT);
+ printf("Total Image Size: %lu in %hhu channel(s)\n", width*height*channels, channels);
assert(STRIP_LENGTH*STRIP_COUNT == width*height*channels);
- buffer = malloc(STRIP_LENGTH*sizeof(uint8_t));
+
+ //-----------------------------------------------
+ //-TIFF-LOAD-DATA--------------------------------
+ //-----------------------------------------------
+ void* buffer = malloc(STRIP_LENGTH*sizeof(uint8_t));
uint8_t* raster_8 = calloc(width*height*channels,sizeof(uint8_t));
for (size_t y = 0; y < STRIP_COUNT; y++) {
tmsize_t strip_size = TIFFReadRawStrip(tif, y, buffer, STRIP_LENGTH);
@@ -110,13 +128,15 @@ int main()
}
}
free(buffer);
+ //-----------------------------------------------
+ //-----------------------------------------------
+ //-FLOOD-FILL-SEGMENTATION-----------------------
+ //-CONTIGUOUS-REGION-FINDING---------------------
+ //-----------------------------------------------
struct timespec ts_start, ts_end;
char buff[100];
timespec_get(&ts_start, TIME_UTC);
- strftime(buff, sizeof buff, "%D %T", gmtime(&ts_start.tv_sec));
- printf("Current time: %s.%09ld UTC\n", buff, ts_start.tv_nsec);
-
// Flood fill
uint16_t starting_label = 1;
uint16_t *labels = NULL;
@@ -135,10 +155,9 @@ int main()
}
}
timespec_get(&ts_end, TIME_UTC);
- strftime(buff, sizeof buff, "%D %T", gmtime(&ts_end.tv_sec));
- printf("Current time: %s.%09ld UTC\n", buff, ts_end.tv_nsec);
- printf("Time difference: %f\n", diff_timespec(&ts_end, &ts_start));
+ printf("Time difference: %.3fms\n", 1000*diff_timespec(&ts_end, &ts_start));
printf("N_labels: %u\n", starting_label-1);
+ //-----------------------------------------------
uint32_t *raster = (uint32_t*)_TIFFmalloc(width*height*sizeof(uint32_t));
if (raster == NULL) {