forked from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51f176e892 | ||
|
|
fbd456f6a0 |
No files matched your search
+3
-91
@@ -8,103 +8,15 @@
|
|||||||
|
|
||||||
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
// TODO Implementieren Sie geeignete Hilfsfunktionen für das Lesen der Bildserie aus einer Datei
|
||||||
|
|
||||||
/* Liest den Datei-Header sowie Anzahl und Abmessungen der Bilder. */
|
|
||||||
static int readFileHeader(FILE *file, unsigned short *count, unsigned short *width, unsigned short *height)
|
|
||||||
{
|
|
||||||
char tag[sizeof(FILE_HEADER_STRING) - 1];
|
|
||||||
|
|
||||||
return fread(tag, sizeof(tag), 1, file) == 1 &&
|
|
||||||
memcmp(tag, FILE_HEADER_STRING, sizeof(tag)) == 0 && /* vergleicht File-Header mit dem erwarteten Wert */
|
|
||||||
fread(count, sizeof(*count), 1, file) == 1 &&
|
|
||||||
fread(width, sizeof(*width), 1, file) == 1 &&
|
|
||||||
fread(height, sizeof(*height), 1, file) == 1 &&
|
|
||||||
*count > 0 && *width > 0 && *height > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Liest die Pixel und das unmittelbar folgende Label eines Bildes. */
|
|
||||||
static int readImage(FILE *file, GrayScaleImage *image, unsigned char *label, size_t pixelCount)
|
|
||||||
{
|
|
||||||
image->buffer = (GrayScalePixelType *)malloc(pixelCount);
|
|
||||||
if (image->buffer == NULL || fread(image->buffer, sizeof(*image->buffer), pixelCount, file) != pixelCount || fread(label, sizeof(*label), 1, file) != 1) /*Prüft ob Speicher korrekt reserviert wurde */
|
|
||||||
{
|
|
||||||
free(image->buffer);
|
|
||||||
image->buffer = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gibt auch bereits teilweise geladene Serien und deren Pixelpuffer frei. */
|
|
||||||
static void freeImages(GrayScaleImageSeries *series)
|
|
||||||
{
|
|
||||||
if (series == NULL) /*Prüft ob Serie übergeben Wurde*/
|
|
||||||
return;
|
|
||||||
if (series->images != NULL)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < series->count; ++i) /* Prüft jedes bIld der Serie*/
|
|
||||||
free(series->images[i].buffer);
|
|
||||||
}
|
|
||||||
free(series->images);
|
|
||||||
free(series->labels);
|
|
||||||
free(series);
|
|
||||||
}
|
|
||||||
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
// TODO 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;
|
||||||
unsigned short count, width, height;
|
|
||||||
size_t pixelCount;
|
|
||||||
FILE *file;
|
|
||||||
|
|
||||||
if (path == NULL || (file = fopen(path, "rb")) == NULL) /*prüft ob sich Pfad öffnen lässt*/
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Zuerst den Header prüfen, bevor Speicher reserviert wird */
|
|
||||||
if (!readFileHeader(file, &count, &width, &height))
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pixelCount = (size_t)width * height;
|
|
||||||
series = (GrayScaleImageSeries *)calloc(1, sizeof(*series)); /*Speicher für Serie reservieren*/
|
|
||||||
if (series == NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
series->count = count; /*speicher die anzahl der Bilder*/
|
|
||||||
series->images = (GrayScaleImage *)calloc(count, sizeof(*series->images));
|
|
||||||
series->labels = (unsigned char *)malloc(count * sizeof(*series->labels));
|
|
||||||
if (series->images == NULL || series->labels == NULL)
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Parameter jedes Bildes einlesen*/
|
|
||||||
for (unsigned int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
series->images[i].width = width;
|
|
||||||
series->images[i].height = height;
|
|
||||||
if (!readImage(file, &series->images[i], &series->labels[i], pixelCount))
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Vervollständigen Sie die Funktion clearSeries, welche eine Bildserie vollständig aus dem Speicher freigibt
|
||||||
void clearSeries(GrayScaleImageSeries *series)
|
void clearSeries(GrayScaleImageSeries *series)
|
||||||
{
|
{
|
||||||
freeImages(series);
|
}
|
||||||
}
|
|
||||||
@@ -119,17 +119,6 @@ void test_readImagesFailsOnWrongFileTag(void)
|
|||||||
remove(path);
|
remove(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_readImagesFailsOnZeroWidth(void)
|
|
||||||
{
|
|
||||||
const char *path = "testFile.info2";
|
|
||||||
|
|
||||||
prepareImageFile(path, 0, 8, 1, 1);
|
|
||||||
|
|
||||||
TEST_ASSERT_NULL(readImages(path));
|
|
||||||
|
|
||||||
remove(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUp(void) {
|
void setUp(void) {
|
||||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||||
}
|
}
|
||||||
@@ -149,7 +138,6 @@ int main()
|
|||||||
RUN_TEST(test_readImagesReturnsCorrectLabels);
|
RUN_TEST(test_readImagesReturnsCorrectLabels);
|
||||||
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
|
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
|
||||||
RUN_TEST(test_readImagesFailsOnWrongFileTag);
|
RUN_TEST(test_readImagesFailsOnWrongFileTag);
|
||||||
RUN_TEST(test_readImagesFailsOnZeroWidth);
|
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
+2
-130
@@ -6,158 +6,30 @@
|
|||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||||
{
|
{
|
||||||
if (rows == 0 || cols == 0) {
|
|
||||||
return (Matrix){0}; // Setzt rows, cols und den Puffer auf 0/NULL
|
|
||||||
}
|
|
||||||
Matrix m;
|
|
||||||
m.rows = rows;
|
|
||||||
m.cols = cols;
|
|
||||||
|
|
||||||
// Speicher reservieren und mit 0 initialisieren
|
|
||||||
m.buffer = (MatrixType *)calloc((size_t)rows * cols, sizeof(MatrixType));
|
|
||||||
|
|
||||||
// Falls Arbeitsspeicher voll ist
|
|
||||||
if (m.buffer == NULL) {
|
|
||||||
m.rows = 0;
|
|
||||||
m.cols = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearMatrix(Matrix *matrix)
|
void clearMatrix(Matrix *matrix)
|
||||||
{
|
{
|
||||||
//prüfen ob pointer exisitert und ob es einen buffer gibt
|
|
||||||
if (matrix != NULL && matrix->buffer != NULL)
|
|
||||||
{
|
|
||||||
// Speicher freigeben
|
|
||||||
free(matrix->buffer);
|
|
||||||
|
|
||||||
// Werte zurücksetzen
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
// Sind Idx innerhalb der Matrix?
|
|
||||||
if (matrix.buffer != NULL && rowIdx < matrix.rows && colIdx < matrix.cols)
|
|
||||||
{
|
|
||||||
// Umrechnung von 2D auf 1D
|
|
||||||
matrix.buffer[rowIdx * matrix.cols + colIdx] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
{
|
{
|
||||||
// Sicherheitsprüfung wie beim setzen
|
|
||||||
if (matrix.buffer != NULL && rowIdx < matrix.rows && colIdx < matrix.cols)
|
|
||||||
{
|
|
||||||
return matrix.buffer[rowIdx * matrix.cols + colIdx];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fehlerwert, falls außerhalb der grenzen
|
|
||||||
return UNDEFINED_MATRIX_VALUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
// Prüfen ob Zeilenanzahl gleich ist und ob buffer existieren
|
|
||||||
if (matrix1.buffer == NULL || matrix2.buffer == NULL || matrix1.rows != matrix2.rows)
|
|
||||||
{
|
|
||||||
return (Matrix){0};
|
|
||||||
}
|
|
||||||
// Wenn beide Matrixen gleich groß sind:
|
|
||||||
if (matrix1.cols == matrix2.cols)
|
|
||||||
{
|
|
||||||
Matrix result = createMatrix(matrix1.rows, matrix1.cols);
|
|
||||||
if (result.buffer == NULL) return (Matrix){0};
|
|
||||||
|
|
||||||
unsigned int totalElements = matrix1.rows * matrix1.cols;
|
|
||||||
for (unsigned int i = 0; i < totalElements; i++)
|
|
||||||
{
|
|
||||||
result.buffer[i] = matrix1.buffer[i] + matrix2.buffer[i];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//Wenn matrix2 ein Spaltenvektor ist
|
|
||||||
else if (matrix2.cols == 1)
|
|
||||||
{
|
|
||||||
Matrix result = createMatrix(matrix1.rows, matrix1.cols);
|
|
||||||
if (result.buffer == NULL) return (Matrix){0};
|
|
||||||
|
|
||||||
for (unsigned int r = 0; r < matrix1.rows; r++)
|
|
||||||
{
|
|
||||||
for (unsigned int c = 0; c < matrix1.cols; c++)
|
|
||||||
{
|
|
||||||
// Wert mit r und c aus m1 + Wert mit r aus m2
|
|
||||||
result.buffer[r * matrix1.cols + c] = matrix1.buffer[r * matrix1.cols + c] + matrix2.buffer[r];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//Wenn matrix1 ein Spaltenvektor ist
|
|
||||||
else if (matrix1.cols == 1)
|
|
||||||
{
|
|
||||||
Matrix result = createMatrix(matrix2.rows, matrix2.cols);
|
|
||||||
if (result.buffer == NULL) return (Matrix){0};
|
|
||||||
|
|
||||||
for (unsigned int r = 0; r < matrix2.rows; r++)
|
|
||||||
{
|
|
||||||
for (unsigned int c = 0; c < matrix2.cols; c++)
|
|
||||||
{
|
|
||||||
//gleich wie davor nur m1 und m2 getauscht
|
|
||||||
result.buffer[r * matrix2.cols + c] = matrix2.buffer[r * matrix2.cols + c] + matrix1.buffer[r];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Matrix){0};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
// Überprüfen, ob die Matrizen gültig sind und ob ihre Dimensionen eine Multiplikation erlauben
|
|
||||||
if (matrix1.buffer == NULL || matrix2.buffer == NULL || matrix1.cols != matrix2.rows)
|
|
||||||
{
|
|
||||||
return (Matrix){0};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ergebnismatrix erstellen
|
|
||||||
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
|
|
||||||
|
|
||||||
// Überprüfen, ob die Speicherreservierung erfolgreich war
|
|
||||||
if (result.buffer == NULL)
|
|
||||||
{
|
|
||||||
return (Matrix){0};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jede Zeile der ersten Matrix durchlaufen
|
|
||||||
for (unsigned int i = 0; i < matrix1.rows; i++)
|
|
||||||
{
|
|
||||||
// Jede Spalte der zweiten Matrix durchlaufen
|
|
||||||
for (unsigned int j = 0; j < matrix2.cols; j++)
|
|
||||||
{
|
|
||||||
MatrixType sum = 0;
|
|
||||||
|
|
||||||
// Summe der Produkte berechnen
|
|
||||||
for (unsigned int k = 0; k < matrix1.cols; k++)
|
|
||||||
{
|
|
||||||
sum += matrix1.buffer[i * matrix1.cols + k] *
|
|
||||||
matrix2.buffer[k * matrix2.cols + j];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Berechneten Wert in der Ergebnismatrix speichern
|
|
||||||
result.buffer[i * result.cols + j] = sum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -7,9 +7,9 @@ typedef float MatrixType;
|
|||||||
|
|
||||||
// TODO Matrixtyp definieren
|
// TODO Matrixtyp definieren
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MatrixType *buffer;
|
|
||||||
unsigned int rows;
|
unsigned int rows;
|
||||||
unsigned int cols;
|
unsigned int cols;
|
||||||
|
MatrixType *buffer; // Speichert die Matrixwerte in einem Array, zeigt die Speicheradresse des ersten Matrixwerts im Array
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
|
|
||||||
@@ -21,4 +21,4 @@ Matrix add(const Matrix matrix1, const Matrix matrix2);
|
|||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -9,39 +9,6 @@
|
|||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
FILE *file = fopen(path, "wb");
|
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *fileTag = "__info2_neural_network_file_format__";
|
|
||||||
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
|
||||||
|
|
||||||
if (nn.numberOfLayers > 0)
|
|
||||||
{
|
|
||||||
fwrite(&nn.layers[0].weights.cols, sizeof(int), 1, file);
|
|
||||||
fwrite(&nn.layers[0].weights.rows, sizeof(int), 1, file);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
fwrite(&nn.layers[i].weights.rows, sizeof(int), 1, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType),
|
|
||||||
nn.layers[i].weights.rows * nn.layers[i].weights.cols, file);
|
|
||||||
|
|
||||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType),
|
|
||||||
nn.layers[i].biases.rows * nn.layers[i].biases.cols, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int endDimension = 0;
|
|
||||||
fwrite(&endDimension, sizeof(int), 1, file);
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
-110
@@ -1,110 +0,0 @@
|
|||||||
#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
|
|
||||||
|
|
||||||
/* Liest den Datei-Header sowie Anzahl und Abmessungen der Bilder. */
|
|
||||||
static int readFileHeader(FILE *file, unsigned short *count, unsigned short *width, unsigned short *height)
|
|
||||||
{
|
|
||||||
char tag[sizeof(FILE_HEADER_STRING) - 1];
|
|
||||||
|
|
||||||
return fread(tag, sizeof(tag), 1, file) == 1 &&
|
|
||||||
memcmp(tag, FILE_HEADER_STRING, sizeof(tag)) == 0 && /* vergleicht File-Header mit dem erwarteten Wert */
|
|
||||||
fread(count, sizeof(*count), 1, file) == 1 &&
|
|
||||||
fread(width, sizeof(*width), 1, file) == 1 &&
|
|
||||||
fread(height, sizeof(*height), 1, file) == 1 &&
|
|
||||||
*count > 0 && *width > 0 && *height > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Liest die Pixel und das unmittelbar folgende Label eines Bildes. */
|
|
||||||
static int readImage(FILE *file, GrayScaleImage *image, unsigned char *label, size_t pixelCount)
|
|
||||||
{
|
|
||||||
image->buffer = (GrayScalePixelType *)malloc(pixelCount);
|
|
||||||
if (image->buffer == NULL || fread(image->buffer, sizeof(*image->buffer), pixelCount, file) != pixelCount || fread(label, sizeof(*label), 1, file) != 1) /*Prüft ob Speicher korrekt reserviert wurde */
|
|
||||||
{
|
|
||||||
free(image->buffer);
|
|
||||||
image->buffer = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gibt auch bereits teilweise geladene Serien und deren Pixelpuffer frei. */
|
|
||||||
static void freeImages(GrayScaleImageSeries *series)
|
|
||||||
{
|
|
||||||
if (series == NULL) /*Prüft ob Serie übergeben Wurde*/
|
|
||||||
return;
|
|
||||||
if (series->images != NULL)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < series->count; ++i) /* Prüft jedes bIld der Serie*/
|
|
||||||
free(series->images[i].buffer);
|
|
||||||
}
|
|
||||||
free(series->images);
|
|
||||||
free(series->labels);
|
|
||||||
free(series);
|
|
||||||
}
|
|
||||||
// TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen
|
|
||||||
GrayScaleImageSeries *readImages(const char *path)
|
|
||||||
{
|
|
||||||
GrayScaleImageSeries *series = NULL;
|
|
||||||
unsigned short count, width, height;
|
|
||||||
size_t pixelCount;
|
|
||||||
FILE *file;
|
|
||||||
|
|
||||||
if (path == NULL || (file = fopen(path, "rb")) == NULL) /*prüft ob sich Pfad öffnen lässt*/
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Zuerst den Header prüfen, bevor Speicher reserviert wird */
|
|
||||||
if (!readFileHeader(file, &count, &width, &height))
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pixelCount = (size_t)width * height;
|
|
||||||
series = (GrayScaleImageSeries *)calloc(1, sizeof(*series)); /*Speicher für Serie reservieren*/
|
|
||||||
if (series == NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
series->count = count; /*speicher die anzahl der Bilder*/
|
|
||||||
series->images = (GrayScaleImage *)calloc(count, sizeof(*series->images));
|
|
||||||
series->labels = (unsigned char *)malloc(count * sizeof(*series->labels));
|
|
||||||
if (series->images == NULL || series->labels == NULL)
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Parameter jedes Bildes einlesen*/
|
|
||||||
for (unsigned int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
series->images[i].width = width;
|
|
||||||
series->images[i].height = height;
|
|
||||||
if (!readImage(file, &series->images[i], &series->labels[i], pixelCount))
|
|
||||||
{
|
|
||||||
fclose(file);
|
|
||||||
freeImages(series);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
return series;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearSeries(GrayScaleImageSeries *series)
|
|
||||||
{
|
|
||||||
freeImages(series);
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user