A list,

1 Experiment Content

(1) Embed watermark in an MP3 music (not a song) file.

(2) Design a simple algorithm to complete the watermark embedding and (extraction) verification.

(3) Draw simulation diagram and signal analysis curve, etc.

2 algorithm principle:

Firstly, the audio files in MP3 format are converted into WAVE format audio files, and then digital watermarks are embedded into WAVE format audio files. Finally, the watermarked WAVE file is converted into MP3 format audio files. (Use tools to convert MP3 audio files to WAV format).

3 Experimental steps:

(1) Watermark embedding

① Convert MP3 audio files to WAV format

② Read the WAV format file and watermark image, convert the image into binary graph, reduce dimension, then spread spectrum processing, and finally embed in the audio

③ The embedded watermark signal is reconstructed to get the audio file in WAV format

④ Convert the EMBEDDED WAV file into MP3 format

(2) Watermark extraction

① Convert the embedded MP3 file into WAV format

② Read the original audio and the waV format audio file after watermarking to extract the watermark, spread spectrum decomposition of the watermark signal, dimensional enhancement, the construction of two-dimensional image processing

③ The watermark image is reconstructed

4 Design block diagram:

Ii. Source code

% Add white noise audio watermarking program clear; kk.wave = wavread('3.wav'); % Read the original audio file y=kk.wave; [c,l]=wavedec(y,3.'db4'); % ca3= appCoef (c,l,'db4'.3);
cd3=detcoef(c,l,3);
cd2=detcoef(c,l,2);
cd1=detcoef(c,l,1); x=ca3; % Extraction low frequency coefficient Len =length(y); x1=x; s=max(abs(x))*0.2;
i=find(abs(x)>s); lx=length(x(i)); % find greater than the maximum value0.2Multiple sequence figure; subplot(2.2.1); plot(ca3); % Draw the low frequency coefficient graph title('Low frequency figure');
subplot(2.2.2);
plot(cd3);
title('cd3');
subplot(2.2.3);
plot(cd2);
axis([0 10e4 0.5 0.5]);
title('cd2');
subplot(2.2.4);
plot(cd1);
title('cd1');
randn('seed'.10); % produces a random Gaussian sequence mark=randn(1,lx);
ss=mark;
rr=ss*0.1; % Set watermark embedding strength x(I)=x(I).*(1+2*rr'); % embedded watermark c1=[x',cd3',cd2',cd1'];
s1=waverec(c1,l,'db4');
file1='Watermarked. Wav';
dd=length(s1);
ee=reshape(s1,dd/2.2);
wavwrite(ee,file1);
figure;
subplot(3.1.1); plot(y); % Draw the original signal graph axis([0 18e4 2 - 2]);
title('Diagram of the original signal');                    
subplot(3.1.2); plot(ss); title('Watermark');
subplot(3.1.3); plot(s1); % Draw the watermark embedded signal graph title('Watermarked sound signal')
kk.wave = wavread('Watermarked'); yc=kk.wave; fz=sum(y.*y); % Calculate the signal-to-noise ratio of the embedded signal FM =sum((y-yc).*(y-yc)); SNR=- 10*log(fm/fz)
yyy=randn(1,dd); % add white noise b=sqrt(0.01); 
yyy=b*yyy; 
s1=s1+yyy;
ee=reshape(s1,dd/2.2);
wavwrite(ee,file1);
kk.wave = wavread('Watermarked'); % read sound file yr=kk.wave; [cr,lr]=wavedec(yr,3.'db4');
car3=appcoef(cr,lr,'db4'.3);
cdr3=detcoef(cr,lr,3);
cdr2=detcoef(cr,lr,2);
cdr1=detcoef(cr,lr,1); xr=car3; clc; clear; close all; % watermark embedded program % read audio signal3.[A,fs,nbits] = wavRead ('3.wav'); % Plot the original sound image subplot(311); plot(A); 
axis([0 350000 2 - 2]);
title('Waveform of original sound signal'); % Use variable L to store the length of audio A L = size(A); % read image h.beam save variable M as watermark signal M = imread('h.bmp');
subplot(312); imshow(M); title('Watermarked image'); % Convert image H.beam to binary graph and store variable BW BW = im2bw(M); % Calculate watermark matrix size [M1,M2] = size(BW); % M12 is an intermediate variable to avoid calculating M1*M2 every time M12 = M1*M2; 0 0 0 0 0 0 0 0 0 01,M12); n = M12; % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % to spread spectrum watermarking signal processing, the effect is not very good for % spread spectrum coefficient2
n = M12*2;
M = zeros(n,1); % produces the key sequence Mfor k = 1 : n
    if mod(k,4) = =0
        M(k) = 1;
    else 
        M(k) = 0; End % Watermark signal sequence by bit and key xor L = respectivelyceil(k/2); S(k) = bitxor(C(l),M(k)); End % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % need to embed a watermark information for N N = audio data10; 
length = n*10; % Decompose the original audio signal into Ae and Ar parts I =1 : length; 
j = [1]; % Take rows from L to length of matrix A to construct matrix Ae Ae = A(I,j); % Ae(i,j) i = length+1: L; % Take the length of matrix A to the first column of L row to construct matrix Ar Ar = A(I,j);Copy the code

3. Operation results









Fourth, note

Version: 2014 a