小波变换原理
小波变换是一种信号的时间一尺度(时间一频率)分析方法,一种窗口大小固定不变形状可改变,时间窗和频率窗都可以改变的时频局部化分析方法。它具有多分辨率分析( Multi-resolution Analysis)的特点,且在时频两域都具有表征信号局部特征的能力。
小波分析方法在低频部分具有较高的频率分辨率和较低的时间分辨率,在高频部分具有较高的时间分辦率和较低的频率分辦率,所以被誉为“数学显微镜”。正是这种特性,使小波变换具有对信号的自适应性。
小波分析被看成调和分析这一数学领域半个世纪以来的工作结晶,已经广泛地应用于信号处理、图像处理、量子场论、地震勘探、语音识别与合成、音乐、雷达、CT成像、彩色复印、流体湍流、天体识别、机器视觉、机械故障诊断与监控、分形以及数字电视等科技领域。
原则上讲,传统上使用傅里叶分析的地方,都可以用小波分析取代。小波分析优于傅里叶变换的地方是在时域和频域同时具有良好的局部化性质。
这样小波变換对不同的频率在时域上的取样步长是调节性的:在低频时,小波变换的时间分辨率较低,而频率分辦率较高;在高频时,小波变换的时间分辨率较高,而類率分辨率较低。这正符合低频信号变化缓慢而高频信号变化迅速的特点。
这便是它优于经典傅里叶变换与短时傅里叶变换的地方。
function varargout = DSP_mark(varargin) % DSP_MARK MATLAB code for DSP_mark.fig % DSP_MARK, by itself, creates a new DSP_MARK or raises the existing % singleton*. % % H = DSP_MARK returns the handle to a new DSP_MARK or the handle to % the existing singleton*. % % DSP_MARK('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in DSP_MARK.M with the given input arguments. % % DSP_MARK('Property','Value',...) creates a new DSP_MARK or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before DSP_mark_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to DSP_mark_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 DSP_mark % Last Modified by GUIDE v2.5 09-Jan-2021 18:54:43 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @DSP_mark_OpeningFcn, ... 'gui_OutputFcn', @DSP_mark_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 DSP_mark is made visible. function DSP_mark_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 DSP_mark (see VARARGIN) % Choose default command line output for DSP_mark handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes DSP_mark wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = DSP_mark_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; % --- 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 GUIDA %--------------------------读取原始音频-------------------------% cla reset; Fs=44100; FILE1='Rihanna - Take A Bow.wav'; [y,Fs]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits y_fft=fft(y,Fs); % y_fft_f=2*sqrt(y_fft.*conj(y_fft)); axes(handles.axes1); plot(y); grid on;axis tight; title('原始音频信号的时域波形'); xlabel('time(s)');ylabel('幅度'); axes(handles.axes2); plot(abs(y_fft)); grid on;axis tight; title('原始音频信号的频域波形'); xlabel('f(Hz)');ylabel('幅度'); sound(y,Fs);%播放原始语音 % --- 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) %--------------------------读取水印音频-------------------------% cla reset; Fs=44100; FILE1='Rihanna - Take A Bow.wav'; [y,Fs]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits %用db4小波对原始音频信号进行3级小波分解 [c,l]=wavedec(y,3,'db4');%3级小波分解,低频部分为相似,高频部分为细节 %提取3级小波分解的低频系数和高频系数 ca3=appcoef(c,l,'db4',3);%提取三级小波分解的最低频分 cd3=detcoef(c,l,3);%提取三级小波分解的次低频分 cd2=detcoef(c,l,2); cd1=detcoef(c,l,1); x=ca3;%提取三级小波分解的最低频部分 %找到插入位置,检测特征点 s=max(abs(x))*0.2; i=find(abs(x)>s); lx=length(x(i)); %读取水印音频 FILE2='test_new.wav'; [mark,Fs]=audioread(FILE2); mark=mark(1:lx); mark_fft=fft(mark,Fs); % mark_fft_f=2*sqrt(mark_fft.*conj(mark_fft)); axes(handles.axes1); plot(mark); grid on;axis tight; title('水印音频信号的时域波形'); xlabel('time(s)');ylabel('幅度'); axes(handles.axes2) plot(abs(mark_fft)); grid on;axis tight; title('水印音频信号的频域波形'); xlabel('f(Hz)');ylabel('幅度'); sound(mark,Fs); % --- 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) %--------------------------水印嵌入-------------------------% cla reset; Fs=44100; FILE1='Rihanna - Take A Bow.wav'; [y,Fs]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits %用db4小波对原始音频信号进行3级小波分解 [c,l]=wavedec(y,3,'db4');%3级小波分解,低频部分为相似,高频部分为细节 %提取3级小波分解的低频系数和高频系数 ca3=appcoef(c,l,'db4',3);%提取三级小波分解的最低频分 cd3=detcoef(c,l,3);%提取三级小波分解的次低频分 cd2=detcoef(c,l,2); cd1=detcoef(c,l,1); x=ca3;%提取三级小波分解的最低频部分 %找到插入位置,检测特征点 s=max(abs(x))*0.2; i=find(abs(x)>s); lx=length(x(i)); %读取水印音频 FILE2='test_new.wav'; %--------------------------读取原始音频-------------------------% FILE1='Rihanna - Take A Bow.wav'; [y,Fs]=audioread(FILE1); %音频信号y,采样率fs,采样精度bits y_fft=fft(y,Fs); % y_fft_f=2*sqrt(y_fft.*conj(y_fft)); figure(1) %绘制时域波形 plot(y); grid on;axis tight; title('原始音频信号的时域波形'); xlabel('time(s)');ylabel('幅度'); figure(2) %绘制频域波形 plot(abs(y_fft)); grid on;axis tight; title('原始音频信号的频域波形'); xlabel('f(Hz)');ylabel('幅度'); sound(y,Fs); %播放原始语音 %--------------------------读取水印音频-------------------------% FILE1='Rihanna - Take A Bow.wav'; [y,Fs]=audioread(FILE1); %音频信号y,采样率fs %用db4小波对原始音频信号进行3级小波分解 [c,l]=wavedec(y,3,'db4'); %3级小波分解,低频部分为相似,高频部分为细节 %提取3级小波分解的低频系数和高频系数 %这个会返回信号y在level 3(小波分解级数)的小波分解系数 ca3=appcoef(c,l,'db4',3); %提取三级小波分解的最低频分 cd3=detcoef(c,l,3); %提取三级小波分解的次低频分量 cd2=detcoef(c,l,2); cd1=detcoef(c,l,1); x=ca3; %提取三级小波分解的最低频部分 %找到插入位置,检测特征点 s=max(abs(x))*0.2; i=find(abs(x)>s); lx=length(x(i)); %读取水印音频 FILE2='test_new.wav'; [mark,Fs]=audioread(FILE2); mark=mark(1:lx); mark_fft=fft(mark,Fs); % mark_fft_f=2*sqrt(mark_fft.*conj(mark_fft)); figure(3) plot(mark); grid on;axis tight; title('水印音频信号的时域波形'); xlabel('time(s)');ylabel('幅度'); figure(4) plot(abs(mark_fft)); grid on;axis tight; title('水印音频信号的频域波形'); xlabel('f(Hz)');ylabel('幅度'); sound(mark,Fs);
版本:2014a
完整代码或代写加1564658423