OpenCV cvMatchTemplate same image size -
i trying find normalized cross correlation between 2 1-by-1 images. in order this, i'm using cvmatchtemplate. after using cvminmaxloc, maxval returns 1.00000 2 1-by-1 images.
so tried bypass trying use cvmatchtemplate on 6-by-3 image , 3-by-3 image. each original pixel, expanded out 6-by-3 , 3-by-3 see if provide better results. doesn't. maxval still returns 1.000000. there better way find ncc between 2 pixels?
cvsetimageroi(img, cvrect(curwidth, curheight, 1, 1)); iplimage* temproi = cvcreateimage(cvsize(1, 1), img->depth, img->nchannels); cvcopy(img, temproi); cvresetimageroi(img); iplimage* currentroi = cvcreateimage(cvsize(6,3), img->depth, img->nchannels); (int = 0; < 3; i++) { (int j = 0; j < 6; j++) { cvsetimageroi(currentroi, cvrect(j, i, 1, 1)); cvcopy(temproi, currentroi); cvresetimageroi(currentroi); } } cvreleaseimage(&temproi); cvsetimageroi(opp_img, cvrect(opp_loc, curheight, 1, 1)); temproi = cvcreateimage(cvsize(1, 1), opp_img->depth, opp_img->nchannels); cvcopy(opp_img, temproi); cvresetimageroi(opp_img); iplimage* centerroi = cvcreateimage(cvsize(3,3), opp_img->depth, opp_img->nchannels); (int = 0; < 3; i++) { (int j = 0; j < 3; j++) { cvsetimageroi(centerroi, cvrect(j, i, 1, 1)); cvcopy(temproi, centerroi); cvresetimageroi(centerroi); } } iplimage *re = cvcreateimage(cvsize(4, 1), ipl_depth_32f, 1); cvzero(re); cvmatchtemplate(currentroi, centerroi, re, cv_tm_ccorr_normed); cvminmaxloc(re, &minval, &maxval, &minloc, &maxloc);
it possible ncc on 1-by-1 images or images same image size, not useful usually. if search template t in image i, result r dimensions - t + 1 , if images same size, result 1x1. if search minmax location in image size(1x1) , return 1.000 expected.
Comments
Post a Comment