Home > other >  Embed on MATLAB to make mistakes
Embed on MATLAB to make mistakes

Time:04-27

Small white one, contact time is not long MATLAB
Just recently when running the code we found there are several mistakes don't know how to solve, please everyone a great god can help me with

First is to run after the software tip line 51 error:
Ae=A (I, j);
How to increase the matrix dimensions?

30 lines, please add a allocates memory statement:
S=zeros (M12 * 2);
Is that ok?

Also is the line 100 variables:
G=[G, F {I, 1}].
How to allocate memory?



clc; clear; close all;
% watermark embedding procedure

Read audio signal % 3. Wav to variables in A
[A, nbits]=audioread (' D: \ MATLAB - MusicWatermrk \ code \ \ audio \ 7 audio watermark embedding and extraction login. Wav ');
Drawing original sound image %
Subplot (211); The plot (A);
The axis ([0. 350000-2, 2]);
The title (' original voice signal waveform figure);
With the length of the variable L store audio A %
L=size (A);
% read image Lena. The BMP in the variable M as watermark signal
M=imread (' D: \ MATLAB - MusicWatermrk \ code \ audio \ \ mark 7 audio watermark embedding and extraction BMP ');
% the image Lena. BMP is converted into binary diagram and deposited in the variable BW
BW=im2bw (M);

% calculation watermarking matrix size
[M1, M2]=size (BW);
% M12 as intermediate variables, avoiding calculating every time the M1 * M2
M12=* M1 M2;
% dimension reduction, will get the one-dimensional sequence of watermark in the sequence of C
C=reshape (BW, 1, M12);
N1=M12;

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% to spread spectrum watermarking signal processing, the effect is not very good
% spread spectrum coefficient for 2
N=M12 * 2;
M=zeros (n, 1);
S=zeros (M12 * 2);
Sequences generated key % M
For k=1: n
If the mod (k, 4)==0
M (k)=1;
The else
M (k)=0;
End
% watermark signal sequence respectively bitwise and key exclusive or
L=ceil (k/2);
S (k)=bitxor (C (l), M (k));
End
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

% to embed a watermark need audio data for N
N=10;
Length=n * 10;
% the original audio signal is decomposed into two parts of the Ae and Ar
I=1: length;
J=1;
Get to the line length of matrix A l % build matrix Ae
Ae=A (I, j);
% Ae (I, j)
I=length + 1: L;
% to the line L take the length of matrix A first column building matrix Ar
Ar=A (I, j);


% to establish cell B, each audio data segment Ae (m) is an element of B
K=1;
% build line M1, M2 x l column (
B=cell (n, 1);
Th=n * n;
% when k is less than the length of the Ae, matrix Ae per 10 lines as an audio data segment in the cellular B
While (k & lt; Th)
I=k: k + 9;
M=(k + 9)/10;
{B, m, 1}=Ae (I, j);
K=k + 10;
End


Established cell D %, and of the discrete cosine transform the cellular B elements in the cell D
D=cell (n, 1);
For I=1: n
D {I, 1}=DCT {I, 1} (B);
End

% build cellular E, intermediate frequency coefficients of the storage of watermark are embedded in
E1=cell (n, 1);
E=D;
For I=1: n
% % the watermark information embedded in the audio C
% E {I, 1} (3)={I, 1} (D) (3) * (1 + 2 * C (I));
% will be embedded in the audio spread-spectrum watermark information S
E {I, 1} (3)={I, 1} (D) (3) * (1 + 2 * S (I));
End

% to establish cell F
F=cell (n, 1);
% will belong to the discrete cosine transformation in the E elements in the cell F
For I=1: n
{I, 1} F=idct (E {I, 1});
End

% incorporating all separation period of creation to one dimensional matrix G
G=F {1, 1};
I from 3 to M1 * % M2 ordinal value
For I=2: n
% to cell cell and the G F the group I combine creation to one dimensional matrix G
G=[G, F {I, 1}].
End
% will create a cell and the G matrix Ar merger d matrix G
G=[G; Ar];
Audiowrite (G, fs, nbits, 'D: \ MATLAB - MusicWatermrk \ code \ audio \ \ test 7 audio watermark embedding and extraction wav');
Subplot (212); The plot (G);
The title (' with the voice of the watermark signal waveform figure).
The axis ([0. 350000-2, 2]);
  • Related