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

📄 yxfft.m

📁 自己手写的图像的FFT变换和DCT变换的MATLAB代码
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%   二维的Lena图像的傅立叶变换,并显示出变换后的Lena图像     %%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y1=YXFFT(f,wideth,height)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%       显示初始的图像   %%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  y=zeros(wideth,height);
    q=zeros(wideth,height);
    for i=1:wideth
        for j=1:height
            y(i,j)=f(i,j);
        end;
    end;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %%%%%%%%%  进行行的傅立叶变换  %%%%%%%%%%%%%%%
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    temp=zeros(1,height);
    for i=1:wideth
        for j=1:height
            temp(j)=y(i,j);            
        end;
        temp=Y1FFT(temp,height);
        for j=1:height
            y(i,j)=temp(j);
        end;
    end;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %%%%%%%%%  进行列的傅立叶变换  %%%%%%%%%%%%%%%
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    temp=zeros(1,height);
    for j=1:height
        for i=1:wideth
            temp(i)=y(i,j);            
        end;
        temp=Y1FFT(temp,wideth);
        for i=1:wideth
            y(i,j)=temp(i);
        end;
    end;
% % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % 

%%%%%%%%%%%%%%%%%%            将进行完傅立叶变换后的数值求其模,进行实数的转换       %%%%%%%%%%%%%%%%%%%%%%%

% % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % % % % %% % % % 
 [wideth,height]=size(f);
for i=1:1:wideth
    for j=1:1:height
        q(i,j)=abs((sqrt(real(y(i,j))*real(y(i,j))+imag(y(i,j))*imag(y(i,j))))/100);
        if q(i,j)>512
            q(i,j)=512;
        end;
    end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%        调整图像的显示的中心    %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:1:wideth
    for j=1:1:height
       if(i>wideth/2)
            i1=i-wideth/2;
        else 
            i1=i+wideth/2;
       end;
        if(j>height/2)
             j1=j-height/2;
        else
             j1=j+height/2;
        end;
         y1(i1,j1)=uint8(q(i,j)); %%%%%取整操作
    end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%       显示变换后的傅立叶的图像   %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% figure,imshow(y1);
% title '傅立叶变换后的Lena图像';
end


⌨️ 快捷键说明

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