I think the following examples shows a bug in warpAffine: Mat x(1,20, CV_32FC1); for (int iCol(0); iCol<x.cols; icol++)="" {="" x.col(icol).setto(icol);="" }="" mat="" crop;="" point2d="" c(10.,="" 0.);="" double="" scale(1.3);="" int="" cropsz(11);="" double="" vals[6]="{" scale,="" 0.0,="" c.x-(cropsz="" 2)*scale,="" 0.0,="" scale,="" c.y="" };="" mat="" map(2,="" 3,="" cv_64fc1,="" vals);="" warpaffine(x,="" crop,="" map,="" size(cropsz,="" 1),="" warp_inverse_map="" |="" inter_linear);="" float="" dx="(crop.at<float">(0, crop.cols-1) - crop.at<float>(0, 0))/(crop.cols-1); Mat constGrad = crop.clone().setTo(0); for (int iCol(0); iCol<constgrad.cols; icol++)="" {="" constgrad.col(icol)="c.x" +="" (icol-cropsz="" 2)*scale;="" }="" mat="" diff="crop" -="" constgrad;="" double="" err="norm(diff," norm_inf);="" if="" (err="">1e-4) { cout << "Problem" << endl; } I create an image with entries 0, 1, 2, ...n-1, and cut a region around (10,0) with scale 1.3. I also create an expected image constGrad. However, they are not the same. It's not a boundary stuff problem, the same happens at the inner of an image and also without WARP_INVERSE_MAP The error is at most about 0.03.