⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_porg.m

📁 Digital watermarking
💻 M
字号:
clear all
close all
clc
%xin = wavread('hota.wav');
xin = wavread('test.wav');
xin = xin(1:length(xin)/4);
[m_xn,n_xn] = size(xin);
% set the parameters for the program
block = 512;
length_watermark = 50;
alpha = 0.1;
% Call the function that will generate random watermark
watermark = watermark_generation(length_watermark);
% Call the function that will insert the watermark in the input audio stream
[xn,watermarked_audio] = insert_WM(xin,block,alpha,watermark);
n = length(xn)-1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ORIGINAL AND WATERMARKED SIGNAL IN TIME DOMAIN
figure(1)
subplot(311),plot(xn),grid;
%axis([0 250000 -2 2]);
title('The original signal in time domain');
subplot(312),plot(real(watermarked_audio)),grid;
%axis([0 250000 -2 2]);
title('The watermarked signal in time domian');
difference_in_time = real(watermarked_audio) - xn;
subplot(313),plot(difference_in_time),grid;
%axis([0 250000 -2 2]);
title('Difference of original signal and of watermarked signal in time domain');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CALCULATE THE FFT OF THE ORIGINAL AND WATERMARKED FILE
fft_original = (abs(fftshift(fft(xn)))./4000);
fft_watermarked = (abs(fftshift(fft(watermarked_audio)))./4000);
difference_in_fft = fft_watermarked - fft_original;
pause
figure(2)
subplot(311),plot((-n/2:n/2)/(n/2),fft_original),grid;
%axis([0 250000 -50 100]);
title('Frequency response of the original signal');
subplot(312),plot((-n/2:n/2)/(n/2),fft_watermarked),grid;
%axis([0 250000 -50 100]);
title('Frequency response of the watermarked signal');
subplot(313),plot((-n/2:n/2)/(n/2),difference_in_fft),grid;
%axis([0 250000 -50 100]);
title('Difference of Frequency response of the original signal and of watermarked signal');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CALCULATE THE FFT OF THE ORIGINAL AND WATERMARKED FILE
fft_original_db = 20.*log10(abs(fftshift(fft(xn)))./4000);
fft_watermarked_db = 20.*log10(abs(fftshift(fft(watermarked_audio)))./4000);
difference_in_fft_db= fft_watermarked_db - fft_original_db;

pause
figure(3)
subplot(311),plot((-n/2:n/2)/(n/2),fft_original_db),grid;
%axis([0 250000 -50 100]);
title('Frequency response of the original signal in dB');
subplot(312),plot((-n/2:n/2)/(n/2),fft_watermarked_db),grid;
%axis([0 250000 -50 100]);
title('Frequency response of the watermarked signal in dB');
subplot(313),plot((-n/2:n/2)/(n/2),difference_in_fft_db),grid;
%axis([0 250000 -50 100]);
title('Difference of Frequency response of the original signal and of watermarked signal in dB');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
recovered_WM = remove_WM(xn,watermarked_audio,length_watermark,block,alpha);

pause
figure(4)
subplot(311),stem(real(watermark),'c'),grid
title('The original watermark');
axis([0 50 -1 1]);
subplot(312),stem(real(recovered_WM),'r'),grid
title('The recovered watermark');
axis([0 50 -1 1]);
test_acc = recovered_WM - watermark;
subplot(313), stem(real(test_acc),'b'),grid
axis([0 50 -1 1]); 
title('The difference between the origninal and recovered watermarks');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pause
wavplay(xn,44100);
pause
wavplay(real(watermarked_audio),44100);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -