The result I get from conversion of conv2 function in matlab is very different from the result I get in opencv using filter2d function. In opencv in the position of (0,0) I get 1.1175871e-08 while the result I get in matlab is -0.9639
In Matlab:
A = [1,2,3,4; 1,2,3,4; 1,2,3,4];
k = [-0.014, -0.45, 0, 0.4, 0.01];
conv2(A, k, 'same');
In opencv/c++:
cv::Mat dst;
cv::Mat kernel;
float K[5] = {-0.014, -0.45, 0, 0.4, 0.01};
cv::Mat kernel(1, 5, CV_32F, K);
float test[3][4] = {{1, 2, 3, 4},{1, 2, 3, 4},{1, 2, 3, 4}};
cv::Mat myMat(3, 4, CV_32FC1, &test);
filter2D(myMat, dst, -1 , kernel , Point( -1, -1 ), 0, BORDER_DEFAULT);
What am I doing wrong in the opencv code?