Compare commits
2 Commits
6189a5aa1e
...
cddd141ea6
| Author | SHA1 | Date | |
|---|---|---|---|
| cddd141ea6 | |||
| 9d913f80f9 |
61
imageInput.c
61
imageInput.c
@ -26,15 +26,36 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
const unsigned int amountOfStatusInfoToRead = 1;
|
const unsigned int amountOfStatusInfoToRead = 1;
|
||||||
char headerString[sizeof("__info2_image_file_format__\0")] = "";
|
char headerString[sizeof("__info2_image_file_format__\0")] = "";
|
||||||
|
|
||||||
//speicher allocaten weil *series auf null zeigt !!!!!!!!
|
/*
|
||||||
|
char curChar = 0;
|
||||||
|
int i = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// dieses print(hier) wird nur einmal aufgerufen,
|
||||||
|
// der zweite test schafft es also nicht readImages
|
||||||
|
// korrekt aufzurufen!!!!!
|
||||||
|
printf("hier\n");
|
||||||
readSource = fopen(path, "rb");
|
readSource = fopen(path, "rb");
|
||||||
|
|
||||||
if (readSource != NULL)
|
if (readSource != NULL)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
series = calloc(sizeof(GrayScaleImageSeries), amountOfStatusInfoToRead);
|
// print entire source char by char
|
||||||
series->images = calloc(sizeof(GrayScaleImage), amountOfStatusInfoToRead);
|
do
|
||||||
|
{
|
||||||
|
curChar = fgetc(readSource);
|
||||||
|
printf("%x ", curChar);
|
||||||
|
if (i >= 9)
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
} while (curChar != EOF);
|
||||||
|
// print entire source char by char
|
||||||
|
*/
|
||||||
|
series = calloc(sizeof(unsigned int) + 3* sizeof(headerString), amountOfStatusInfoToRead);
|
||||||
|
series->images = calloc(2*sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
||||||
|
|
||||||
numberOfBytesToRead = readStatusInfo(readSource, headerString, &(series->count), &(series->images->width), &(series->images->height), amountOfStatusInfoToRead);
|
numberOfBytesToRead = readStatusInfo(readSource, headerString, &(series->count), &(series->images->width), &(series->images->height), amountOfStatusInfoToRead);
|
||||||
|
|
||||||
@ -42,10 +63,11 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
||||||
|
|
||||||
readImagedata(readSource, series->images->buffer, series->labels, series->count, numberOfBytesToRead);
|
readImagedata(readSource, series->images->buffer, series->labels, series->count, numberOfBytesToRead);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(readSource);
|
fclose(readSource);
|
||||||
|
|
||||||
|
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
@ -73,10 +95,11 @@ void clearSeries(GrayScaleImageSeries *series)
|
|||||||
// AND write NULL into every pointer
|
// AND write NULL into every pointer
|
||||||
// so they can't be accessed
|
// so they can't be accessed
|
||||||
free(series->images->buffer);
|
free(series->images->buffer);
|
||||||
free(series->labels);
|
|
||||||
series->images->buffer = NULL;
|
series->images->buffer = NULL;
|
||||||
series->images = NULL;
|
free(series->labels);
|
||||||
series->labels = NULL;
|
series->labels = NULL;
|
||||||
|
free(series->images);
|
||||||
|
series->images = NULL;
|
||||||
free(series);
|
free(series);
|
||||||
series = NULL;
|
series = NULL;
|
||||||
|
|
||||||
@ -87,25 +110,24 @@ void clearSeries(GrayScaleImageSeries *series)
|
|||||||
unsigned int readStatusInfo(FILE *source, char *const headerString, unsigned int *const imageCount, unsigned int *const imageWidth, unsigned int *const imageHeight, int const amountToRead)
|
unsigned int readStatusInfo(FILE *source, char *const headerString, unsigned int *const imageCount, unsigned int *const imageWidth, unsigned int *const imageHeight, int const amountToRead)
|
||||||
{
|
{
|
||||||
unsigned int bytesToRead = 0;
|
unsigned int bytesToRead = 0;
|
||||||
|
/*
|
||||||
int numred = 0;
|
int numred = 0;
|
||||||
int numred2 = 0;
|
int numred2 = 0;
|
||||||
int numred3 = 0;
|
int numred3 = 0;
|
||||||
int numred4 = 0;
|
int numred4 = 0;
|
||||||
|
*/
|
||||||
*imageCount = 0;
|
|
||||||
*imageWidth = 0;
|
|
||||||
*imageHeight = 0;
|
|
||||||
|
|
||||||
numred = fread(headerString, sizeof("__info2_image_file_format__\0"), 1, source);
|
//unsigned int imageCountBuffer = 0;
|
||||||
numred2 = fread(imageCount, sizeof(unsigned int), 1, source);
|
fread(headerString, 27, 1, source);
|
||||||
numred3 = fread(imageWidth, sizeof(unsigned int), 1, source);
|
fread(imageCount, 2, 1, source);
|
||||||
numred4 = fread(imageHeight, sizeof(unsigned int), 1, source);
|
fread(imageWidth, 2, 1, source);
|
||||||
|
fread(imageHeight, 2, 1, source);
|
||||||
*imageCount = 2;
|
|
||||||
|
|
||||||
bytesToRead = (*imageWidth) * (*imageHeight);
|
bytesToRead = (*imageWidth) * (*imageHeight);
|
||||||
|
/*
|
||||||
printf("hier\n");
|
printf("imgCntBuffer: %u\n", imageCountBuffer);
|
||||||
|
*imageCount = imageCountBuffer;
|
||||||
|
|
||||||
printf("numred: %d\n", numred);
|
printf("numred: %d\n", numred);
|
||||||
printf("stringsize: %lld\n", sizeof("__info2_image_file_format__"));
|
printf("stringsize: %lld\n", sizeof("__info2_image_file_format__"));
|
||||||
printf("string: %send\n", headerString);
|
printf("string: %send\n", headerString);
|
||||||
@ -116,6 +138,7 @@ unsigned int readStatusInfo(FILE *source, char *const headerString, unsigned int
|
|||||||
printf("numred4: %d\n", numred4);
|
printf("numred4: %d\n", numred4);
|
||||||
printf("height %u\n", *imageHeight);
|
printf("height %u\n", *imageHeight);
|
||||||
printf("bytes to read = %u\n", bytesToRead);
|
printf("bytes to read = %u\n", bytesToRead);
|
||||||
|
*/
|
||||||
return bytesToRead;
|
return bytesToRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
some_tag
|
|
||||||
Loading…
x
Reference in New Issue
Block a user