generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
2
Commits
4e2dd7b4d4
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a4ff89df7 | ||
|
|
7d30feef54 |
No files matched your search
+6
-7
@@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "imageInput.h"
|
#include "imageInput.h"
|
||||||
@@ -19,10 +20,10 @@ static int getCharValueFromFile(FILE* openedFile) {
|
|||||||
return addToFile;
|
return addToFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrayScaleImageSeries *readImages(const char *path)
|
GrayScaleImageSeries* readImages(const char *path)
|
||||||
{
|
{
|
||||||
GrayScaleImageSeries *series = NULL;
|
GrayScaleImageSeries *series = NULL;
|
||||||
|
// uint16_t
|
||||||
FILE* openFile;
|
FILE* openFile;
|
||||||
|
|
||||||
openFile = fopen(path, "rb");
|
openFile = fopen(path, "rb");
|
||||||
@@ -46,7 +47,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
}
|
}
|
||||||
actualFileTag[strlen(FILE_HEADER_STRING)] = '\0';
|
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);
|
int fileTagEqual = strcmp(actualFileTag, FILE_HEADER_STRING);
|
||||||
|
|
||||||
//we only need the fileTag to verify its an image for our series.
|
//we only need the fileTag to verify its an image for our series.
|
||||||
@@ -54,6 +55,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
actualFileTag = NULL;
|
actualFileTag = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
//only if equal, the method continues
|
||||||
if (fileTagEqual == 0) {
|
if (fileTagEqual == 0) {
|
||||||
numberOfImages = getCharValueFromFile(openFile);
|
numberOfImages = getCharValueFromFile(openFile);
|
||||||
|
|
||||||
@@ -73,16 +75,12 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//all the starting parameters are set --> the images can be read and stored
|
//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 = malloc(sizeof(GrayScaleImageSeries));
|
||||||
|
|
||||||
series->count = 0;
|
series->count = 0;
|
||||||
series->images = malloc(numberOfImages * sizeof(GrayScaleImage));
|
series->images = malloc(numberOfImages * sizeof(GrayScaleImage));
|
||||||
series->labels = malloc(numberOfImages * sizeof(unsigned char));
|
series->labels = malloc(numberOfImages * sizeof(unsigned char));
|
||||||
|
|
||||||
printf(" %d , %d , %d \n", width, height, numberOfImages);
|
|
||||||
|
|
||||||
for (int i = 0; i < numberOfImages; i++) {
|
for (int i = 0; i < numberOfImages; i++) {
|
||||||
series->images[i].height = height;
|
series->images[i].height = height;
|
||||||
series->images[i].width = width;
|
series->images[i].width = width;
|
||||||
@@ -98,6 +96,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the fclose happens here, since every other path closes the file beforehand
|
||||||
fclose (openFile);
|
fclose (openFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Matrix createMatrix(size_t rows, size_t cols)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clearMatrix(Matrix *matrix)
|
void clearMatrix(Matrix* matrix)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < matrix->rows; i++) {
|
for (int i = 0; i < matrix->rows; i++) {
|
||||||
for (int j = 0; j < matrix->cols;j++) {
|
for (int j = 0; j < matrix->cols;j++) {
|
||||||
|
|||||||
Reference in new issue
Block a user