Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Problems with function for normalised cross correlation

$
0
0
Hi everyone! I'm trying to implement a function for NCC, but I have some problems, the function gives me the error malloc.c:2372. I think the problem probably is in the function CalculateDen....But I don't understand if is the only problem. Can you help me? xD float CalculateDen(IplImage *image, int dMax) { float sum; for (int i = 0; i < image->height; i++) for (int j = 0; j < image->width; j++) for (int d = 0; d < dMax + 1; d++) { sum+=CV_IMAGE_ELEM(image, float, i, j)*CV_IMAGE_ELEM(image, float, i, j); } return sum; } /////////////////////////////////////////////////////////////////// int NormalisedCrossCorrelationCost(IplImage *L, IplImage *R, int dMax, f_DSI *DSI) { float den=sqrt(CalcolaOperandoDen(L,dMax)*CalcolaOperandoDen(R,dMax)); for (int i = 0; i < L->height; i++) for (int j = 0; j < L->width; j++) for (int d = 0; d < dMax + 1; d++) { float cost; int j_R= (j-d < 0 ? 0 : j-d); cost = ( CV_IMAGE_ELEM(L, float , i, j) * CV_IMAGE_ELEM(R, float, i, j_R) )/den; DSI->values[d*L->width*L->height + i*L->width + j] = cost; } return 0; }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>