generated from freudenreichan/info2Praktikum-NeuronalesNetz
Fertigstellen von matrix.c und Hilfsfunktion von input.c
This commit is contained in:
parent
115b5b18f6
commit
cd7d1fc0af
38
imageInput.c
38
imageInput.c
@ -8,24 +8,32 @@
|
||||
|
||||
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
||||
|
||||
void helpFunction
|
||||
static void readPictureData(const char *path,const short ptrPicturesCount, const short ptrPictureWidth, const short ptrPictureHeigth)
|
||||
{
|
||||
GrayScalePixelType *bufferRead;
|
||||
GrayScalePixelType *bufferWrite;
|
||||
bufferRead = fopen(*path, "rb");
|
||||
unsigned char header = strlen(FILE_HEADER_STRING);
|
||||
unsigned int header = strlen(FILE_HEADER_STRING);
|
||||
|
||||
bufferWrite = createMatrix(1,header + 3);
|
||||
FILE *file = fopen(path,"rb");
|
||||
if (file == NULL){
|
||||
perror("failed open file");
|
||||
return;
|
||||
}
|
||||
|
||||
fread(bufferWrite,sizeof(GrayScalePixelType),, bufferRead);
|
||||
fseek(file, header, SEEK_SET);
|
||||
|
||||
pictures = *bufferRead + header;
|
||||
fread(ptrPicturesCount, sizeof(unsigned short), 1, file);
|
||||
fread(ptrPictureWidth, sizeof(unsigned short), 1, file);
|
||||
fread(ptrPictureHeight, sizeof(unsigned short), 1, file);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
||||
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
||||
GrayScaleImageSeries *readImages(const char *path)
|
||||
{
|
||||
unsigned short picturesCount, pictureWidth, pictureHeight;
|
||||
Matrix labels = creatmatrix(1,picturesCount);
|
||||
Matrix images = creatmatrix(1,picturesCount);
|
||||
|
||||
|
||||
|
||||
@ -38,3 +46,17 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
void clearSeries(GrayScaleImageSeries *series)
|
||||
{
|
||||
}
|
||||
|
||||
MatrixChar createMatrix(unsigned int rows, unsigned int cols)
|
||||
{
|
||||
if(rows <= 0 || cols <= 0){
|
||||
Matrix matrix = { 0 , 0 , UNDEFINED_MATRIX_VALUE };
|
||||
return matrix;
|
||||
}
|
||||
|
||||
MatrixChar matrix = { rows , cols };
|
||||
|
||||
matrix.buffer = malloc((sizeof(char)*rows*cols));
|
||||
|
||||
return matrix;
|
||||
}
|
||||
@ -17,6 +17,12 @@ typedef struct
|
||||
unsigned int count;
|
||||
} GrayScaleImageSeries;
|
||||
|
||||
typedef struct{
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
MatrixType *buffer;
|
||||
}MatrixChar;
|
||||
|
||||
GrayScaleImageSeries *readImages(const char *path);
|
||||
void clearSeries(GrayScaleImageSeries *series);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user