Compare commits
4 Commits
51d02f32c2
...
758dc03ab8
| Author | SHA1 | Date | |
|---|---|---|---|
| 758dc03ab8 | |||
| 93408c1f47 | |||
| ed1191fffd | |||
| 4999631b9e |
24
imageInput.c
24
imageInput.c
@ -16,9 +16,9 @@ unsigned int checkHeaderString (const char *const header);
|
|||||||
// DONE Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
// DONE Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
||||||
GrayScaleImageSeries *readImages(const char *path)
|
GrayScaleImageSeries *readImages(const char *path)
|
||||||
{
|
{
|
||||||
GrayScaleImageSeries *series = NULL;
|
GrayScaleImageSeries *series = NULL;
|
||||||
FILE *readSource = 0;
|
FILE *readSource = 0;
|
||||||
const unsigned int sizeOfStausInfoElementsInBytes = 2;
|
const unsigned int sizeOfStausInfoElementsInBytes = sizeof(unsigned short);
|
||||||
const unsigned int amountOfStatusInfoToRead = 1;
|
const unsigned int amountOfStatusInfoToRead = 1;
|
||||||
unsigned int numberOfBytesToRead = 0;
|
unsigned int numberOfBytesToRead = 0;
|
||||||
unsigned int expectedHeader = 0;
|
unsigned int expectedHeader = 0;
|
||||||
@ -29,43 +29,39 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
|
|
||||||
if (readSource != NULL)
|
if (readSource != NULL)
|
||||||
{
|
{
|
||||||
series = calloc(sizeof(unsigned int) + 3* sizeof(headerString), amountOfStatusInfoToRead);
|
series = calloc(3 * sizeof(unsigned int) + 3*sizeof(headerString), amountOfStatusInfoToRead);
|
||||||
series->images = calloc(2*sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
series->images = calloc(2 * sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
||||||
|
|
||||||
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));
|
||||||
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)
|
||||||
{
|
{
|
||||||
printf("expected Header!\n");
|
|
||||||
// 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)));
|
||||||
|
|
||||||
printf("count: %d", series->count);
|
// for loop was previously running with i < series->count, wich caused programm to crash.
|
||||||
series->images[2].width = series->images->width;
|
|
||||||
series->images[2].height = series->images->height;
|
|
||||||
/*
|
|
||||||
for (int i = 0; i < series->count; i++)
|
for (int i = 0; i < series->count; i++)
|
||||||
{
|
{
|
||||||
series->images[i].width = series->images->width;
|
series->images[i].width = series->images->width;
|
||||||
series->images[i].height = series->images->height;
|
series->images[i].height = series->images->height;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
printf("afer for Loop! \n");
|
|
||||||
readImagedata(readSource, series, numberOfBytesToRead);
|
readImagedata(readSource, series, numberOfBytesToRead);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
series = NULL;
|
series = NULL;
|
||||||
}
|
}
|
||||||
printf("before read Source\n");
|
|
||||||
fclose(readSource);
|
fclose(readSource);
|
||||||
}
|
}
|
||||||
printf("finished reading!\n");
|
|
||||||
|
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|||||||
10
matrix.c
10
matrix.c
@ -47,13 +47,19 @@ void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// printf("rowIdx %d\n", rowIdx);
|
||||||
|
// printf("mat.row %d\n", matrix.rows);
|
||||||
|
// printf("colIdx %d\n", colIdx);
|
||||||
|
// printf("mat.cols %d\n", matrix.cols);
|
||||||
|
|
||||||
if(rowIdx >= matrix.rows || colIdx >= matrix.cols)
|
if(rowIdx >= matrix.rows || colIdx >= matrix.cols)
|
||||||
{
|
{
|
||||||
//printf("Ungueltige Indizes beim Setzen!\n");
|
//printf("Ungueltige Indizes beim Setzen!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// printf("%d \n", rowIdx + matrix.cols * colIdx);
|
||||||
matrix.buffer[rowIdx * matrix.cols + colIdx] = value;
|
matrix.buffer[rowIdx + matrix.cols * colIdx] = value;
|
||||||
|
// printf("value %f\n", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
|
|||||||
@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path)
|
|||||||
|
|
||||||
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
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)
|
if(count > 0 && images != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user