Joseph Redmon
2014-03-13 2ea63c0e99a5358eaf38785ea83b9c5923fcc9cd
src/image.c
@@ -4,6 +4,21 @@
int windows = 0;
image image_distance(image a, image b)
{
    int i,j;
    image dist = make_image(a.h, a.w, 1);
    for(i = 0; i < a.c; ++i){
        for(j = 0; j < a.h*a.w; ++j){
            dist.data[j] += pow(a.data[i*a.h*a.w+j]-b.data[i*a.h*a.w+j],2);
        }
    }
    for(j = 0; j < a.h*a.w; ++j){
        dist.data[j] = sqrt(dist.data[j]);
    }
    return dist;
}
void subtract_image(image a, image b)
{
    int i;
@@ -121,7 +136,7 @@
        }
    }
    free_image(copy);
    if(disp->height < 500 || disp->width < 500){
    if(disp->height < 500 || disp->width < 500 || disp->height > 1000){
        int w = 1500;
        int h = w*p.h/p.w;
        if(h > 1000){
@@ -342,21 +357,11 @@
    return outImg;
}
image load_image(char *filename, int h, int w)
image ipl_to_image(IplImage* src)
{
    IplImage* src = 0;
    if( (src = cvLoadImage(filename,-1)) == 0 )
    {
        printf("Cannot load file image %s\n", filename);
        exit(0);
    }
    cvShowImage("Orig", src);
    IplImage *resized = resizeImage(src, h, w, 1);
    cvShowImage("Sized", resized);
    cvWaitKey(0);
    cvReleaseImage(&src);
    src = resized;
    unsigned char *data = (unsigned char *)src->imageData;
    int h = src->height;
    int w = src->width;
    int c = src->nChannels;
    int step = src->widthStep;
    image out = make_image(h,w,c);
@@ -369,6 +374,23 @@
            }
        }
    }
    return out;
}
image load_image(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 ){
        IplImage *resized = resizeImage(src, h, w, 1);
        cvReleaseImage(&src);
        src = resized;
    }
    image out = ipl_to_image(src);
    cvReleaseImage(&src);
    return out;
}