fixed bracketplacement in imageInput.c

This commit is contained in:
Jonas Hofmann 2025-11-24 21:38:37 +01:00
parent 4999631b9e
commit ed1191fffd
2 changed files with 9 additions and 8 deletions

View File

@ -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;

View File

@ -170,7 +170,7 @@ 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)
{
@ -180,6 +180,7 @@ static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], un
{
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);