fixed bracketplacement in imageInput.c
This commit is contained in:
parent
4999631b9e
commit
ed1191fffd
10
imageInput.c
10
imageInput.c
@ -16,7 +16,7 @@ unsigned int checkHeaderString (const char *const header);
|
||||
// DONE Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
||||
GrayScaleImageSeries *readImages(const char *path)
|
||||
{
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
FILE *readSource = 0;
|
||||
const unsigned int sizeOfStausInfoElementsInBytes = sizeof(unsigned short);
|
||||
const unsigned int amountOfStatusInfoToRead = 1;
|
||||
@ -29,8 +29,8 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
|
||||
if (readSource != NULL)
|
||||
{
|
||||
series = calloc(sizeof(unsigned int) + 3* sizeof(headerString), amountOfStatusInfoToRead);
|
||||
series->images = calloc(2*sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
||||
series = calloc(3 * sizeof(unsigned int) + 3*sizeof(headerString), amountOfStatusInfoToRead);
|
||||
series->images = calloc(2 * sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
||||
|
||||
numberOfBytesToRead = readStatusInfo(readSource, series, headerString, sizeOfStausInfoElementsInBytes, amountOfStatusInfoToRead);
|
||||
|
||||
@ -42,10 +42,10 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
if (expectedHeader)
|
||||
{
|
||||
// reallocate memory so that each image width can be saved seperately
|
||||
series->images = realloc(series->images, series->count * 2 * sizeof(unsigned int) + sizeof(headerString));
|
||||
series->images = realloc(series->images, series->count * (2 * sizeof(unsigned int) + sizeof(headerString)));
|
||||
|
||||
// for loop was previously running with i < series->count, wich caused programm to crash.
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < series->count; i++)
|
||||
{
|
||||
series->images[i].width = series->images->width;
|
||||
series->images[i].height = series->images->height;
|
||||
|
||||
@ -170,16 +170,17 @@ NeuralNetwork loadModel(const char *path)
|
||||
|
||||
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
||||
{
|
||||
Matrix matrix = {NULL, 0, 0};
|
||||
Matrix matrix = {/*NULL,*/ 0, 0, NULL};
|
||||
|
||||
if(count > 0 && images != NULL)
|
||||
{
|
||||
matrix = createMatrix(images[0].height * images[0].width, count);
|
||||
|
||||
if(matrix.buffer != NULL)
|
||||
{
|
||||
{
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
printf("i %d\n", i);
|
||||
for(int j = 0; j < images[i].width * images[i].height; j++)
|
||||
{
|
||||
setMatrixAt((MatrixType)images[i].buffer[j], matrix, j, i);
|
||||
@ -248,7 +249,7 @@ unsigned char *predict(const NeuralNetwork model, const GrayScaleImage images[],
|
||||
Matrix outputBatch = forward(model, inputBatch);
|
||||
|
||||
unsigned char *result = argmax(outputBatch);
|
||||
|
||||
|
||||
clearMatrix(&outputBatch);
|
||||
|
||||
return result;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user