forked from freudenreichan/info2Praktikum-NeuronalesNetz
Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/turtschinba100320/info2Praktikum-NeuronalesNetzBastiBjoern
This commit is contained in:
commit
e17eaf4542
10
imageInput.c
10
imageInput.c
@ -46,9 +46,9 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
unsigned short image_count, width, height;
|
||||
fread(&image_count,1,sizeof(unsigned short),datei);
|
||||
fread(&width,1,sizeof(unsigned short),datei);
|
||||
fread(&height,1,sizeof(unsigned short),datei);
|
||||
fread(&image_count,sizeof(unsigned short),1,datei);
|
||||
fread(&width,sizeof(unsigned short),1,datei);
|
||||
fread(&height,sizeof(unsigned short),1,datei);
|
||||
//printf("%u Bilder und %u mal %u",image_count,width,height);
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
series = malloc(sizeof(GrayScaleImageSeries));
|
||||
@ -57,6 +57,8 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
series->labels = malloc(image_count*sizeof(unsigned char));
|
||||
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);
|
||||
}
|
||||
for(unsigned short i = 0;i<image_count;i++)
|
||||
@ -94,4 +96,4 @@ void clearSeries(GrayScaleImageSeries *series)
|
||||
printf("Serie freigegeben\n");
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void test_readImagesReturnsCorrectImageWidth(void)
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const unsigned short expectedWidth = 10;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, 8, expectedWidth, 2, 1);
|
||||
prepareImageFile(path, expectedWidth, 8, 2, 1);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->images);
|
||||
@ -70,7 +70,7 @@ void test_readImagesReturnsCorrectImageHeight(void)
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const unsigned short expectedHeight = 10;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, expectedHeight, 8, 2, 1);
|
||||
prepareImageFile(path,8, expectedHeight, 2, 1);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->images);
|
||||
|
||||
5
main.c
5
main.c
@ -1,3 +1,4 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "imageInput.h"
|
||||
@ -6,7 +7,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
readImages("mnist_test.info2");
|
||||
//readImages("mnist_test.info2");
|
||||
|
||||
const unsigned int windowWidth = 800;
|
||||
const unsigned int windowHeight = 600;
|
||||
@ -68,4 +69,4 @@ int main(int argc, char *argv[])
|
||||
|
||||
return exitCode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user