diff --git a/.idea/NeuralNetwork.iml b/.idea/NeuralNetwork.iml
index bc2cd87..4c94235 100644
--- a/.idea/NeuralNetwork.iml
+++ b/.idea/NeuralNetwork.iml
@@ -1,8 +1,2 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
index 643ac7d..dc36d98 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -1,62 +1,299 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
+
@@ -64,6 +301,11 @@
+
+
+
+
+
@@ -75,507 +317,29 @@
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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/imageInput.c
+++ b/info2praktikum-neuronalesnetz/imageInput.c
@@ -7,12 +7,56 @@
#define FILE_HEADER_STRING "__info2_image_file_format__"
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
+// Lädt eine .info2-Datei und prüft, ob das Dateiformat korrekt ist
+FILE* openImageFile(const char* path) {
+ FILE* imageFile = NULL;
+ imageFile = fopen(path, "rb");
+
+ // Prüfe, ob die Datei mit dem richtigen String beginnt
+ char *fileHeaderString = (char*)malloc(BUFFER_SIZE);
+ fread(fileHeaderString, 1, (BUFFER_SIZE - 1), imageFile);
+
+ if (strngncmp(fileHeaderString, FILE_HEADER_STRING, BUFFER_SIZE, 27)) {
+ // Datei hat nicht das korrekte Format
+ return NULL;
+ }
+
+ return imageFile;
+}
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
GrayScaleImageSeries *readImages(const char *path)
{
GrayScaleImageSeries *series = NULL;
-
+
+ // Datei laden
+ FILE* imageFile = openImageFile(path);
+
+ if (imageFile == NULL) {
+ printf("Unbekannter Fehler");
+ return NULL;
+ }
+
+ // Springe in der Datei an die Stelle nach dem String am Beginn
+
+ // Lies folgende Informationen aus der Datei aus:
+ // 1) Anzahl der Bilder --> GreyScaleImageSeries.count
+ // 2) Breite der Bilder --> width
+ // 3) Höhe der Bilder --> height
+
+ // labels = unsigned char-Array mit der Größe wie AnzahlBilder
+
+ // Springe in der Datei an die Stelle nach den drei Zahlen
+
+ // für jedes Bild gemäß GreyScaleImageSeries.count:
+ // GreyScaleImage.width = width
+ // GreyScaleImage.height = height
+ // GreyScaleImageSeries.buffer = Pixelwerte
+ // labels = Label des Bilds
+ // Springe in der Datei an die Stelle nach dem i. Bild
+
+ // GrayScaleImageSeries.labels = labels (mit strcpy)
+
return series;
}
diff --git a/info2praktikum-neuronalesnetz/imageInput.h b/info2praktikum-neuronalesnetz/imageInput.h
index 656e213..884cc17 100644
--- a/info2praktikum-neuronalesnetz/imageInput.h
+++ b/info2praktikum-neuronalesnetz/imageInput.h
@@ -3,12 +3,15 @@
typedef unsigned char GrayScalePixelType;
+FILE* openImageFile(const char* path);
+
+// Für die Verarbeitung muss dynamsiche Speicherverwaltung angewendet werden
typedef struct
{
- GrayScalePixelType *buffer;
+ GrayScalePixelType *buffer; // Bytestream der ja Pixel die Graustufe als unsigned char angibt --> Je Pixel 8 Bit
unsigned int width;
unsigned int height;
-} GrayScaleImage;
+} GrayScaleImage; // Jedes Bild ist von der Logik her als Matrix gespeichert mit Höhe und Breite als Angabe für die Anzahl an Spalten und Reihen
typedef struct
{