映射的概念-把数据(像素)按照规则重新排列
什么是像素重投影
简单点说就是把输入图像中各个像素按照一定的规则映射到另外一张图像的
对应位置上去,形成一张新的图像
[Math Processing Error] g(x,y)g(x,y) = [Math Processing Error] f(h(x,y))f(h(x,y))
[Math Processing Error] g(x,y)g(x,y)是重映射后的图像,[Math Processing Error]
hh是功能函数,[Math Processing Error] f(x,y)f(x,y)是原图像。
原图像[Math Processing Error] ff中每一点经过功能函数[Math Processing Error]
hh映射到新图像[Math Processing Error] gg中的每一点
API介绍cv::remap(重新映射)
Remap(可实现 缩小一半 X方向,Y方向对调以及XY方向同时对调)
(
InputArray src, //输入图像(三通道单通道深度都可以)
OutputArray dst,//输出图像
InputAray map1,// x映射表CV _32FC1/CV 32FC2(位数必须是这两种类型) 代表X方向上的映射规则
InputArray map2,// y映射表 代表Y方向的映射规则
int iterpalion/)选择的插值方法,常见线性插值, 可选择立方等
int borderMode,// BORDER CONSTANT(边缘的填充方式)
const Scalar borderValue// color(边缘的颜色)
}
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <iostream>
#include <math.h>
using namespace cv;
using namespace std;
int index = 0;
Mat src,dst,mapx,mapy,mapxy;
void update_map(void);
void Remap(int, void*);
int main()
{
src = imread("D:/实验台/机器视觉/测试图片/格子衬衫.jpg");
if (src.empty())//如果src这个数据库属性为空
{
cout << "无法打开" << endl;
return -1;
}
imshow("原图", src);
Remap(0</