From 2e014244222787d45db120351af5d7088472f3cd Mon Sep 17 00:00:00 2001 From: Thomas Schleicher Date: Tue, 19 Sep 2023 10:31:23 +0200 Subject: [PATCH 1/3] Fixed Image.c & image.h --- image.c | 28 ++++++++++++++++++++-------- image.h | 10 ++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/image.c b/image.c index fcc6495..ccb485b 100644 --- a/image.c +++ b/image.c @@ -1,19 +1,31 @@ #pragma once #include - #include "image.h" #include "matrix.h" -typedef struct { - Matrix* pixel_values; - int image_label; -} Image; +Img** import_images(char* image_file_string, char* label_file_string, int number_of_images) { + + // create file pointer for the image and label data + FILE* image_file = fopen(image_file_string, 'r'); + FILE* label_file = fopen(label_file_string, 'r'); + + // check if the file could be opened + if(image_file == NULL || label_file == NULL) { + printf("ERROR: File could not be opened! ()"); + } + +} + +void img_print (Img* img) { -void img_print (Img* img){ //print the image matrix_print(img->pixel_values); - //print the number of the image + + //print the label of the image printf("%d", img->image_label); } -void img_free (Img* img) + +void img_free (Img* img) { + +} diff --git a/image.h b/image.h index e69de29..ddd20d5 100644 --- a/image.h +++ b/image.h @@ -0,0 +1,10 @@ +#pragma once + +typedef struct { + Matrix* pixel_values; + int image_label; +} Image; + +Img** import_images(char* image_file_string, char* label_file_string, int number_of_images); +void img_print (Img* img); +void img_free (Img* img); \ No newline at end of file From e824d7fdea4b4e349830cd91a0d35a69d3ec36c6 Mon Sep 17 00:00:00 2001 From: Ghost_Element Date: Tue, 19 Sep 2023 10:52:55 +0200 Subject: [PATCH 2/3] img print --- image.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/image.c b/image.c index ccb485b..028eabb 100644 --- a/image.c +++ b/image.c @@ -1,6 +1,8 @@ #pragma once +#include #include + #include "image.h" #include "matrix.h" @@ -21,11 +23,16 @@ void img_print (Img* img) { //print the image matrix_print(img->pixel_values); - - //print the label of the image - printf("%d", img->image_label); + //print the number of the image + printf("Number it is supposed to be: %d\n", img->image_label); } - void img_free (Img* img) { - + matrix_free(img->pixel_values); + free(img); +} +void images_free (Img** images, int quantity){ + for(int i=0;i Date: Tue, 19 Sep 2023 10:56:41 +0200 Subject: [PATCH 3/3] images_free + comments --- image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/image.c b/image.c index 028eabb..e7d8862 100644 --- a/image.c +++ b/image.c @@ -20,19 +20,24 @@ Img** import_images(char* image_file_string, char* label_file_string, int number } void img_print (Img* img) { - //print the image matrix_print(img->pixel_values); //print the number of the image printf("Number it is supposed to be: %d\n", img->image_label); } + void img_free (Img* img) { + //frees the matrix of image (deep free) matrix_free(img->pixel_values); + //frees the rest of img free(img); } + void images_free (Img** images, int quantity){ + //frees every single image for(int i=0;i