Finished testing, no more Failures in imageInputTests

This commit is contained in:
Lukas Weber 2025-11-24 18:26:34 +01:00
parent 3df6e152d7
commit 0a8349d722

View File

@ -28,8 +28,8 @@ int checkString (FILE *file){ //Checks if String at the start of File equals exp
}
}
void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height);
int allocateMemory(GrayScaleImageSeries *series, const int imageCount, const int width, const int height);
static void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height);
static int allocateMemory(GrayScaleImageSeries *series, const int imageCount, const int width, const int height);
GrayScaleImageSeries *readImages(const char *path)
@ -59,10 +59,8 @@ GrayScaleImageSeries *readImages(const char *path)
for(unsigned int i = 0; i < series->count ; i++){ //Iterating for every image
for(unsigned int j = 0; j < width * height; j++){ //Iterating for every pixel
fread(&(series->images[i].buffer[j]), sizeof(GrayScalePixelType), 1, file);
printf("Wrote in buffer: %d", series->images[i].buffer[j]);
}
fread(&(series->labels[i]), sizeof(unsigned char), 1, file);
printf("Wrote in labels: %d", series->labels[i]);
fread(&(series->labels[i]), sizeof(unsigned char), 1, file); // TODO Added writing in labels array
}
fclose(file);
return series;
@ -84,27 +82,26 @@ void clearSeries(GrayScaleImageSeries *series)
free(series); //Freeing Main Structure
}
void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height) { // sets the parameters
static void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height) { // sets the parameters
char buffer[3];
unsigned short buffer[3];
fseek(file, 27, SEEK_SET);
if(fread(buffer, 1, 3, file) != 3){ // TODO changed some stuff here
if(fread(buffer, sizeof(unsigned short), 3, file) != 3){ // TODO changed some stuff here, used UNSIGNED SHORT instead of UNSIGNED CHAR!!
*imageCount = 0;
*width = 0;
*height = 0;
return;
} //Stops if file is too short and clean up
*imageCount = (int) buffer[0];
*imageCount = (unsigned int) buffer[0];
*width = (unsigned int) buffer[1];
*width = (int) buffer[1];
*height = (int) buffer[2];
*height = (unsigned int) buffer[2];
}
int allocateMemory(GrayScaleImageSeries *series, const int imageCount, const int width, const int height) {
static int allocateMemory(GrayScaleImageSeries *series, const int imageCount, const int width, const int height) {
series->count = imageCount; //counts number of images in series
series->images = malloc (sizeof(GrayScaleImage) * imageCount); //Reserving Memory for Images Array