📄 chonggou.m
字号:
function varargout = chonggou(varargin)
% CHONGGOU M-file for chonggou.fig
% CHONGGOU, by itself, creates a new CHONGGOU or raises the existing
% singleton*.
%
% H = CHONGGOU returns the handle to a new CHONGGOU or the handle to
% the existing singleton*.
%
% CHONGGOU('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CHONGGOU.M with the given input arguments.
%
% CHONGGOU('Property','Value',...) creates a new CHONGGOU or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before chonggou_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to chonggou_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help chonggou
% Last Modified by GUIDE v2.5 04-Jun-2002 11:05:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @chonggou_OpeningFcn, ...
'gui_OutputFcn', @chonggou_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 chonggou is made visible.
function chonggou_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 chonggou (see VARARGIN)
% Choose default command line output for chonggou
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes chonggou wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = chonggou_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 edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji3.jpg');
X=rgb2gray(kk);
X=double(X);
sX=size(X);
[cA1,cH1,cV1,cD1]=dwt2(X,'db4');
A0=idwt2(cA1,cH1,cV1,cD1,'db4',sX);
ans=max(max(abs(X-A0)))
figure(1);
subplot(121);
imshow(X,[]);
title('原始图像');
subplot(122);
imshow(A0,[]);
title('重构图像');
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open danch
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji1.jpg');
X=rgb2gray(kk);
X=double(X);
[c,s]=wavedec2(X,2,'sym5');
a1=wrcoef2('a',c,s,'sym5',1);
a2=wrcoef2('a',c,s,'sym5',2);
hd2=wrcoef2('h',c,s,'sym5',2);
vd2=wrcoef2('v',c,s,'sym5',2);
dd2=wrcoef2('d',c,s,'sym5',2);
sX=size(X)
sa1=size(a1)
shd2=size(hd2)
figure(2);
subplot(3,2,1);
imshow(X,[]);
title('原始图像');
subplot(3,2,2);
imshow(a1,[]);
title('尺度1的低频图像');
subplot(3,2,3);
imshow(a2,[]);
title('尺度2的低频图像');
subplot(3,2,4);
imshow(hd2,[]);
title('尺度2的水平高频图像');
subplot(3,2,5);
imshow(vd2,[]);
title('尺度2的垂直高频图像');
subplot(3,2,6);
imshow(dd2,[]);
title('尺度2的斜线高频图像');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open duoch
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji4.jpg');
X=rgb2gray(kk);
X=double(X);
[c,s]=wavedec2(X,2,'db4');
siz=s(size(s,1),:);
ca1=appcoef2(c,s,'db4',1);
a1=upcoef2('a',ca1,'db4',1,siz);
chd1=detcoef2('h',c,s,1);
hd1=upcoef2('h',chd1,'db4',1,siz);
cvd1=detcoef2('v',c,s,1);
vd1=upcoef2('v',cvd1,'db4',1,siz);
cdd1=detcoef2('d',c,s,1);
dd1=upcoef2('d',cdd1,'db4',1,siz);
figure(3);
subplot(321);
imshow(X,[]);
title('原始图像');
subplot(323);
imshow(a1,[]);
title('尺度1的低频系数重构图像');
subplot(324);
imshow(hd1,[]);
title('尺度1的水平高频系数重构图像');
subplot(325);
imshow(vd1,[]);
title('尺度1的垂直高频系数重构图像');
subplot(326);
imshow(dd1,[]);
title('尺度1的斜线高频系数重构图像');
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open xscg
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji4.jpg');
X=rgb2gray(kk);
X=double(X);
[c,s]=wavedec2(X,2,'sym4');
a0=waverec2(c,s,'sym4');
ans=max(max(abs(X-a0)))
figure(4);
subplot(121);
imshow(X,[]);
title('原始图像');
subplot(122);
imshow(a0,[]);
title('重构图像');
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open dfg
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji1.jpg');
X=rgb2gray(kk);
X=double(X);
[c,s]=wavedec2(X,2,'db1');
sc=size(c)
val_s=s
[nc,ns]=upwlev2(c,s,'db1');
snc=size(nc)
val_ns=ns
cal=appcoef2(nc,ns,'db1',1);
figure(5);
subplot(121);
imshow(X,[]);
title('原始图像');
subplot(122);
imshow(cal,[]);
title('尺度1的小波分解低频系数');
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open dcdcg
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
kk=imread('ziji1.jpg');
X=rgb2gray(kk);
X=double(X);
t=wpdec2(X,2,'db2');
rex=wprec2(t)
figure(6);
subplot(211);
imshow(X,[]);
title('原始信号');
subplot(212);
imshow(rex,[]);
title('重构后的信号');
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open tree
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -