1
給定兩個將源圖像中的每個像素映射到目標圖像中的像素(R2到R2)的cv :: Mat矩陣,我想將源圖像變換爲目標圖像。我sucessfuly這樣做使用循環,但實在是太慢了:使用變換貼圖的OpenCV2變換圖像
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;
}
}
這個基本的代碼工作,但速度很慢(我的圖片比100×100大,我必須使用雙三次)。 謝謝,
-O-