Is it similar to the cv::remap reprojection mapping function in opencv in matlab?
10 次查看(过去 30 天)
显示 更早的评论
As far as I know, I know interp2,interp,griddata,scatteredInterpolant and other functions can achieve my non-aligned regular grid data for mapping, but the efficiency is very low, on the contrary, the remap function in opencv is very fast and only does mapping projection. For example, I have the following non-gridded data points, known v = F(x,y), where x,y are non-regular data, I try to use scatteredInterpolant function for interpolation, but the computation time is up to several seconds.
My (x,y) coordinates data is in the following form:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043980/image.jpeg)
load data.mat
validPtsX = double(validPtsX);
validPtsY = double(validPtsY);
[qX,qY] = meshgrid(1:W,1:H);
F = scatteredInterpolant(validPtsX(:),validPtsY(:),oriImg(:));
tic
undistortImg1 = F(qX,qY); % took too long !
toc
undistortImg2 = interp2(validPtsX,validPtsY,oriImg,qX,qY,"linear",0);% error: Grid arrays must have NDGRID structure.
However, I can quickly get my interpolated mapped image in OpenCV by using the following statement:
cv::Mat undistortImg;
cv::remap(oriImg, undistortImg, mapX, mapY, cv::INTER_LINEAR); // Supports both grid and non-grid data mapping
update:
It is verified that the interp2 function has equivalent mapping power and execution speed to the cv::remap function when the mapping matrix mapX,mapY (or called queryX,queryY) is computed in advance!
undistortImg = interp2(img,mapX,mapY,"linear",0);% 等价OpenCV的cv::remap函数,速度在各自环境下等价一致!
1 个评论
Walter Roberson
2022-6-24
https://www.mathworks.com/discovery/matlab-opencv.html allows calling into OpenCV .
采纳的回答
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!