对于 OpenCV,请查看remap。
编辑:轻松/快速创建地图(使用矢量):
//Create vector of what the rows/cols look like
std::vector<int> t_X,t_Y;
for (int i = 0; i < img.cols(); i++) t_X.push_back(i);
for (int i = 0; i < img.rows(); i++) t_Y.push_back(i);
//circular shift t_X vector
std::vector<int>::iterator it;
int zeroPixel = 50; //This x-pixel to bring to 0 (shifting to the left)
it = std::find(t_X.begin(), t_X.end(), zeroPixel);
std::rotate(t_X.begin(), it, t_X.end());
//Create Maps
//Turn vectors in cv::Mat
cv::Mat xRange = cv::Mat(t_X);
cv::Mat yRange = cv::Mat(t_Y);
//Maps
cv::Mat xMap;
cv::Mat yMap;
cv::repeat(xRange.reshape(1,1), yRange.total(), 1, xMap);
cv::repeat(yRange.reshape(1,1).t(), 1, xRange.total(), yMap);
您还可以使用 ROI
int zeroPixel = 50;
cv::Mat newMat;
cv::Mat rightHalf = img(cv::Rect(0,0,zeroPixel,img.rows()));
cv::Mat leftHalf = img(cv::Rect(0,zeroPixel+1,img.cols()-zeroPixel-1,img.rows());
cv::hconcat(leftHalf , rightHalf , newMat);