MATLAB interp3 幀間插值

如題,MATLAB裏面有interp1,interp2和interp3等等插值方法

也有‘linear’:線性插值(缺省算法); ‘cubic’:三次插值; ‘spline’:三次樣條插值;‘ nearest’:最鄰近插值。等插值選擇

但如何用兩張圖像去插中間一張呢,或者用四張去插中間的一張呢

我們選擇用interp3

input_path = './cremi/';
out_path = './cremi/0005_interp.png';
temp = zeros(1761,1680,4, 'uint8');

temp(:,:,1) = imread([input_path, num2str(3, '%04d'), '.png']);
temp(:,:,2) = imread([input_path, num2str(4, '%04d'), '.png']);
temp(:,:,3) = imread([input_path, num2str(6, '%04d'), '.png']);
temp(:,:,4) = imread([input_path, num2str(7, '%04d'), '.png']);

temp = double(temp);
[x,y,z] = size(temp);
[hx,hy,hz] = meshgrid(1:y, 1:x, 2:1/2:3);
hr = interp3(temp, hx, hy, hz, 'cubic');
imwrite(uint8(hr(:,:,2)), out_path)

注意:

cubic插值至少需要三張圖像

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章