4
我必須從低分辨率圖像獲取高分辨率圖像。這可以使用插值方法來實現。我知道在matlab imresize
和interp2
函數將執行任務,但我必須編寫代碼,而不使用任何內置函數。我理解雙線性插值如何工作,但我似乎無法將它拼湊在我的代碼中。我會很感激任何幫助和建議。如何使用Matlab執行雙線性插值
這是到目前爲止我的代碼:
clear all; close all; clc;
input_im=imread('superman.png');
im=rgb2gray(input_im);
%subplot(1,2,1), imshow(input_im), title('Original Image');
%subplot(1,2,2), imshow(im), title('Gray Scale Input Image');
[m,n]=size(im); %obtain the size of gray scale image
S = input(' Now Enter Value : ');
Scale1 = floor(S);
Scale2 = floor(S);
scale = [Scale1, Scale2];
Oim=size(im);
Nim=max(floor(scale.*Oim(1:1)),1);
for i=1:Nim-1
for j=1:Nim-1
Q11=
Q21=
Q12=
Q22=
R1=((x2-x)/(x2-x1))*Q11+((x-x1)/(x2-x1))*Q21;
R2=((x2-x)/(x2-x1))*Q12+((x-x1)/(x2-x1))*Q22;
P=((y2-y)/(y2-y1))*R1+((y-y1)/(y2-y1))*R2;
end
end
最好不要在matlab中使用'i'和'j'作爲變量名稱(http://stackoverflow.com/questions/14790740/using-i-and-j-as-variables-in- MATLAB) – Shai 2013-05-16 07:31:12