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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "imageInput.h"
|
||||
@@ -19,10 +20,10 @@ static int getCharValueFromFile(FILE* openedFile) {
|
||||
return addToFile;
|
||||
}
|
||||
|
||||
GrayScaleImageSeries *readImages(const char *path)
|
||||
GrayScaleImageSeries* readImages(const char *path)
|
||||
{
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
|
||||
// uint16_t
|
||||
FILE* openFile;
|
||||
|
||||
openFile = fopen(path, "rb");
|
||||
@@ -46,7 +47,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 +55,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
actualFileTag = NULL;
|
||||
|
||||
|
||||
//only if equal, the method continues
|
||||
if (fileTagEqual == 0) {
|
||||
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
|
||||
// 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 +96,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
// the fclose happens here, since every other path closes the file beforehand
|
||||
fclose (openFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user