重映射

1 void remap(InputArray src,OutputArray dst,InputArray map1,InputArray map2,int interpolation,int borderMode=BORDER_CONSTANT,const Scalar&borderValue=Scalar())

include<opencv2/opencv.hpp>

include

using namespace cv;
int main()
{
Mat srcImage,dstImage;
Mat map_x, map_y;
srcImage = imread("D:/jianji.jpg",1);
imshow("原始图", srcImage);
dstImage.create(srcImage.size(), srcImage.type());
map_x.create(srcImage.size(), CV_32FC1);
map_y.create(srcImage.size(), CV_32FC1);
for (int j = 0; j < srcImage.rows; j++)
{
for (int i = 0; i < srcImage.cols; i++)
{
//改变map_x&map_y的值
map_x.at(j, i) = static_cast(i);
map_y.at(j, i) = static_cast(srcImage.rows - j);
}
}
remap(srcImage, dstImage, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0, 0, 0));
imshow("【程序窗口】", dstImage);
waitKey();
return 0;

}

posted @ 2019-12-07 16:06  我输过但没服过  阅读(103)  评论(0编辑  收藏  举报