Merge remote-tracking branch 'origin/Development' into Development
This commit is contained in:
commit
f8aa5535c5
2 changed files with 41 additions and 7 deletions
36
image.c
36
image.c
|
|
@ -1,19 +1,43 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
typedef struct {
|
Img** import_images(char* image_file_string, char* label_file_string, int number_of_images) {
|
||||||
Matrix* pixel_values;
|
|
||||||
int image_label;
|
// create file pointer for the image and label data
|
||||||
} Image;
|
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
|
//print the image
|
||||||
matrix_print(img->pixel_values);
|
matrix_print(img->pixel_values);
|
||||||
//print the number of the image
|
//print the number of the image
|
||||||
printf("%d", img->image_label);
|
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<quantity;i++){
|
||||||
|
img_free(images[i]);
|
||||||
|
}
|
||||||
|
//frees the rest of images
|
||||||
|
free(images);
|
||||||
}
|
}
|
||||||
void img_free (Img* img)
|
|
||||||
|
|
|
||||||
10
image.h
10
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);
|
||||||
Reference in a new issue