赞
踩
-
- #include <iostream>
- #include <opencv2/core.hpp>
- #include <opencv2/highgui.hpp>
- #include <opencv2/imgproc.hpp>
- #include <opencv2/videoio.hpp>
- #include <opencv2/video.hpp>
-
- using namespace cv;
- using namespace std;
-
- int main(int argc, char** argv)
- {
- //0.变量定义
- Mat srcImage, dstImage;
- Mat map_x, map_y;
-
- //1.载入原始图
- srcImage = imread("700levi.jpg");
- imshow("原始图", srcImage);
-
- //2.创建和原始图一样的效果图, x重映射图, y重映射图
- dstImage.create(srcImage.size(), srcImage.type());
- map_x.create(srcImage.size(), CV_32FC1);
- map_y.create(srcImage.size(), CV_32FC1);
-
- //3.双层循环 遍历每一个像素点, 改变map_x和map_y的值
- for (int i = 0; i < srcImage.rows; i++)
- {
- for (int j = 0; j < srcImage.cols; j++) {
- //改变map_x 和 map_y的值
- map_x.at<float>(i, j) = static_cast<float>(j);
- map_y.at<float>(i, j) = static_cast<float>(srcImage.rows-i);
- }
- }
-
- //4.进行重映射操作
- remap(srcImage, dstImage, map_x, map_y, INTER_LINEAR);
-
- //5.显示效果图
- imshow("程序窗口", dstImage);
-
- waitKey(0);
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。