Is it similar to the cv::remap reprojection mapping function in opencv in matlab?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
cui,xingxing
am 24 Jun. 2022
Beantwortet: cui,xingxing
am 14 Okt. 2022
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:
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 Kommentar
Walter Roberson
am 24 Jun. 2022
https://www.mathworks.com/discovery/matlab-opencv.html allows calling into OpenCV .
Akzeptierte Antwort
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!