| | |
| | | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | } |
| | | } |
| | | } |
| | | 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; |
| | | } |