diff --git a/src/mnist.c b/src/mnist.c new file mode 100644 index 0000000..992a0e3 --- /dev/null +++ b/src/mnist.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include + + +uint32_t swap_endian(uint32_t val) { + val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF); + return (val << 16) | (val >> 16); +} + + +// Renvoie une image sous forme d'un int** +int** read_image(unsigned int width, unsigned int height, FILE* ptr) { + unsigned char buffer[width*height]; + int** image = (int**)malloc(sizeof(int*)*height); + + size_t ligne_size = sizeof(int) * width; + + fread(buffer, sizeof(buffer), 1, ptr); + + for (int i=0; i