Hi, i am trying to run this code and facing problem. So plz help.....!!!

조회 수: 1 (최근 30일)
Naman
Naman 2014년 5월 3일
이동: DGM 2023년 2월 14일
clc;
close all;
clear all;
% save start time
start_time=cputime;
k=2; % set the gain factor for embeding
%read the original video and get the information
vid = VideoReader('vipmen.avi');
mov = read(vid);
% size of the each frame
Mc=mov.Height;
Nc=mov.Width;
% read in the message image and reshape it into a vector
file_name='_copyright_small.bmp';
message=double(imread(file_name)); % 0's and 255's in matrix
[Mm,Nm]=size(message);
message_vector=round(reshape(message,Mm*Nm,1)./256);
% read in key for PN generator
file_name='_key.bmp';
key=double(imread(file_name))./256;
% key=mean(key);
for h=1:mov.NumFrames
for z=1:3
% take the single frame of the video
cover_object=mov(h).cdata(:,:,z);
cover_object=double(cover_object);
% reset MATLAB's PN generator to state "key"
rand('state',key(1));
%perform DWT
[cA1,cH1,cV1,cD1] = dwt2(cover_object,'haar');
% add pn sequences to H1 and V1 componants when message = 0
for (kk=1:length(message_vector))
pn_sequence_h=round(2*(rand(Mc/2,Nc/2)-0.5));
pn_sequence_v=round(2*(rand(Mc/2,Nc/2)-0.5));
if (message(kk) == 0)
cH1=cH1+k*pn_sequence_h;
cV1=cV1+k*pn_sequence_v;
end
end
% perform IDWT
watermarked_image = idwt2(cA1,cH1,cV1,cD1,'haar',[Mc,Nc]);
R{z}=watermarked_image;
end
% I2--> 3D color watermarked frame
I2=cat(3,cell2mat(R(1)),cell2mat(R(2)),cell2mat(R(3)));
% I3--> all watermarked frames in 4-D
I3(:,:,:,h)=I2;
end
%convert all the frames into matlab movie format
for y=1:h
mov2(y).cdata=uint8(I3(:,:,:,y));
mov2(y).colormap=[];
end
% matlab movie is converted into avi file and it is stored into hard disk
movie2avi(mov2,'watermarkedvideo','FPS',30,'compression','None')
% display processing time
elapsed_time=cputime-start_time
  댓글 수: 4
Naman
Naman 2014년 5월 6일
이동: DGM 2023년 2월 14일
Thanks both of you for your reply.
Naman
Naman 2014년 5월 6일
이동: DGM 2023년 2월 14일
Error has been fixed. Now i want to use it with MATLAB function block and i do not knw how to use it with this code.

댓글을 달려면 로그인하십시오.

답변 (1개)

Mehdi
Mehdi 2014년 5월 3일
Can you attach vipmen.avi so the code can be run to check errors
  댓글 수: 1
Naman
Naman 2014년 5월 6일
이동: DGM 2023년 2월 14일
vipmen.avi is a small video. You can consider any video instead of this and rename it as vipmen.avi (.avi is a kind of video format)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by