-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain
55 lines (53 loc) · 1.62 KB
/
main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
clc
clear all
close all
sel=input('Enter the choice : \n 1- recorded Sound wave \n 2- New Sound \n Enter Choice:');
if sel==1
% file=uigetfile({'*'}); % get input file
[A,fs,nbits] = wavread('test.wav'); % read the audio wave
elseif sel==2
t=5; % time in seconds
fs=44100; % % sampling rate
recobj=audiorecorder(fs,8,1);
recordblocking(recobj, t);
play(recobj)
A = getaudiodata(recobj);
end
% A=A(1:15000);
figure(1)
subplot(2,1,1)
plot(A)
title('Input Audio Signal')
%% embedding watremark loaded
I=imread('_copyright.bmp'); % read watermark image
I=im2bw(I);
figure(2)
subplot(1,2,1)
imshow(I)
title('Embedding Message')
[row,colm]=size(I);
watermark=imresize(I,[1,row*colm]);
%% condition check
if numel(watermark)>numel(A)
errordlg('Watermark Message is too large to be embedded')
end
%% sampling of input audio in frames
dwtlevel=4; % % Level for DWT
cnt=1;% initilaisation of counter variable
ind=1; % counter started to pick the element from the original image vector
message_chunks=(numel(watermark)/(dwtlevel^2-dwtlevel));
signalinframe=numel(A)/(message_chunks);
iter= message_chunks;
gain=3;
[finalwatermrked,U11,V11]=embedding(gain,A,watermark,signalinframe,iter,dwtlevel);
figure(1)
subplot(2,1,2)
plot(finalwatermrked)
axis tight
title('Watermarked Audio Signal')
%% evaluation for embedding
originalframe=A(1:numel(finalwatermrked));
[NCC,MSE,PSNR]=evelauation( originalframe',finalwatermrked); % evaluation for embedded audio signal
display(['Normalised cross correlation = ', num2str(NCC)])
disp(['PSNR Peak Signal to Noise Ratio = ', num2str(PSNR)]);
disp(['Mean Squaer Error = ', num2str(MSE)]);