What is the best method to use for interpolating RGB true colour images?

14 visualizzazioni (ultimi 30 giorni)
What is the best method to use for interpolating RGB true colour images? It seems that I am not using the following 4 methods very well, the first and the fourth are actually the same, and the second interp2 cannot interpolate the R,G,B channels at the same time? The third method only supports ndgrid grid points and cannot interpolate images?
%% test performance speed
load param.mat % required params
numTimes = 1000; % test times
%% method1
t1 = tic;
for i = 1:numTimes
dstImg = imwarp(src,tform,OutputView=outputView);
end
T1 = toc(t1)
T1 = 5.2366
imshow(dstImg)
%% method2
t1 = tic;
for i = 1:numTimes
birdsEyeImgR = interp2(src(:,:,1),mapX,mapY,"linear",0);
% birdsEyeImgG = interp2(src(:,:,2),mapX,mapY,"linear",0);
% birdsEyeImgB = interp2(src(:,:,3),mapX,mapY,"linear",0);
% birdsEyeImg = cat(3,birdsEyeImgR,birdsEyeImgG,birdsEyeImgB);
end
T2 = toc(t1)
T2 = 5.6969
imshow(birdsEyeImgR)
%% method3, not is my expected result image
t1 = tic;
[X,Y] = ndgrid(1:size(src,1),1:size(src,2));
F = griddedInterpolant(X,Y,src,'linear','nearest');
for i = 1:numTimes
birdsEyeImgF = F(mapX,mapY);
end
T3 = toc(t1)
T3 = 9.9702
imshow(birdsEyeImgF)
%% method4
t1 = tic;
for i = 1:numTimes
BEV = transformImage(birdsEye,src);
end
T4 = toc(t1)
T4 = 5.5785
imshow(BEV)
Any recommendations for a more efficient method? your answer would be greatly appreciate!

Risposta accettata

cui,xingxing
cui,xingxing il 14 Ott 2022
Modificato: cui,xingxing il 14 Ott 2022
High interpolation efficiency by looking at the internal implementation.
%% test performance speed
load param.mat % required params
numTimes = 1000; % test times
%% internal method
t1 = tic;
for i = 1:numTimes
dstImg = images.internal.interp2d(src,mapX,mapY,...
"linear",0, false);
end
elasedTime = toc(t1)
elasedTime = 0.3328
imshow(dstImg)

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by