⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bilinear_interpolation_shrink.m

📁 MATLAB双线性插值法对图像进行放大和缩小
💻 M
字号:
function Bilinear_Interpolation_Shrink
f1024=imread('1024.jpg');
[imagewidth,imageheight]=size(f1024);
width=256;
height=256;
f256=uint8(zeros(width,height));
wscale=imagewidth/width;
hscale=imageheight/height;

for i=1:width   
for j=1:height      
x=i*wscale;      
y=j*hscale;

if(x==floor(x)) & (y==floor(y)) 
f256(i,j)=f1024(int16(x),int16(y)); 
       
else 
if(floor(x)==0) | (floor(y)==0) 
f256(i,j)=f1024(1,1);

else 
x11=double(f1024(floor(x),floor(y)));      
x12=double(f1024(floor(x),ceil(y)));      
x21=double(f1024(ceil(x),floor(y)));      
x22=double(f1024(ceil(x),ceil(y)));            
Wx1=1-(x-floor(x));      
Wx2=x-floor(x);      
Wy1=1-(y-floor(y));      
Wy2=y-floor(y);            

f256(i,j)=[Wx1 Wx2]*[x11 x12;x21 x22]*[Wy1;Wy2];  
end
end
end
end

figure('Name','The 1024 x 1024 picture','NumberTitle','off'),imshow(f1024)
figure('Name','The 256 x 256 picture','NumberTitle','off'),imshow(f256)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -