Joseph Redmon
2015-08-17 3a99b8151f6a002353691b1254b395eb52effefa
src/image.c
@@ -3,6 +3,11 @@
#include <stdio.h>
#include <math.h>
#ifdef OPENCV
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#endif
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
@@ -188,7 +193,7 @@
    int x,y,k;
    image copy = copy_image(p);
    constrain_image(copy);
    rgbgr_image(copy);
    if(p.c == 3) rgbgr_image(copy);
    //normalize_image(copy);
    char buff[256];
@@ -249,6 +254,7 @@
        }
    }
    int success = stbi_write_png(buff, im.w, im.h, im.c, data, im.w*im.c);
    free(data);
    if(!success) fprintf(stderr, "Failed to write image %s\n", buff);
}
@@ -849,8 +855,16 @@
void show_images(image *ims, int n, char *window)
{
    image m = collapse_images_vert(ims, n);
    save_image(m, window);
    show_image(m, window);
    int w = 448;
    int h = ((float)m.h/m.w) * 448;
    if(h > 896){
        h = 896;
        w = ((float)m.w/m.h) * 896;
    }
    image sized = resize_image(m, w, h);
    save_image(sized, window);
    show_image(sized, window);
    free_image(sized);
    free_image(m);
}