// Aplica los filtros a images/sun.pgm y dibuja el resultado.
// Se corre desde lab/image: build/filter_demo
#include <stdio.h>

#include "filters.h"

int main(void) {
    struct image *img = image_load("images/sun.pgm");
    if (img == NULL) {
        fprintf(stderr, "No se pudo leer images/sun.pgm\n");
        return 1;
    }

    int min = 0;
    int max = 0;
    double mean = 0.0;
    image_stats(img, &min, &max, &mean);
    printf("Tamaño: %d x %d\n", img->width, img->height);
    printf("Mínimo %d, máximo %d, promedio %.2f\n", min, max, mean);

    flip_horizontal(img);
    printf("flip_horizontal:\n");
    image_show(img);

    threshold(img, 128);
    printf("threshold 128:\n");
    image_show(img);

    invert(img);
    printf("invert:\n");
    image_show(img);

    if (!image_save(img, "build/sun_result.pgm")) {
        fprintf(stderr, "No se pudo escribir build/sun_result.pgm\n");
        image_free(img);
        return 1;
    }

    image_free(img);
    return 0;
}
