generated from freudenreichan/info2Praktikum-NeuronalesNetz
Adding Breakpoints to set parameters
This commit is contained in:
parent
0a549b7e0d
commit
ec8c735eb2
28
imageInput.c
28
imageInput.c
@ -37,20 +37,28 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
{
|
{
|
||||||
FILE* file = fopen(path, "rb");
|
FILE* file = fopen(path, "rb");
|
||||||
// TODO open binary file from file name
|
// TODO open binary file from file name
|
||||||
GrayScaleImageSeries *series = NULL;
|
GrayScaleImageSeries *series = malloc(sizeof(GrayScaleImageSeries));
|
||||||
|
GrayScaleImage *image = malloc(sizeof(GrayScaleImage));
|
||||||
|
series->images = image;
|
||||||
if(!(checkString(file)))
|
if(!(checkString(file)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
unsigned int* imageCount = &(series->count); // sets a pointer for int variable count in struct
|
unsigned int* imageCount = &(series->count); // sets a pointer for int variable count in struct
|
||||||
|
printf("%d", *imageCount);
|
||||||
setParameters(file, imageCount, &(series->images->width), &(series->images->height));
|
unsigned int* width = &(series->images->width);
|
||||||
|
//printf("%d", *width);
|
||||||
|
setParameters(file, imageCount, width, &(series->images->height));
|
||||||
|
printf("BP3\n");
|
||||||
allocateMemory(series, *imageCount, series->images->width, series->images->height);
|
allocateMemory(series, *imageCount, series->images->width, series->images->height);
|
||||||
|
printf("BP4\n");
|
||||||
//allocateMemoryLabels();
|
//allocateMemoryLabels();
|
||||||
for(int i = (series->images->width * series->images->height) - 1; i <= 0; i--)
|
for(int i = (series->images->width * series->images->height) - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
fread(&(series->images->buffer[i]), sizeof(GrayScalePixelType), 1, file);
|
fread(&(series->images->buffer[i]), sizeof(GrayScalePixelType), 1, file);
|
||||||
|
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
printf("BP5\n");
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,16 +72,28 @@ void clearSeries(GrayScaleImageSeries *series)
|
|||||||
}
|
}
|
||||||
series->images = NULL;
|
series->images = NULL;
|
||||||
series->labels = NULL;
|
series->labels = NULL;
|
||||||
|
|
||||||
|
free(series);
|
||||||
|
|
||||||
|
series = NULL;
|
||||||
}
|
}
|
||||||
void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height) { // sets the parameters
|
void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, unsigned int* height) { // sets the parameters
|
||||||
|
printf("BP1");
|
||||||
char buffer[3];
|
char buffer[3];
|
||||||
|
|
||||||
fseek(file, 27, SEEK_SET);
|
fseek(file, 27, SEEK_SET);
|
||||||
fread(buffer, 1, 3, file);
|
fread(buffer, 1, 3, file);
|
||||||
|
|
||||||
*imageCount = (int) buffer[0];
|
*imageCount = (int) buffer[0];
|
||||||
|
|
||||||
|
|
||||||
*width = (int) buffer[1];
|
*width = (int) buffer[1];
|
||||||
|
|
||||||
*height = (int) buffer[2];
|
*height = (int) buffer[2];
|
||||||
|
printf("BP2\n");
|
||||||
|
printf("%d\n", *imageCount);
|
||||||
|
printf("%d\n", *width);
|
||||||
|
printf("%d\n", *height);
|
||||||
// TODO allocate memory for labels array (in imageInput.h) -> Done in allocate Memory
|
// TODO allocate memory for labels array (in imageInput.h) -> Done in allocate Memory
|
||||||
|
|
||||||
// TODO read from file and write in 2d arry, write label in labels array, repeat for imageCount -> done in readImages
|
// TODO read from file and write in 2d arry, write label in labels array, repeat for imageCount -> done in readImages
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user