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

17 ビュー (過去 30 日間)
cui,xingxing
cui,xingxing 2022 年 9 月 21 日
コメント済み: cui,xingxing 2022 年 10 月 14 日
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!

採用された回答

cui,xingxing
cui,xingxing 2022 年 10 月 14 日
編集済み: cui,xingxing 2022 年 10 月 14 日
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)
  1 件のコメント
cui,xingxing
cui,xingxing 2022 年 10 月 14 日
Provided that the interpolated coordinate points are known

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by