【信号隐藏】基于小波变换算法DWT和LSB实现音频数字水印嵌入提取附matlab代码
1 简介
主要研究了在数字语音信号中加入数字水印的方法,提出了一种基于小波变换和LSB的数字水印隐藏与检测算法,用这种算法隐藏水印具有很强的隐藏性,对原始语音的影响基本上察觉不出来.叠加了水印的语音在经过多种强干扰及各种信号处理的变换之后,使用本算法仍能正确检测出水印的存在,如它可以抵抗噪声干扰,去噪算法对信号进行去噪处理,语音信号的有损压缩以及信号的重新采样等.
2 部分代码
function varargout = untitled(varargin)% UNTITLED MATLAB code for untitled.fig% UNTITLED, by itself, creates a new UNTITLED or raises the existing% singleton*.%% H = UNTITLED returns the handle to a new UNTITLED or the handle to% the existing singleton*.%% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in UNTITLED.M with the given input arguments.%% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before untitled_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled_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 untitled% Last Modified by GUIDE v2.5 28-Dec-2020 19:45:23% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled_OpeningFcn, ... 'gui_OutputFcn', @untitled_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 untitled is made visible.function untitled_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 untitled (see VARARGIN)% Choose default command line output for untitledhandles.output = hObject;ha=axes('units','normalized','pos',[0 0 1 1]); uistack(ha,'down'); ii=imread('beijing.jpg');%设置程序的背景图为beijing.jpg image(ii); colormap gray set(ha,'handlevisibility','off','visible','off');% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = untitled_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 structurevarargout{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 GUIDATA)clear sound;cla (handles.axes1,'reset');cla (handles.axes2,'reset');global fs;global x1;global xmax;global xmin;global t;global l1;fs=8000; %采样频率为8000HZ[x1,fs]=audioread('Rihanna - Take A Bow.wav'); %音频信号x1,采样率fsxmax=max(abs(x1)); %计算最大幅度xmin=min(abs(x1)); %计算最小幅度l1=size(x1); %l1计算出载频的总长度,便于FFT分析t=(0:length(x1)-1)/fs;y1=fft(x1,fs); %对信号做FFT变换f=fs*(0:900)/fs;axes(handles.axes1);plot(t,x1) %做原始语音信号的时域图形grid on;axis tight;title('原始语音信号时域波形');xlabel('time(s)');ylabel('幅度');axes(handles.axes2);plot(f,abs(y1(1:901))) %做原始语音信号的FFT频谱图grid on;axis tight;title('原始语音信号频域波形')xlabel('HZ');ylabel('幅度');sound(x1,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)clear sound;cla (handles.axes1,'reset');cla (handles.axes2,'reset');global fs;global sy;global symax;global symin;global syfft;global f;global l2;global t1;%-----------读取水印信号并显示fs=8000; %设定采样频率为8000HZ[sy,fs]=audioread('test_new.wav'); %水印信号sy,采样率fssymax=max(abs(sy)); %计算最大幅度symin=min(abs(sy)); %计算最小幅度l2=size(sy); %l2计算出载频的总长度,便于FFT分析t1=(0:length(sy)-1)/fs;syfft=fft(sy,fs);f=fs*(0:900)/fs;y2=fft(sy,fs); %对水印信号做FFT变换f=fs*(0:900)/fs;axes(handles.axes1); %做原始水印信号的时域图形plot(t1,sy) grid on;axis tight;title('原始水印信号时域波形');xlabel('time(s)');ylabel('幅度');axes(handles.axes2); %做原始水印信号的FFT频谱图plot(f,abs(y2(1:901))) grid on;axis tight;title('原始水印信号频域波形')xlabel('Hz');ylabel('幅度');sound(sy,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)clear sound;cla (handles.axes1,'reset');cla (handles.axes2,'reset');global fs;global xmax;global xmin;global x1;global sy;global l1;global tglobal y1;global f;global symax;global symin;global t1;global syfft;global y2;global lhsy;global lhx1;global fdsy;global xx1;global qrh;global QRH;global l2;global t2;%-------------读入原始信号fs=8000; %采样频率为8000HZ[x1,fs]=audioread('Rihanna - Take A Bow.wav'); %音频信号x1,采样率fsxmax=max(abs(x1)); %计算最大幅度xmin=min(abs(x1)); %计算最小幅度l1=size(x1); %l1计算出载频的总长度,便于FFT分析t=(0:length(x1)-1)/fs;y1=fft(x1,fs); %对信号做FFT变换f=fs*(0:900)/fs;%-----------读取水印信号[sy,fs]=audioread('test_new.wav'); %水印信号sy,采样率fssymax=max(abs(sy)); %计算最大幅度symin=min(abs(sy)); %计算最小幅度l2=size(sy); %l2计算出载频的总长度,便于FFT分析t1=(0:length(sy)-1)/fs;
3 仿真结果




4 参考文献
[1]杨立东. "基于提升小波变换的音频数字水印隐藏与检测算法." 中国通信学会学术年会 2008.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。


