HolyFuckItsAlive #13

Merged
jastornig merged 105 commits from Delta-Error-Test into main 2023-09-23 22:27:54 +02:00
4 changed files with 26 additions and 7 deletions
Showing only changes of commit f98bb5cbaa - Show all commits

View file

@ -3,4 +3,4 @@ project(c_net C)
set(CMAKE_C_STANDARD 11)
add_executable(c_net main.c matrix.c)
add_executable(c_net main.c matrix.c image.c)

20
image.c
View file

@ -1,10 +1,12 @@
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include "image.h"
#include "matrix.h"
Img** import_images(char* image_file_string, char* label_file_string, int number_of_images) {
Image** 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');
@ -12,9 +14,23 @@ Img** import_images(char* image_file_string, char* label_file_string, int number
// check if the file could be opened
if(image_file == NULL || label_file == NULL) {
printf("ERROR: File could not be opened! ()");
printf("ERROR: File could not be opened! (import_images)");
}
do {
ch = fgetc(label_file);
printf("%c", ch);
// Checking if character is not EOF.
// If it is EOF stop reading.
} while (ch != EOF);
// allocate memory for the storage of images
// Image** images = malloc(sizeof(Image) * number_of_images);
fclose(image_file);
fclose(label_file);
}
void img_print (Img* img) {

View file

@ -5,6 +5,6 @@ typedef struct {
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);
Image** import_images(char* image_file_string, char* label_file_string, int number_of_images);
void img_print (Image* image);
void img_free (Image* image);

5
main.c
View file

@ -1,7 +1,10 @@
#include <stdio.h>
#include <stdio.h>
#include "matrix.h"
#include <stdio.h>
#include "image.h"
int main() {
Image** images = import_images("train-images.idx3-ubyte", "train-labels.idx3-ubyte", 20);
}