function varargout = yangrui(varargin)
% YANGRUI MATLAB code for yangrui.fig
% YANGRUI, by itself, creates a new YANGRUI or raises the existing
% singleton*.
%
% H = YANGRUI returns the handle to a new YANGRUI or the handle to
% the existing singleton*.
%
% YANGRUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in YANGRUI.M with the given input arguments.
%
% YANGRUI('Property','Value',...) creates a new YANGRUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before yangrui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to yangrui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help yangrui
% Last Modified by GUIDE v2.5 17-Jun-2015 17:56:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @yangrui_OpeningFcn, ...
'gui_OutputFcn', @yangrui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before yangrui is made visible.
function yangrui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to yangrui (see VARARGIN)
% Choose default command line output for yangrui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes yangrui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = yangrui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function information_Callback(hObject, eventdata, handles)
% hObject handle to information (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function tuxiangzengqiang_Callback(hObject, eventdata, handles)
% hObject handle to tuxiangzengqiang (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function tuxiangfenge_Callback(hObject, eventdata, handles)
% hObject handle to tuxiangfenge (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function tuxiangbianhuan_Callback(hObject, eventdata, handles)
% hObject handle to tuxiangbianhuan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function ft_Callback(hObject, eventdata, handles)
A=handles.img;
subplot(1,2,1),imshow(A);title('原图像');
colorbar;
B=fftshift(fft2(A));
subplot(1,2,2),imshow(log(abs(B)),[ ]);title('二维傅立叶变换');
colorbar;
% hObject handle to ft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function ift_Callback(hObject, eventdata, handles)
A=handles.img;
subplot(2,2,1),imshow(A);title('原图像');
colorbar;
B=fftshift(fft2(A));
subplot(2,2,2),imshow(log(abs(B)),[ ]);title('二维傅立叶变换');
colorbar;
C=ifft2(B);
subplot(2,2,3),imshow(log(abs(C)),[ ]);title('逆变换后图像');
colorbar;
% hObject handle to ift (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function fft_Callback(hObject, eventdata, handles)
i=handles.img;
subplot(121);%设定窗口
imshow(i);%显示原图像
colorbar;%显示图像的颜色条
title('原图像')%图像命名
j=fft2(i);%二维离散傅立叶变换
k=fftshift(j);%直流分量移到频谱中心
l=log(1+abs(k));%数字图像的对数变换
subplot(122);%设定窗口
imshow(l,[]);%显示原图像
colorbar;%显示图像的颜色条
title('经过二维快速傅立叶变换后的图像')%图像命名
% hObject handle to fft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function ifft_Callback(hObject, eventdata, handles)
i=handles.img;
j=fft2(i);%二维离散傅立叶变换
n=ifft2(j)/255;%逆二维快速傅里叶变换
subplot(121);%设定窗口
imshow(n);%显示原图像
colorbar;%显示图像的颜色条
title('经过二维快速傅立叶逆变换后的图像')%图像命名
m=fftshift(j);%直流分量移到频谱中心
RR=real(m);%取傅立叶变换的实部
II=imag(m);%取傅立叶变换的虚部
A=sqrt(RR.^2+II.^2);%计算频谱幅值
A=(A-min(min(A)))/(max(max(A))-min(min(A)))*225;%归一化
subplot(122);%设定窗口
imshow(A);%显示原图像
colorbar;%显示图像的颜色条
title('离散傅立叶频谱');%图像命名
% hObject handle to ifft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function dct_Callback(hObject, eventdata, handles)
% hObject handle to dct (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global caise;
axes(handles.axes1);
J=rgb2gray(caise);
imshow(J);
title('灰度图为')
axes(handles.axes2);
s = dct2(J);
imshow(log(abs(s)),[]);
title('离散余弦变换后')
% --------------------------------------------------------------------
function xiaobo_Callback(hObject, eventdata, handles)
% hObject handle to xiaobo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global caise;
axes(handles.axes1);
J=rgb2gray(caise);
imshow(J);
title('灰度图为')
axes(handles.axes2);
[m,n] = wavedec2(J,2,'bior3.7');%采用bior3.7小波对图像进行2层小波分解
F1 = appcoef2(m,n,'bior3.7',1);%提取二维小波分解的一层变换
[cA,cH,cV,cD] = dwt2(J,'db1');%根据I进行小波分析并计算低频系数矩阵cA和高频系数矩阵cH(水平方向)?%和cV(垂直方向)、cD(对角方向)
imshow(F1);
title('小波变换结果');%显示一层小波变换结果
% ------------------------------------------------------------------