generated from freudenreichan/info2Praktikum-NeuronalesNetz
Preparation for the next workphase
This commit is contained in:
parent
04493332f7
commit
7168681f1d
@ -69,6 +69,9 @@ void setParameters(FILE* file, unsigned int* imageCount, unsigned int* width, un
|
|||||||
*imageCount = (int) buffer[0];
|
*imageCount = (int) buffer[0];
|
||||||
*width = (int) buffer[1];
|
*width = (int) buffer[1];
|
||||||
*height = (int) buffer[2];
|
*height = (int) buffer[2];
|
||||||
|
// TODO allocate memory for labels array (in imageInput.h)
|
||||||
|
|
||||||
|
// TODO read from file and write in 2d arry, write label in labels array, repeat for imageCount
|
||||||
}
|
}
|
||||||
// change this to createMatrix?
|
// change this to createMatrix?
|
||||||
void allocateMemory(GrayScaleImageSeries* s, const int imageCount, const int width, const int height) {
|
void allocateMemory(GrayScaleImageSeries* s, const int imageCount, const int width, const int height) {
|
||||||
|
|||||||
15
matrix.c
15
matrix.c
@ -8,12 +8,17 @@
|
|||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||||
{
|
{
|
||||||
Matrix newMatrix;
|
Matrix newMatrix;
|
||||||
|
if (rows == 0 || cols == 0) {
|
||||||
|
newMatrix.rows = 0;
|
||||||
|
newMatrix.cols = 0;
|
||||||
|
newMatrix.buffer = NULL;
|
||||||
|
return newMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
newMatrix.rows = rows;
|
newMatrix.rows = rows;
|
||||||
newMatrix.cols = cols;
|
newMatrix.cols = cols;
|
||||||
if (rows == 0 || cols == 0)
|
|
||||||
newMatrix.buffer = NULL;
|
newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType));
|
||||||
else
|
|
||||||
newMatrix.buffer = calloc(rows*cols, sizeof(MatrixType));
|
|
||||||
return newMatrix;
|
return newMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +26,8 @@ void clearMatrix(Matrix *matrix)
|
|||||||
{
|
{
|
||||||
free(matrix->buffer);
|
free(matrix->buffer);
|
||||||
matrix->buffer = NULL;
|
matrix->buffer = NULL;
|
||||||
|
matrix->rows = 0;
|
||||||
|
matrix->cols = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user