Joseph Redmon
2014-12-04 1edcf73a73d2007afc61289245763f5cf0c29e10
src/image.c
@@ -4,6 +4,23 @@
int windows = 0;
void draw_box(image a, int x1, int y1, int x2, int y2)
{
    int i, c;
    for(c = 0; c < a.c; ++c){
        for(i = x1; i < x2; ++i){
            a.data[i + y1*a.w + c*a.w*a.h] = (c==0)?1:-1;
            a.data[i + y2*a.w + c*a.w*a.h] = (c==0)?1:-1;
        }
    }
    for(c = 0; c < a.c; ++c){
        for(i = y1; i < y2; ++i){
            a.data[x1 + i*a.w + c*a.w*a.h] = (c==0)?1:-1;
            a.data[x2 + i*a.w + c*a.w*a.h] = (c==0)?1:-1;
        }
    }
}
image image_distance(image a, image b)
{
    int i,j;
@@ -138,7 +155,7 @@
    }
    free_image(copy);
    if(disp->height < 500 || disp->width < 500 || disp->height > 1000){
        int w = 1500;
        int w = 500;
        int h = w*p.h/p.w;
        if(h > 1000){
            h = 1000;
@@ -199,6 +216,7 @@
image make_empty_image(int h, int w, int c)
{
    image out;
    out.data = 0;
    out.h = h;
    out.w = w;
    out.c = c;
@@ -368,7 +386,6 @@
        // Will do a scaled image resize with the correct aspect ratio.
        outImg = resizeImage(croppedImg, newHeight, newWidth, 0);
        cvReleaseImage( &croppedImg );
    }
    else {
@@ -414,6 +431,25 @@
    return out;
}
image load_image_color(char *filename, int h, int w)
{
    IplImage* src = 0;
    if( (src = cvLoadImage(filename, 1)) == 0 )
    {
        printf("Cannot load file image %s\n", filename);
        exit(0);
    }
    if(h && w && (src->height != h || src->width != w)){
        //printf("Resized!\n");
        IplImage *resized = resizeImage(src, h, w, 0);
        cvReleaseImage(&src);
        src = resized;
    }
    image out = ipl_to_image(src);
    cvReleaseImage(&src);
    return out;
}
image load_image(char *filename, int h, int w)
{
    IplImage* src = 0;