Björn 2025-11-18 01:53:20 +01:00
commit e17eaf4542
3 changed files with 11 additions and 8 deletions

View File

@ -46,9 +46,9 @@ GrayScaleImageSeries *readImages(const char *path)
return NULL; return NULL;
} }
unsigned short image_count, width, height; unsigned short image_count, width, height;
fread(&image_count,1,sizeof(unsigned short),datei); fread(&image_count,sizeof(unsigned short),1,datei);
fread(&width,1,sizeof(unsigned short),datei); fread(&width,sizeof(unsigned short),1,datei);
fread(&height,1,sizeof(unsigned short),datei); fread(&height,sizeof(unsigned short),1,datei);
//printf("%u Bilder und %u mal %u",image_count,width,height); //printf("%u Bilder und %u mal %u",image_count,width,height);
GrayScaleImageSeries *series = NULL; GrayScaleImageSeries *series = NULL;
series = malloc(sizeof(GrayScaleImageSeries)); series = malloc(sizeof(GrayScaleImageSeries));
@ -57,6 +57,8 @@ GrayScaleImageSeries *readImages(const char *path)
series->labels = malloc(image_count*sizeof(unsigned char)); series->labels = malloc(image_count*sizeof(unsigned char));
for(unsigned short i = 0;i<image_count;i++) for(unsigned short i = 0;i<image_count;i++)
{ {
series->images[i].width = width;
series->images[i].height = height;
series->images[i].buffer = malloc(width*height); series->images[i].buffer = malloc(width*height);
} }
for(unsigned short i = 0;i<image_count;i++) for(unsigned short i = 0;i<image_count;i++)
@ -94,4 +96,4 @@ void clearSeries(GrayScaleImageSeries *series)
printf("Serie freigegeben\n"); printf("Serie freigegeben\n");
return; return;
} }

View File

@ -54,7 +54,7 @@ void test_readImagesReturnsCorrectImageWidth(void)
GrayScaleImageSeries *series = NULL; GrayScaleImageSeries *series = NULL;
const unsigned short expectedWidth = 10; const unsigned short expectedWidth = 10;
const char *path = "testFile.info2"; const char *path = "testFile.info2";
prepareImageFile(path, 8, expectedWidth, 2, 1); prepareImageFile(path, expectedWidth, 8, 2, 1);
series = readImages(path); series = readImages(path);
TEST_ASSERT_NOT_NULL(series); TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_NOT_NULL(series->images); TEST_ASSERT_NOT_NULL(series->images);
@ -70,7 +70,7 @@ void test_readImagesReturnsCorrectImageHeight(void)
GrayScaleImageSeries *series = NULL; GrayScaleImageSeries *series = NULL;
const unsigned short expectedHeight = 10; const unsigned short expectedHeight = 10;
const char *path = "testFile.info2"; const char *path = "testFile.info2";
prepareImageFile(path, expectedHeight, 8, 2, 1); prepareImageFile(path,8, expectedHeight, 2, 1);
series = readImages(path); series = readImages(path);
TEST_ASSERT_NOT_NULL(series); TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_NOT_NULL(series->images); TEST_ASSERT_NOT_NULL(series->images);

5
main.c
View File

@ -1,3 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "imageInput.h" #include "imageInput.h"
@ -6,7 +7,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
readImages("mnist_test.info2"); //readImages("mnist_test.info2");
const unsigned int windowWidth = 800; const unsigned int windowWidth = 800;
const unsigned int windowHeight = 600; const unsigned int windowHeight = 600;
@ -68,4 +69,4 @@ int main(int argc, char *argv[])
return exitCode; return exitCode;
} }