Fast Affine Template Matching over Galois Field热力图实现

参考:

https://cpp.hotexamples.com/examples/-/-/mxCreateDoubleMatrix/cpp-mxcreatedoublematrix-function-examples.html

https://www.csdn.net/gather_27/NtDaEg5sOTY2LWJsb2cO0O0O.html

http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/apiref/mx-c.html

https://zlearning.netlify.com/communication/matlab/matlabmxcreatedoulbematrix

https://zlearning.netlify.com/

https://www.mathworks.com/help/matlab/ref/jet.html

 

论文Fast Affine Template Matching over Galois Field热力图实现

论文效果:

我的效果:

后面的图不列出来了,效果非常接近

上代码:

EvaluateConfigs_mex.cpp加入如下代码:

    ......

    double *targetImgPointFrequency;
    plhs[1] = mxCreateDoubleMatrix(w2, h2, mxREAL);
    targetImgPointFrequency = mxGetPr(plhs[1]);

    ......


	if (!usePhotometrics) {
		for (int j = 0; j < numPoints ; j++) {
			targetPoint_x = int(a11*(*ptrXsc) + a12*(*ptrYsc) + tmp1); 
			targetPoint_y = int(a21*(*ptrXsc) + a22*(*ptrYsc) + tmp2); 
			targetInd = (targetPoint_y - 1)*w2 + targetPoint_x - 1; // -1 is for c

			int index_c = targetInd%(h2*w2);//add code
			targetImgPointFrequency[index_c] += 1;//add code

			score += (fabs((*ptrVals) - img2[targetInd]));
			ptrVals++;
			ptrXsc++;
			ptrYsc++;
		}
	}

    ......

FindBestTransformation.m加入如下代码:

        if (isGrayscale)
            [distances,targetImgPointFrequency] = EvaluateConfigs_mex(I1',I2',matrixConfigs_mex,int32(xs),int32(ys),int32(photometricInvariance));
            fprintf('----- Evaluate Configs grayscale, with %d configs -----\n',size(configs,1));
        else
            distances = EvaluateConfigsVectorized_mex(permute(I1,[3,2,1]),permute(I2,[3,2,1]),matrixConfigs_mex,int32(xs),int32(ys),int32(photometricInvariance));
            fprintf('----- Evaluate Configs vectorized, with %d configs -----\n',size(configs,1));
        end
		
		
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %Heat map of matching frequency
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        [mmm,nnn] = size(I2);
        [Xedgemesh,Yedgemesh]=meshgrid([1:1:nnn],[1:1:mmm]);
        figure(100+level)
        % shading interp对曲面或图形对象的颜色着色进行色彩的插值处理,使色彩平滑过渡
        pcolor(Xedgemesh,Yedgemesh,fliplr(targetImgPointFrequency)');colormap('jet');shading interp
        
        EvaluateConfigs_mex_time = toc(EvaluateConfigsMEX);
        
        totTime = totTime + Configs2Affine_mex_time + EvaluateConfigs_mex_time;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章