From 7d30feef54a1e773c849c25736677f9fc3bbdc05 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 27 Nov 2025 15:40:57 +0100 Subject: [PATCH] added some more comments --- imageInput.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/imageInput.c b/imageInput.c index 68cb4d3..6dfb1e6 100644 --- a/imageInput.c +++ b/imageInput.c @@ -46,7 +46,7 @@ GrayScaleImageSeries *readImages(const char *path) } actualFileTag[strlen(FILE_HEADER_STRING)] = '\0'; - // checks if the files are equal: strcmp should return '0' --> convert it to '1' for 'true' + // checks if the files are equal int fileTagEqual = strcmp(actualFileTag, FILE_HEADER_STRING); //we only need the fileTag to verify its an image for our series. @@ -54,6 +54,7 @@ GrayScaleImageSeries *readImages(const char *path) actualFileTag = NULL; + //only if equal, the method continues if (fileTagEqual == 0) { numberOfImages = getCharValueFromFile(openFile); @@ -73,16 +74,12 @@ GrayScaleImageSeries *readImages(const char *path) } //all the starting parameters are set --> the images can be read and stored - // GrayScaleImage* images = malloc(numberOfImages * sizeof(GrayScaleImage)); - // unsigned char* labels = malloc(numberOfImages * sizeof(unsigned char)); series = malloc(sizeof(GrayScaleImageSeries)); series->count = 0; series->images = malloc(numberOfImages * sizeof(GrayScaleImage)); series->labels = malloc(numberOfImages * sizeof(unsigned char)); - printf(" %d , %d , %d \n", width, height, numberOfImages); - for (int i = 0; i < numberOfImages; i++) { series->images[i].height = height; series->images[i].width = width; @@ -98,6 +95,7 @@ GrayScaleImageSeries *readImages(const char *path) } } + // the fclose happens here, since every other path closes the file. beforehand fclose (openFile); }