Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image OpenCV2使用变换贴图变换图像_Image_Image Processing_Opencv_Transformation - Fatal编程技术网

Image OpenCV2使用变换贴图变换图像

Image OpenCV2使用变换贴图变换图像,image,image-processing,opencv,transformation,Image,Image Processing,Opencv,Transformation,给定两个cv::Mat矩阵,它们将源图像中的每个像素映射到目标图像中的一个像素(R2到R2),我想将源图像转换为目标图像。我使用for循环成功地完成了此操作,但速度太慢: cv::Mat srcImg(100,100,CV_8U); //fill... cv::Mat dstImg(100,100,CV_8U); //dst2src ->backprojection //these matrices indicates for each pixel in the destinati

给定两个cv::Mat矩阵,它们将源图像中的每个像素映射到目标图像中的一个像素(R2到R2),我想将源图像转换为目标图像。我使用for循环成功地完成了此操作,但速度太慢:

cv::Mat srcImg(100,100,CV_8U);

//fill...

cv::Mat dstImg(100,100,CV_8U);

//dst2src ->backprojection

//these matrices indicates for each pixel in the destination image, where to map it from the source image

cv::Mat x_dst2src(100,100,CV_64F);

cv::Mat y_dst2src(100,100,CV_64F);

//fill...

for(int ydst=0; ydst!=100;++ydst)

{

    for(int xdst=0; xdst!=100;++xdst)
     {
      double xsrc = x_dst2src.at<double>(ydst,xdst);
      double ysrc = y_dst2src.at<double>(ydst,xdst);
      double val = getBicubic(srcImg,xsrc,ysrc);
      dstImg.at<double>(ydst,xdst) = val;

     }

}
cv::Mat srcImg(100100,cv_8U);
//填充。。。
cv::Mat dstImg(100100,cv_8U);
//dst2src->反投影
//这些矩阵指示目标图像中每个像素从源图像映射到的位置
cv::Mat x_dst2src(100100,cv_64F);
cv::材料y_dst2src(100100,cv_64F);
//填充。。。
用于(int-ydst=0;ydst!=100;++ydst)
{
对于(int-xdst=0;xdst!=100;++xdst)
{
双xsrc=x_dst2src.at(ydst,xdst);
双ysrc=ydst2src.at(ydst,xdst);
double val=getBicubic(srcImg、xsrc、ysrc);
dstImg.at(ydst,xdst)=val;
}
}
这段基本代码可以工作,但速度非常慢(我的图像大于100x100,我必须使用双三次曲线)。 谢谢


-O-

有一个很好的OpenCV函数,名为remap()。令人惊讶的是,它确实实现了这种转变

为了加快速度,您应该寻找另一个函数,它以比简单位置图更便于处理器的格式准备地图。(它类似于mapTransform(),请在
中查找它,另请参见
部分remap()文档)

快乐的重新映射