MATLAB imwarp vs C ++ warpAffine

时间:2017-12-15 11:19:06

标签: c++ matlab opencv

我正在尝试通过Opencv库将以下MATLAB代码转换为c ++代码

Matlab代码:

scale_x = 0.99951;
scale_y = 0.99951;
RsrcImg= imref2d(size(im1));
T=[scale_x 0 0;0 scale_y 0;0 0 1];
tformEstimate = affine2d(T);
destImg =imwarp(im1,tformEstimate,'Interp','cubic','OutputView',RsrcImg);

C ++代码:

double scale_x = 0.99951;
double scale_y = 0.99951;
Mat tformEstimate=Mat::zeros(2,3,CV_64FC1);
tformEstimate.at<double>(0,0)=scale_x;
tformEstimate.at<double>(1,1)=scale_y;
warpAffine(im1,destImg,tformEstimate,im1.size(),INTER_CUBIC);

但我的PSNR值完全不同!有没有办法让两个代码都能使用相同的结果?

INPUT:

im1=[19656,20452,21048,21020,20564;
20740,21332,21964,20932,20220;
21688,21832,20236,21520,21948;
19780,20572,21056,20748,20088;
20560,21188,20608,22136,20736]

Matlab输出:

[19656.4613056001,20452.8984647534,21048.6416903208,21019.5009522438,0;
20741.1425789163,21333.2772155087,21963.2997618553,20930.5373907996,0; 
21687.3205560205,21830.7204384573,20235.1172001277,21521.5360776160,0;
19779.1003189859,20572.0033036149,21056.4880106032,20747.6616956745,0;
0,0,0,0,0]

C ++输出:

[19656.00000  20452.00000  21048.00000  21020.00000  20564.00000  
20740.00000  21332.00000  21964.00000  20932.00000  20220.00000  
21688.00000  21832.00000  20236.00000  21520.00000  21948.00000  
19780.00000  20572.00000  21056.00000  20748.00000  20088.00000  
20560.00000  21188.00000  20608.00000  22136.00000  20736.00000] 

我见过 MATLAB vs C++ vs OpenCV - imresize 没有成功。

感谢您的帮助。

0 个答案:

没有答案