corrected image read function, lable not reading correctly
This commit is contained in:
parent
6a5bc9796b
commit
d59ffa6888
24
imageInput.c
24
imageInput.c
@ -32,15 +32,15 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
|
|
||||||
if (readSource != NULL)
|
if (readSource != NULL)
|
||||||
{
|
{
|
||||||
series = calloc(amountOfStatusInfoToRead, 3 * sizeof(unsigned int) + 3 * sizeof(headerString));
|
series = calloc(amountOfStatusInfoToRead, (3 * sizeof(unsigned int) + 3 * sizeof(headerString)));
|
||||||
series->images = calloc(amountOfStatusInfoToRead, 2 * sizeof(unsigned int) + sizeof(headerString));
|
series->images = calloc(amountOfStatusInfoToRead, (2 * sizeof(unsigned int) + sizeof(headerString)));
|
||||||
|
|
||||||
numberOfBytesToRead = readStatusInfo(readSource, series, headerString, sizeOfStausInfoElementsInBytes, amountOfStatusInfoToRead);
|
numberOfBytesToRead = readStatusInfo(readSource, series, headerString, sizeOfStausInfoElementsInBytes, amountOfStatusInfoToRead);
|
||||||
|
|
||||||
expectedHeader = checkHeaderString(headerString);
|
expectedHeader = checkHeaderString(headerString);
|
||||||
|
|
||||||
// printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
|
// printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
|
||||||
series->images->buffer = calloc((series->count) * numberOfBytesToRead, sizeof(GrayScalePixelType));
|
series->images->buffer = calloc(((series->count) * numberOfBytesToRead), sizeof(GrayScalePixelType));
|
||||||
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
||||||
|
|
||||||
if (expectedHeader)
|
if (expectedHeader)
|
||||||
@ -49,7 +49,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
//heightbuffer = series->images->height;
|
//heightbuffer = series->images->height;
|
||||||
|
|
||||||
// reallocate memory so that each image width can be saved seperately
|
// 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))));
|
||||||
|
|
||||||
//series->images->width = widthbuffer;
|
//series->images->width = widthbuffer;
|
||||||
//series->images->height = heightbuffer;
|
//series->images->height = heightbuffer;
|
||||||
@ -140,12 +140,18 @@ unsigned int readStatusInfo(FILE *const source, GrayScaleImageSeries *const seri
|
|||||||
// reads the imagebytes and the label of all images
|
// reads the imagebytes and the label of all images
|
||||||
void readImagedata(FILE *const source, GrayScaleImageSeries *const series, int const amountToRead)
|
void readImagedata(FILE *const source, GrayScaleImageSeries *const series, int const amountToRead)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < series->count ; i++)
|
for (i = 0; i < series->count ; i++)
|
||||||
{
|
{
|
||||||
fread(&(series->images->buffer), sizeof(*series->images->buffer), amountToRead, source);
|
// printf("amount11 %d\n", amountToRead);
|
||||||
fread(&(series->labels[i]), sizeof(*series->images->buffer), sizeof(*series->labels), source);
|
// gedanke: &(series->images[i].buffer)
|
||||||
|
// geht: &(series->images->buffer[0]) +i*36)
|
||||||
|
// geht nicht: &series->images[i].buffer
|
||||||
|
fread(&series->images[i].buffer[0], 1, amountToRead, source);
|
||||||
|
fread(&(series->labels[i]), 1, 1, source);
|
||||||
|
// printf("label: %d\n", series->labels[i]);
|
||||||
|
// fread(&(series->labels[i]), sizeof(*series->images->buffer), sizeof(*series->labels), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
testFile.info2
BIN
testFile.info2
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user