generated from freudenreichan/info2Praktikum-NeuronalesNetz
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "imageInput.h"
|
|
|
|
#define BUFFER_SIZE 100
|
|
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
|
|
|
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
|
static unsigned short readNumberOfImages(const char *path)
|
|
{
|
|
unsigned short numberOfImages = 0;
|
|
fseek(path, sizeof(char)*strlen(FILE_HEADER_STRING)-1, SEEK_SET);
|
|
fread(numberOfImages, sizeof(unsigned short), 1, path);
|
|
return numberOfImages;
|
|
}
|
|
|
|
static unsigned short readImageWidth(const char *path)
|
|
{
|
|
unsigned short ImageWidth = 0;
|
|
fseek(path, sizeof(unsigned short), SEEK_CUR);
|
|
fread(ImageWidth, sizeof(unsigned short), 1, path);
|
|
return ImageWidth;
|
|
}
|
|
|
|
static unsigned short readImageHeight(const char *path)
|
|
{
|
|
unsigned short ImageHeight = 0;
|
|
fseek(path, sizeof(unsigned short), SEEK_CUR);
|
|
fread(ImageHeight, sizeof(unsigned short), 1,path);
|
|
return ImageHeight;
|
|
|
|
}
|
|
|
|
static *readImage(const char *path, unsigned short ImageWidth, unsigned short ImageHeight)
|
|
{
|
|
fseek(path, sizeof(unsigned short), SEEK_CUR);
|
|
fread(path, sizeof(char), ImageHeight*ImageWidth, path);
|
|
}
|
|
|
|
|
|
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
|
GrayScaleImageSeries *readImages(const char *path)
|
|
{
|
|
GrayScaleImageSeries *series = NULL;
|
|
FILE *file = fopen(path, "wb");
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
return series;
|
|
}
|
|
|
|
// TODO Vervollständigen Sie die Funktion clearSeries, welche eine Bildserie vollständig aus dem Speicher freigibt
|
|
void clearSeries(GrayScaleImageSeries *series)
|
|
{
|
|
} |