資源簡介
該代碼實現了以2為因子的圖像升采樣和降采樣功能。
降采樣包括使用平滑濾波器(with using the averaging filter)和不使用平滑濾波器(without using the averaging filter)兩種方法。
升采樣包括像素點直接復制(pixel replication method)和線性插值(bilinear interpolatoin method)兩種方法。
降采樣方法和升采樣方法共有4種組合。程序運行后,給出了一個原始圖片和四個結果圖片。
圖片1.原始圖片。
圖片2.平滑濾波器降采樣&像素點直接復制升采樣。
代碼片段和文件信息
%Function:Down?and?Up?Sampling?by?Factor?2
%Input:yourimage.jpg
%Output:?Four?Images
%????????Figure1.Up:pixel?replication?&?Down:without?using?the?averaging?filter
%????????Figure2.Up:pixel?replication?&?Down:with?using?the?averaging?filter
%????????Figure3.Up:bilinear?interpolation?&?Down:without?using?the?averaging?filter
%????????Figure4.Up:bilinear?interpolation?&?Down:with?using?the?averaging?filter
clc;clear?all;close?all;
%%%%%%%%%%%%%%%%
%%%??Imread??%%%
%%%%%%%%%%%%%%%%
I0=imread(‘yourimage.jpg‘);
I=rgb2gray(I0);
imshow(I[]);title(‘Original?Image‘);
I=double(I);
[height?width]=size(I);
hheight=height/2;hwidth=width/2;
dI1=zeros(hheighthwidth);dI2=zeros(hheighthwidth);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%??Down?Sample?by?a?Factor?2??%%%
%%%%%%%%%%%%
- 上一篇:基于MATLAB的擴頻通信系統仿真
- 下一篇:自適應控制算法
評論
共有 條評論