?? wavelet_denoise.m
字號:
function varargout = Wavelet_Denoise(varargin)% WAVELET_DENOISE Application M-file for Wavelet_Denoise.fig% FIG = WAVELET_DENOISE launch Wavelet_Denoise GUI.% WAVELET_DENOISE('callback_name', ...) invoke the named callback.% Last Modified by GUIDE v2.0 11-Nov-2004 09:30:52if nargin == 0 % LAUNCH GUI fig = openfig(mfilename,'reuse'); % Generate a structure of handles to pass to callbacks, and store it. handles = guihandles(fig); guidata(fig, handles); if nargout > 0 varargout{1} = fig; endelseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK try if (nargout) [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard else feval(varargin{:}); % FEVAL switchyard end catch disp(lasterr); endend%| ABOUT CALLBACKS:%| GUIDE automatically appends subfunction prototypes to this file, and %| sets objects' callback properties to call them through the FEVAL %| switchyard above. This comment describes that mechanism.%|%| Each callback subfunction declaration has the following form:%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)%|%| The subfunction name is composed using the object's Tag and the %| callback type separated by '_', e.g. 'slider2_Callback',%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.%|%| H is the callback object's handle (obtained using GCBO).%|%| EVENTDATA is empty, but reserved for future use.%|%| HANDLES is a structure containing handles of components in GUI using%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This%| structure is created at GUI startup using GUIHANDLES and stored in%| the figure's application data using GUIDATA. A copy of the structure%| is passed to each callback. You can store additional information in%| this structure at GUI startup, and you can change the structure%| during callbacks. Call guidata(h, handles) after changing your%| copy to replace the stored original so that subsequent callbacks see%| the updates. Type "help guihandles" and "help guidata" for more%| information.%|%| VARARGIN contains any extra arguments you have passed to the%| callback. Specify the extra arguments by editing the callback%| property in the inspector. By default, GUIDE sets the property to:%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))%| Add any extra arguments after the last argument, before the final%| closing parenthesis.% --------------------------------------------------------------------function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)[filename, pathname] = uigetfile( ... {'*.wav', 'All wav-Files (*.wav)'; ... '*.*','All Files (*.*)'}, ... 'Select Wave File');% If "Cancel" is selected then returnFile = fullfile(pathname,filename);[x1 fs nbits]=wavread(File);x2=x1(1:65536);axes(handles.axes1)plot(x2);set(handles.axes1,'XMinorTick','on')grid onhandles.X1=x2;guidata(h, handles);handles.X2=fs;guidata(h, handles);set(handles.edit1,'String',File)uiwait(msgbox('File Loaded','File Loaded','modal'));% --------------------------------------------------------------------function varargout = Denoise_Callback(h, eventdata, handles, varargin)f1 = get(handles.edit1,'String')x=findstr(f1,'\')if x==[][s,N] = makesig(f1);n = randn(1,N);f2 = str2double(get(handles.edit4,'String'));if f2==2h = 2; elseif f2==4h = 4; elseif f2==6;h = 6; elseif f2==8;h = 8 ; elseif f2==10;h = 10; elseh = 2; end x = s + n/h; f2 = str2double(get(handles.edit3,'String'))if f2==4h = daubcqf(4); elseif f2==6h = daubcqf(6); elseif f2==8;h = daubcqf(8); elseif f2==10;h = daubcqf(10); elseh = daubcqf(4); endf1 = str2double(get(handles.edit2,'String'))if f1==1[yd,yn,opt2] = denoise(x,h);elseif f1==2 [yd,yn,opt2] = denoise(x,h,1);else[yd,yn,opt2] = denoise(x,h);endaxes(handles.axes4)plot(x);hold on;plot(yd,'r');hold off;legend('Noisy Signal','Filter Signal')set(handles.axes4,'XMinorTick','on')grid onuiwait(msgbox('Denoising Done','Denoising','modal'));elseFile=get(handles.edit1,'String'); x1=wavread(File);x2=x1(1:65536);f2 = str2double(get(handles.edit3,'String'))if f2==4h = daubcqf(4); elseif f2==6h = daubcqf(6); elseif f2==8;h = daubcqf(8); elseif f2==10;h = daubcqf(10); elseh = daubcqf(4); endf1 = str2double(get(handles.edit2,'String'))if f1==1[yd,yn,opt2] = denoise(x2,h);elseif f1==2 [yd,yn,opt2] = denoise(x2,h,1);else[yd,yn,opt2] = denoise(x2,h);endaxes(handles.axes4)plot(yd)set(handles.axes4,'XMinorTick','on')grid onuiwait(msgbox('Denoising Done','Denoising','modal'));end% --------------------------------------------------------------------function varargout = File_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Close_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Calculate_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Untitled_6_Callback(h, eventdata, handles, varargin)File=get(handles.edit1,'String'); x1=wavread(File);x2=x1(1:65536);h = daubcqf(6); [yd,yn,opt2] = denoise(x2,h,1);axes(handles.axes2)plot(yd);set(handles.axes2,'XMinorTick','on')grid onuiwait(msgbox('Denoising Done','Denoising','modal'));% --------------------------------------------------------------------function varargout = Help_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Untitled_8_Callback(h, eventdata, handles, varargin)[data map]=imread('sheraz.bmp');uiwait(msgbox('This Software is developed by Sheraz Khan','About Developer','custom',data,map));% --------------------------------------------------------------------function varargout = LoadFile_Callback(h, eventdata, handles, varargin)function varargout = Open_Callback(h, eventdata, handles, varargin)% Use UIGETFILE to allow for the selection of a custom address book.[filename, pathname] = uigetfile( ... {'*.wav', 'All wav-Files (*.wav)'; ... '*.*','All Files (*.*)'}, ... 'Select Address Book');% If "Cancel" is selected then return File = fullfile(pathname,filename);x1=wavread('File');x2=x1(1:65536); h = daubcqf(6); [yd,yn,opt2] = denoise(x2,h,1,[]);axes(handles.axes1)plot(x2);hold on;plot(yd,'r');set(handles.axes1,'XMinorTick','on')grid on% --------------------------------------------------------------------function varargout = edit1_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = popupmenu1_Callback(h, eventdata, handles, varargin)val = get(h,'Value');switch valcase 1set(handles.edit2,'String','1')case 2set(handles.edit2,'String','2')end% --------------------------------------------------------------------function varargout = popupmenu2_Callback(h, eventdata, handles, varargin)val = get(h,'Value');switch valcase 1set(handles.edit3,'String','4')case 2set(handles.edit3,'String','6')case 3set(handles.edit3,'String','8')case 4set(handles.edit3,'String','10')end% --------------------------------------------------------------------function varargout = edit2_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = edit3_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------% --------------------------------------------------------------------function varargout = popupmenu3_Callback(h, eventdata, handles, varargin)val = get(h,'Value');switch valcase 1set(handles.pushbutton4,'Enable','on')set(handles.text10,'Visible','off')set(handles.popupmenu4,'Visible','off')set(handles.text11,'Visible','off')set(handles.popupmenu5,'Visible','off')set(handles.radiobutton3,'Visible','on')set(handles.radiobutton4,'Visible','on')set(handles.frame2,'Visible','on')set(handles.text12,'Visible','on')case 2set(handles.pushbutton4,'Enable','off')set(handles.radiobutton3,'Visible','off')set(handles.radiobutton4,'Visible','off')set(handles.frame2,'Visible','off')set(handles.text12,'Visible','off')set(handles.text10,'Visible','on')set(handles.popupmenu4,'Visible','on')set(handles.text11,'Visible','on')set(handles.popupmenu5,'Visible','on')end% --------------------------------------------------------------------function varargout = popupmenu4_Callback(h, eventdata, handles, varargin)val = get(h,'Value');switch valcase 1set(handles.edit1,'String','Bumps')signal= 'Bumps';case 2set(handles.edit1,'String','Blocks')signal= 'Blocks';case 3set(handles.edit1,'String','Doppler')signal= 'Doppler';case 4set(handles.edit1,'String','Ramp')signal= 'Ramp';case 5set(handles.edit1,'String','Cusp')signal= 'Cusp';case 6set(handles.edit1,'String','Sing')signal= 'Sing';case 7set(handles.edit1,'String','HiSine')signal= 'HiSine';case 8set(handles.edit1,'String','LoSine')signal= 'LoSine';case 9set(handles.edit1,'String','LinChirp')signal= 'LinChirp';case 10set(handles.edit1,'String','TwoChirp')signal= 'TwoChirp';case 11set(handles.edit1,'String','QuadChirp')signal= 'QuadChirp';case 12set(handles.edit1,'String','MishMash')signal= 'MishMash';case 13set(handles.edit1,'String','Werner Sorrows')signal= 'Werner Sorrows';case 14set(handles.edit1,'String','Leopold')signal= 'Leopold';case 15set(handles.edit1,'String','HeaviSine')signal= 'HeaviSine';endf2 = str2double(get(handles.edit4,'String'));if f2==2h = 2; elseif f2==4h = 4; elseif f2==6;h = 6; elseif f2==8;h = 8 ; elseif f2==10;h = 10; elseh = 2; end [s,N] = makesig(signal); n = randn(1,N);x = s + n/h; axes(handles.axes1)plot(x);hold on;plot(s,'r');hold off;legend('Noisy Signal','Pure Signal')set(handles.axes1,'XMinorTick','on')grid on% --------------------------------------------------------------------function varargout = popupmenu5_Callback(h, eventdata, handles, varargin)val = get(h,'Value');switch valcase 1set(handles.edit4,'String','2')case 2set(handles.edit4,'String','4')case 3set(handles.edit4,'String','6')case 4set(handles.edit4,'String','8')case 5set(handles.edit4,'String','10')end% --------------------------------------------------------------------function varargout = edit4_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = edit5_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = radiobutton3_Callback(h, eventdata, handles, varargin)set(handles.radiobutton4,'Value',0)set(handles.axes1,'Visible','on')set(handles.axes7,'Visible','off')x2=handles.X1;fs=handles.X2axes(handles.axes1)plot(x2);set(handles.axes1,'XMinorTick','on')grid on% --------------------------------------------------------------------function varargout = radiobutton4_Callback(h, eventdata, handles, varargin)set(handles.radiobutton3,'Value',0)set(handles.axes1,'Visible','off')set(handles.axes7,'Visible','on')x2=handles.X1;fs=handles.X2fft1=fft(x2,65536);w=(0:32767)/32768*(fs/2);axes(handles.axes7)plot(w,abs(fft1(1:32768)));set(handles.axes7,'XMinorTick','on')grid on% --------------------------------------------------------------------function varargout = Signal_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Length_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Untitled_12_Callback(h, eventdata, handles, varargin)% --------------------------------------------------------------------function varargout = Type_Callback(h, eventdata, handles, varargin)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -