主题:线性插值
I=zeros(2*row-1,2*col-1);
%I(2*i-1,2*j-1)=J(i,j)
for i=1:row
for j=1:col
I(2*i-1,2*j-1)=J(i,j);
end
end
%处理边缘
for j=1:col
if j>1
if j<col
I(1,2*j)=(J(1,j-1)+J(1,j+1))/2;
I(2*row-1,2*j)=(J(row,j-1)+J(row,j+1))/2;
end
end
end
for i=1:row
if i>1
if i<row
I(2*i,1)=(J(i-1,1)+J(i+1,1))/2;
I(2*i,2*col-1)=(J(i-1,col)+J(i+1,col))/2;
end
end
end
%I(2*i,2*j)=(J(i,j)+J(i+1,j)+J(i,j+1)+J(i+1,j+1))/4;
for i=1:row-1
for j=1:col-1
I(2*i,2*j)=(J(i,j)+J(i+1,j)+J(i,j+1)+J(i+1,j+1))/4;
end
end
% I(2*i-1,2*j)=(I(2*i-1,2*j-1)+I(2*i-1,2*j+1)+I(2*i-2,2*j)+I(2*i,2*j))/4;
for i=2:row-1
for j=1:col-1
I(2*i-1,2*j)=(I(2*i-1,2*j-1)+I(2*i-1,2*j+1)+I(2*i-2,2*j)+I(2*i,2*j))/4;
end
end
% I(2*i,2*j-1)=(I(2*i-1,2*j-1)+I(2*i+1,2*j-1)+I(2*i,2*j-2)+I(2*i,2*j))/4;
for i=1:row-1
for j=2:col-1
I(2*i,2*j-1)=(I(2*i-1,2*j-1)+I(2*i+1,2*j-1)+I(2*i,2*j-2)+I(2*i,2*j))/4;
end
end
%for i=2:2*row-2
% for j=2:2*col-2
% I(i,j)=I(i-1,j)/4+I(i,j-1)/4+I(i+1,j)/4+I(i,j+1)/4;
% end
%end
为什么这个程序实现之后,图像不是平滑的呢?一定要加上最后一个循环才可以?
那位可以帮帮忙呀
%I(2*i-1,2*j-1)=J(i,j)
for i=1:row
for j=1:col
I(2*i-1,2*j-1)=J(i,j);
end
end
%处理边缘
for j=1:col
if j>1
if j<col
I(1,2*j)=(J(1,j-1)+J(1,j+1))/2;
I(2*row-1,2*j)=(J(row,j-1)+J(row,j+1))/2;
end
end
end
for i=1:row
if i>1
if i<row
I(2*i,1)=(J(i-1,1)+J(i+1,1))/2;
I(2*i,2*col-1)=(J(i-1,col)+J(i+1,col))/2;
end
end
end
%I(2*i,2*j)=(J(i,j)+J(i+1,j)+J(i,j+1)+J(i+1,j+1))/4;
for i=1:row-1
for j=1:col-1
I(2*i,2*j)=(J(i,j)+J(i+1,j)+J(i,j+1)+J(i+1,j+1))/4;
end
end
% I(2*i-1,2*j)=(I(2*i-1,2*j-1)+I(2*i-1,2*j+1)+I(2*i-2,2*j)+I(2*i,2*j))/4;
for i=2:row-1
for j=1:col-1
I(2*i-1,2*j)=(I(2*i-1,2*j-1)+I(2*i-1,2*j+1)+I(2*i-2,2*j)+I(2*i,2*j))/4;
end
end
% I(2*i,2*j-1)=(I(2*i-1,2*j-1)+I(2*i+1,2*j-1)+I(2*i,2*j-2)+I(2*i,2*j))/4;
for i=1:row-1
for j=2:col-1
I(2*i,2*j-1)=(I(2*i-1,2*j-1)+I(2*i+1,2*j-1)+I(2*i,2*j-2)+I(2*i,2*j))/4;
end
end
%for i=2:2*row-2
% for j=2:2*col-2
% I(i,j)=I(i-1,j)/4+I(i,j-1)/4+I(i+1,j)/4+I(i,j+1)/4;
% end
%end
为什么这个程序实现之后,图像不是平滑的呢?一定要加上最后一个循环才可以?
那位可以帮帮忙呀