【信號隱藏】基于小波變換算法DWT和LSB實現(xiàn)音頻數(shù)字水印嵌入提取附matlab代碼
1 簡介
主要研究了在數(shù)字語音信號中加入數(shù)字水印的方法,提出了一種基于小波變換和LSB的數(shù)字水印隱藏與檢測算法,用這種算法隱藏水印具有很強的隱藏性,對原始語音的影響基本上察覺不出來.疊加了水印的語音在經(jīng)過多種強干擾及各種信號處理的變換之后,使用本算法仍能正確檢測出水印的存在,如它可以抵抗噪聲干擾,去噪算法對信號進行去噪處理,語音信號的有損壓縮以及信號的重新采樣等.
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 EDIT
gui_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});
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 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 untitled
handles.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 structure
guidata(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 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 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,采樣率fs
xmax=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,采樣率fs
symax=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 t
global 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,采樣率fs
xmax=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,采樣率fs
symax=max(abs(sy)); ? ? ? ? ? ? ? ? ? ? ? ? ? %計算最大幅度
symin=min(abs(sy)); ? ? ? ? ? ? ? ? ? ? ? ? ? %計算最小幅度
l2=size(sy); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%l2計算出載頻的總長度,便于FFT分析
t1=(0:length(sy)-1)/fs;
3 仿真結果




4 參考文獻
[1]楊立東. "基于提升小波變換的音頻數(shù)字水印隱藏與檢測算法." 中國通信學會學術年會 2008.
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡預測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡文獻,若有侵權聯(lián)系博主刪除。
