Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how could i run this code? and what big mistake in it?

Subject: how could i run this code? and what big mistake in it?

From: amit

Date: 1 Aug, 2011 18:24:11

Message: 1 of 11

clc;
clf;
close all;
clear all;
%============READ A MOVIE TAKE A FRAME====================================%
beta = 0.7;
alpha = 0.649;
watermark_frames = 30;
water = aviinfo('for.avi')
watm = aviread('for.avi',1:30);
asd = aviinfo('news[1].avi')
mob = aviread('news[1].avi',1:300);
%--------------------------IMAGE TO BE WATERMARKED -----------------------%
%frame_no = rand(1,100);
%frame_no = frame_no*1000;
%counter = 0;
for frame=1:1:watermark_frames
%if(frame_no(frame)<300 && counter < watermark_frames)
% counter=counter+1;
% n = fix(frame_no(frame));
% key(counter)=n;
%n1 = n+1;
%else
% continue;
%end
n = frame;
n1= n+1;
aa = mob(n).cdata;
bb = mob(n).colormap;
pp = ind2rgb(aa,bb);
pp = rgb2ycbcr(pp);
IY = pp(:,:,1);
%figure(100+frame);
%imshow(IY);
%title('Luminance component of the frame to be watermarked');
ICr = pp(:,:,2);
ICb = pp(:,:,3);
%========================== FREQUENCY MASKING TRIAL =====================%
[ROW,COL] = size(IY);
BCK = (ROW *COL)/(4*4);
k = zeros(4);
T2 = zeros(BCK,4,4);
Tth = zeros(BCK,4,4);
T3 = zeros(ROW,COL);
T1 = zeros(ROW,COL);
S3 = zeros(ROW,COL);
%---------------------------4*4 DCT OF IMAGE -----------------------------%
c=0;
k = dctmtx(4);
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
ss=IY(ii:x,jj:y);
P=(k * ss * k');
T2(c,1:4,1:4)=P;
T1(ii:x,jj:y)=P;
end
end
%figure(2);
%imshow(T1);
%title('DCT of the luminance component to be watermarked');
%------------------FREQ MASKING START ------------------------------------%
p = 0;
for ii=1:1:BCK
p = p + T2(ii,1,1);
end
p=p/BCK;
for c=1:1:BCK
for ii=1:1:4
for jj=1:1:4
Tth(c,ii,jj) = T2(c,ii,jj) * power((T2(c,1,1)/p),alpha);
end
end
end
%--------------STORING OF VARIOUS BLOCKS IN IMAGE ARRAY ------------------%
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
T3(ii:x,jj:y) = Tth(c,1:4,1:4);
end
end
%figure(3);
%imshow(T3);
%title('DCT Freq. masked component of IY');
%----------------------------INVERSE DCT IMAGE----------------------------%
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
ss = T3(ii:x,jj:y);
P = (k' * ss * k);
S3(ii:x,jj:y)=P;
end
end
%figure(4);
%imshow(S3);
%title('Freq. masked image of IY');
%-------------------------------------------------------------------------%
kk1 = imsubtract(S3,IY);
%figure(5);
%imshow(kk1);
%title('Diff. of IY and freq masked image');
%-----------------EDGE REMAIN AFTER FREQUENCY MASKING---------------------%
edfreq=edge(kk1,'canny');
%figure(6);
%imshow(edfreq);
%title('EDGE remain after freq. masking');
%=======================SPATIAL MASKING TRIAL ============================%
[ROW,COL] = size(IY);
S = zeros(ROW,COL);
a = 0.05;
for ii=1:ROW
for jj=1:COL
S(ii,jj) = 1+(99 * ( log10(1+IY(ii,jj)*a)-log10(1+a))/(log10(1+100*a)-log10(1+a)));
end
end
%figure(7);
%imshow(S);
%title('CONTRAST controlled image');
edcont = edge (S ,'canny');
%figure(8);
%imshow(edcont);
%title('EDGES of contrast controlled image');
%============================MOTION MASKING EFFECT========================%
aa = mob(n).cdata;
bb = mob(n).colormap;
pp=ind2rgb(aa,bb);
pp=rgb2ycbcr(pp);
IYY = pp(:,:,1);
%figure(9);
%imshow(IYY);
%title('LUMINANCE component of first image');
aa1 = mob(n1).cdata;
bb1 = mob(n1).colormap;
pp1=ind2rgb(aa1,bb1);
pp1=rgb2ycbcr(pp1);
IYZ = pp1(:,:,1);
%figure(10);
%imshow(IYZ);
%title('LUMINANCE COMPONENT OF NEXT FRAME');
kk = imsubtract(IYY,IYZ);
kk = im2double(kk);
%figure(11);
%imshow(kk);
%title('DIFFERENCE OF TWO choosen and next frame');
edmotion = edge (kk ,'canny');
%figure(12);
%imshow(edmotion);
%title('edge of diff. between two frames');
%=========================================================================%
S = S;
M = kk;
F = kk1;
GG(frame,:,:)= S+M+F;
%figure(14);
%imshow(GG);
%title('GAURAV');
S = im2double(edcont);
M = im2double(edmotion);
F = im2double(edfreq);
G(frame,:,:)= S+M+F;
%figure(13);
%imshow(G);
%title('total edge due to freq,spatial,motion masking');
%=========================================================================%
c=0;
for ii=1:1:ROW
for jj=1:1:COL
if( G(frame,ii,jj)==1)
c = c+1;
pixel_row(frame,c)=ii;
pixel_col(frame,c)=jj;
end
end
end
cdd(frame)=c;
if(cdd(frame) > 4096)
fprintf('%d NO. OF PIXEL LOCATIONS FOR FRAME NO.%d \n',cdd(frame),frame);
aaa = watm(1).cdata ;
bbb = watm(1).colormap;
RGB = ind2rgb(aaa,bbb);
A = rgb2gray(RGB);
W = im2double(A);
%figure(17);
%imshow(W);
%title('IMAGE TO BE WATERMARKED');
[WR,WC]=size(W);
[ROW COL]=size(IY);
c=0;
for row=1:1:WR
for col=1:1:WC
c=c+1;
IY( pixel_row(frame,c),pixel_col(frame,c)) =IY(pixel_row(frame,c),pixel_col(frame,c))+(0.05 *GG(frame,pixel_row(frame,c),pixel_col(frame,c)) * W(row,col)) ;
end
end
%figure(200+frame);
%imshow(IY);
%title('WATERMARKED IMAGE Y component ');
ppw(:,:,1) = IY(:,:);
%mobw(frame,:,:) = IY(:,:);
ppw(:,:,2) = ICr;
ppw(:,:,3) = ICb ;
%figure(300+frame);
%imshow(ppw);
%title(' WATERMARKED IMAGE ');
ppw1(frame,:,:,:) = ycbcr2rgb(ppw);
mobtemp(:,:,:)=ppw1(frame,:,:,:);
[mob(frame).cdata , mob(frame).colormap] =rgb2ind(mobtemp,mob(frame).colormap);
figure(400+frame);
imshow(mob(frame).cdata , mob(frame).colormap);
title('indexed water marked image');
end
end
movie2avi(mob,'newsw.avi','colormap',mob(1).colormap,'compression','none','fps',1);
movie2avi(mob,'newsw10.avi','colormap',mob(1).colormap,'compression','none','fps',10);
movie2avi(mob,'newsw20.avi','colormap',mob(1).colormap,'compression','none','fps',20);
%video_hvs(ppw1,watm,pixel_row,pixel_col,cdd,GG,watermark_frames);
% MPEG attack =======================%
mov= mpgread('NEWS10.m1v', [1:100],'indexed');
for i=1:1:30
[g,map] = frame2im(mov(i));
x = ind2rgb(g,map);
y = rgb2ycbcr(x);
wm =y(:,:,1);
%wm = im2double(wm);
figure;clf;
imshow(wm);
mobtemp(:,:,1)=wm;
mobtemp(:,:,2)=y(:,:,2);
mobtemp(:,:,3)=y(:,:,3);
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,i)
end
%s(ii) = snr_cal(B1,f1);
%fprintf('SNR = %f\n',s(ii));
%frame dropping and averaging ================%
ii = 1;
mobtemp(:,:,:) = ppw1(ii,:,:,:) ;
mobtemp(:,:,:) = rgb2ycbcr(mobtemp(:,:,:));
S3(:,:) = mobtemp(:,:,1);
B1=im2double(S3);
imwrite(S3, 'J100%.jpg','quality',100);
ii=1;
J = imread('J100%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-100%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
%fprintf('NC 100= %f\n',NC(ii));
imwrite(S3, 'J80%.jpg','quality',80);
ii=2;
J = imread('J80%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-80%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
imwrite(S3, 'J60%.jpg','quality',60);
ii=3;
J = imread('J60%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-60%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
imwrite(S3, 'J40%.jpg','quality',40);
ii=4;
J = imread('J40%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-40%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);;
fprintf('SNR = %f\n',s(ii));
imwrite(S3, 'J30%.jpg','quality',30);
ii=5;
J = imread('J30%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-30%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
imwrite(S3, 'J20%.jpg','quality',20);
ii=6;
J = imread('J20%.jpg');
figure;clf;
imshow(J,[0 255],'truesize');title('JPEG; Quality-20%');
f1=im2double(J);
mobtemp(:,:,1)=f1;
%mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
%Blurring - De-blurring Attack:
ii=7;
% create PSF
LEN = 2;
THETA = 1;
PSF = fspecial('motion',LEN,THETA);
% Blur the image
Blurred = imfilter(S3,PSF,'circular','conv');
imwrite(Blurred,'BLURR.tif');
figure;clf;
imshow(Blurred,'truesize');title('Blurred Image');
J=imread('BLURR.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
% Deblur the image
h10 = deconvwnr(Blurred,PSF);
imwrite(h10, 'DE_BLURRED.tif');
figure; clf;
imshow(h10,'truesize');title('De-Blurred, True PSF');
J=imread('DE_BLURRED.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
%Rotate image by 4 degrees
WM_Ir = imrotate(S3,-2,'bilinear');
WM_Ir2 = imresize(WM_Ir,[144 176]);
imwrite(WM_Ir2,'rot4.tif');
figure;clf;
imshow(WM_Ir2,[],'truesize') ;title('Rotated Image');
J=imread('rot4.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
%Rotate back by 5 degrees and crop irrelevent portion
WM_Irr = imrotate(WM_Ir,+4,'bilinear');
rs_11 = imresize(WM_Irr,[144 176]);
h_11 = imcrop(rs_11,[80 80 500 500]);
h11 = imresize(h_11,[144 176]);
imwrite(h11,'rot_back.tif');
figure;clf;
imshow(h11,'truesize');title('Rotation Corrected cropped and resized Image');
J=imread('rot_back.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
%Average Filtering
F_h = ones(3,3)/9;
h12 = imfilter(S3,F_h);
imwrite(h12, 'Fltr_avg.tif');
figure;clf;
imshow(h12,'truesize');title('Average Filtered Image');
J=imread('Fltr_avg.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
%sharpening Filtering
F_h = [-1,-1,-1;-1,8,-1;-1,-1,-1]/1;
h12 = imfilter(S3,F_h);
figure;
imshow(h12);
h12 = imadd(S3,h12);
imwrite(h12, 'Fltr_sharp.tif');
figure;clf;
imshow(h12,'truesize');title('sharp Filtered Image');
J=imread('Fltr_sharp.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
h13 = imnoise(S3,'salt & pepper', 0.002);
imwrite(h13,'Noisy_SNP.tif');
figure;clf;
imshow(h13,'truesize');
title('Salt-n-Pepper Noise Affected Image');
J=imread('Noisy_SNP.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
% AWG-Noise attack
h14 = imnoise(S3,'gaussian',.001,.005);
imwrite(h14,'Noisy_AWGN.tif');
figure;clf;
imshow(h14,'truesize');title('AWGN Affected Image');
J=imread('Noisy_AWGN.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
ii=ii+1;
% Apply Dithering Attack
h15 = dither(S3);
imwrite(h15, 'Im_dithered.tif');
figure;clf;
imshow(h15, 'truesize');title('Dithered Image');
J=imread('Im_dithered.tif');
f1=im2double(J);
mobtemp(:,:,1)=f1;
% mobtemp(:,:,:)=ycbcr2rgb(mobtemp(:,:,:));
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,ii);
s(ii) = snr_cal(B1,f1);
fprintf('SNR = %f\n',s(ii));
MPEG ATTACK
clear all;
close all;
clc;
clf;
water = aviinfo('for.avi')
watm = aviread('for.avi',1:30);
mov= mpgread('NEWS10.m1v', [1:100],'indexed');
for i=1:1:30
[g,map] = frame2im(mov(i));
x = ind2rgb(g,map);
y = rgb2ycbcr(x);
wm =y(:,:,1);
%wm = im2double(wm);
figure;clf;
imshow(wm);
mobtemp(:,:,1)=wm;
mobtemp(:,:,2)=y(:,:,2);
mobtemp(:,:,3)=y(:,:,3);
video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,i)
end
%movie2avi(mov,'foren.avi');
%mm = aviread('foren.avi',1:300);
function [S] = snr_cal (B1_1,S3_1)
%----------SNR CALCULATION FOR WATERMARKED IMAGE -------------------%
if (size(B1_1) ~= size(S3_1))
error('The size of image is too large')
end
[m n] = size(B1_1);
total_I = 0;
total_Dif = 0;
for u = 1:m
for v = 1:n
total_I = total_I + B1_1(u, v)^2;
total_Dif = total_Dif + (B1_1(u, v) - S3_1(u, v))^2;
end
end
if (total_Dif == 0)
total_Dif = 1;
end
S = (total_I) / (total_Dif);
S = (10 * log10(S));
function [] =video_hvs1(mobtemp,watm,pixel_row,pixel_col,cdd,GG,i)
%---------------EXTRACTION PROCESS BY INVERSE DCT-------------------------%
mob_orig = aviread('news[1].avi',1:300);
aaa = watm(1).cdata;
bbb = watm(1).colormap;
RGB = ind2rgb(aaa,bbb);
A = rgb2gray(RGB);
[WR,WC] = size(A);
orig_W = im2bw(A);
frame=i;
if(cdd(frame) > 4096)
%aa = mob(frame).cdata;
%bb = mob(frame).colormap;
%mobw(:,:,:)=ppw1(frame,:,:,:);
%pp=ind2rgb(aa,bb);
%mobw(:,:,:) = rgb2ycbcr(mobw(:,:,:));
%mobtemp(:,:,:) = rgb2ycbcr(mobtemp(:,:,:));
HH (:,:) = mobtemp(:,:,1);
aa1 = mob_orig(frame).cdata;
bb1 = mob_orig(frame).colormap;
pp1=ind2rgb(aa1,bb1);
pp1=rgb2ycbcr(pp1);
IY = pp1(:,:,1);
%figure(17);
%imshow(W);
%title('IMAGE TO BE WATERMARKED');
[ROW COL]=size(IY);
c=0;
for row=1:1:WR
for col=1:1:WC
c=c+1;
W_extract(row,col) = ( HH( pixel_row(frame,c),pixel_col(frame,c)) -
IY(pixel_row(frame,c),pixel_col(frame,c)) ) / ( 0.05 * GG( frame ,
pixel_row(frame,c) , pixel_col(frame,c)) );
end
end
figure(frame+500);
imshow(W_extract);
W_4 = im2bw(W_extract);
%--------------NORMALIZED CROSS CORRELATION -------------%
w=0;
r=0;
for ii=1:1:WR
for jj = 1:1:WC
w = w + (orig_W(ii,jj) * W_4(ii,jj));
r = r + (orig_W(ii,jj) * orig_W(ii,jj));
end
end
fprintf('EXTRACTED FRAME %d',frame);
NC = (w / r)*100
end
TEXTURE1
clc;
clf;
close all;
clear all;
Threshold =3;
w_frames = 30 ;
DIFF =4;
asd = aviinfo('mother[22].avi')
mob = aviread('mother[22].avi',1:300);
temp1=0;
temp2=0;
temp3=0;
temp4=0;
temp5 = 0;
temp6 = 0;
temp7 = 0;
temp8 = 0;
for frame = 1:1:w_frames
n = frame;
aa = mob(n).cdata;
bb = mob(n).colormap;
pp = ind2rgb(aa,bb);
pp = rgb2ycbcr(pp);
IY = pp(:,:,1);
aa1 = mob(n+1).cdata;
bb1 = mob(n+1).colormap;
pp1 = ind2rgb(aa,bb);
pp1 = rgb2ycbcr(pp1);
IY1 = pp1(:,:,1);
[ROW,COL]=size(IY);
k=dctmtx(4);
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s1=IY1(ii:x,jj:y);
next4(c,1:4,1:4)= s1;
s=IY(ii:x,jj:y);
T4(c,1:4,1:4)= s;
P=(k * s * k');
T2(c,1:4,1:4)=P;
T1(ii:x,jj:y)=P;
end
end
%figure(1);
%imshow(T1);
edgemap = edge(IY,'canny');
c =0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s1 = edgemap(ii:x,jj:y);
T3(c,1:4,1:4) = s1;
end
end
blocks = c;
high_texture = 0;
low_texture = 0;
for c=1:1:blocks
h=0;
for ii=1:1:4
for jj=1:1:4
if(T3(c,ii,jj)==1)
h = h+1;
end
end
end
if(h>=2)
block_status(frame,c)=1;
high_texture = high_texture + 1 ;
else
block_status(frame,c)=0;
low_texture = low_texture + 1 ;
end
end
high_tex(frame) = high_texture
low_tex(frame) = low_texture
RGB=imread('skoda.jpg');
J=rgb2gray(RGB);
J =imresize(J,[50,50],'nearest');
J = im2double(J);
%imshow(J);
%========================= WATERMARKING VARIANTS =======================%
for x=1:1:5
switch (x)
case 1
for c = 1 : 1 : blocks
WT1(c,1:4,1:4) = T2(c,1:4,1:4);
end
i=0;
j=0;
tot_lum = 0;
count = 0;
for c = 1 : 1 : blocks
if( block_status(frame ,c)==1)
lum = 0;
for ii=1:4
for jj=1:4
lum = lum + T4(c,ii,jj) ;
end
end
tot_lum = tot_lum + lum;
count = count + 1 ;
blk(count)=c ;
end
end
ii=0;
for i=1:1:50
for j=1:1:50
ii=ii+1;
if(ii<=count)
WT1(blk(ii),1,1) = WT1(blk(ii),1,1) + 0.02*
(J(i,j)) ;
end
end
end
HTL(frame) = tot_lum / (count * 16);
C=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
C=C+1;
P1=WT1(C,1:4,1:4);
WWT1(ii:x,jj:y)=P1;
end
end
%figure;
%imshow(WWT1);
%title('EMBEDDED WATERMARK STRENGTH DCT');
%WRT1 = zeros(frame,1:144,1:176);
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s = WWT1(ii:x,jj:y);
P = (k' * s * k);
%T2(c,1:4,1:4)=P;
WWT1(ii:x,jj:y)= P;
%WRT1(frame,ii:x,jj:y)=P;
end
end
figure;
imshow(WWT1);
c=0;
diff_hightex(frame) =0;
for ii=1:1:ROW
for jj=1:1:COL
diff_hightex(frame) = diff_hightex(frame) + (WWT1(ii ,jj) -
IY(ii,jj) );
end
end
xxx1 = diff_hightex(frame);
%figure;
%imshow(WRT1(frame));
case 2
for c = 1 : 1 : blocks
WT2(c,1:4,1:4) = T2(c,1:4,1:4) ;
end
i=0;
j=0;
tot_lum = 0;
count = 0;
for c = 1 : 1 : blocks
if( block_status( frame ,c)==0)
lum = 0;
for ii=1:4
for jj=1:4
lum = lum + T4(c,ii,jj) ;
end
end
tot_lum = tot_lum + lum;
count = count + 1 ;
blk(count)=c;
end
end
ii=0;
for i=1:1:50
for j=1:1:50
ii=ii+1;
if(ii<=count)
WT2(blk(ii),1,1) = WT2(blk(ii),1,1) + 0.02 *
(J(i,j)) ;
end
end
end
LTL(frame) = tot_lum / (count*16);
C=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
C=C+1;
P1=WT2(C,1:4,1:4);
WWT2(ii:x,jj:y)=P1;
end
end
%figure;
%imshow(WWT2);
%title('EMBEDDED WATERMARK STRENGTH DCT');
%WRT2 = zeros(frame,1:144,1:176);
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s = WWT2(ii:x,jj:y);
P = (k' * s * k);
%T2(c,1:4,1:4)=P;
WWT2(ii:x,jj:y)= P;
% WRT2(frame,ii:x,jj:y)=P;
end
end
%figure;
%imshow(WWT2);
c=0;
diff_lowtex(frame) =0;
for ii=1:1:ROW
for jj=1:1:COL
diff_lowtex(frame) = diff_lowtex(frame) + (WWT2(ii ,jj) - IY(ii,jj)
);
end
end
xxx2 = diff_lowtex(frame);
case 3
for c = 1 : 1 : blocks
WT3(c,1:4,1:4) = T2(c,1:4,1:4) ;
end
for c = 1 :2 : blocks
count = count + 1 ;
blk(count)=c;
end
ii=0;
for i=1:1:50
for j=1:1:50
ii=ii+1;
if(ii<=count)
WT3(blk(ii),1,1) = WT3(blk(ii),1,1) + 0.02*
(J(i,j)) ;
end
end
end
case 4
low_tex_low_lum = 0;
DL =0;
for c = 1 : 1 : blocks
WT4(c,1:4,1:4) = T2(c,1:4,1:4) ;
end
i=0;j=0;
for c = 1 : 1 : blocks
if( block_status( frame ,c)==0)
lum = 0;
for ii=1:4
for jj=1:4
lum = lum + WT4(c,ii,jj) ;
end
end
if(lum < Threshold )
low_tex_low_lum = low_tex_low_lum + 1;
blk4(low_tex_low_lum) = c;
residue = 0;
for kk = 1:4
for ll = 1:4
residue = residue + abs(T2(c,kk,ll)-
next4(c,kk,ll));
end
end
if(residue < DIFF)
DL = DL + 1 ;
end
% WT4(c,1,1) = WT4(c,1,1) + J(i,j);
end
end
end
ii=0;
for i=1:1:50
for j=1:1:50
ii=ii+1;
if(ii<=low_tex_low_lum)
WT4(blk4(ii),1,1) = WT4(blk4(ii),1,1) +
0.02* (J(i,j)) ;
end
end
end
DL = DL;
LDLTR(frame) = DL/low_tex(frame);
low_tex_low_lum = low_tex_low_lum
C=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
C=C+1;
P1=WT4(C,1:4,1:4);
WWT4(ii:x,jj:y)=P1;
end
end
%figure;
%imshow(WWT4);
%title('EMBEDDED WATERMARK STRENGTH DCT');
%WRT1 = zeros(frame,1:144,1:176);
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s = WWT4(ii:x,jj:y);
P = (k' * s * k);
%T2(c,1:4,1:4)=P;
WWT4(ii:x,jj:y)= P;
%WRT1(frame,ii:x,jj:y)=P;
end
end
%figure;
%imshow(WWT4);
c=0;
diff_low_tex_low_lum(frame) =0;
for ii=1:1:ROW
for jj=1:1:COL
diff_low_tex_low_lum(frame) = diff_low_tex_low_lum(frame) + (WWT4(ii
,jj) - IY(ii,jj) );
end
end
xxx4 = diff_low_tex_low_lum(frame);
%figure;
%imshow(WRT1(frame));
case 5
high_tex_low_lum = 0;
for c = 1 : 1 : blocks
WT5(c,1:4,1:4) = T2(c,1:4,1:4) ;
end
i=0;j=0;
DH = 0;
for c = 1 : 1 : blocks
if( block_status(frame ,c)==1)
lum = 0;
for ii=1:4
for jj=1:4
lum = lum + WT5(c,ii,jj) ;
end
end
if(lum < Threshold )
high_tex_low_lum = high_tex_low_lum + 1;
blk5(high_tex_low_lum) = c;
residue = 0;
for kk = 1:4
for ll = 1:4
residue = residue + abs(T2(c,kk,ll)-
next4(c,kk,ll));
end
end
if(residue < DIFF)
DH = DH + 1 ;
end
%WT5(c,1,1) = WT5(c,1,1) + J(i,j);
end
end
end
ii=0;
for i=1:1:50
for j=1:1:50
ii=ii+1;
if(ii<=high_tex_low_lum)
WT5(blk5(ii),1,1) = WT5(blk5(ii),1,1) +
0.02* (J(i,j)) ;
end
end
end
DH = DH;
LDHTR(frame)= DH / high_tex(frame);
high_tex_low_lum = high_tex_low_lum
C=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
C=C+1;
P1=WT5(C,1:4,1:4);
WWT5(ii:x,jj:y)=P1;
end
end
%figure;
%imshow(WWT5);
%title('EMBEDDED WATERMARK STRENGTH DCT');
%WRT1 = zeros(frame,1:144,1:176);
c=0;
for ii=1:4:ROW
for jj=1:4:COL
x=ii+3;
y=jj+3;
c=c+1;
s = WWT5(ii:x,jj:y);
P = (k' * s * k);
%T2(c,1:4,1:4)=P;
WWT5(ii:x,jj:y)= P;
%WRT1(frame,ii:x,jj:y)=P;
end
end
%figure;
%imshow(WWT5);
c=0;
diff_high_tex_low_lum(frame) =0;
for ii=1:1:ROW
for jj=1:1:COL
diff_high_tex_low_lum(frame) = diff_high_tex_low_lum(frame) +
(WWT5(ii,jj) - IY(ii,jj) );
end
end
xxx5 = diff_high_tex_low_lum(frame);
end
end
temp1 = temp1 + LDHTR(frame);
temp2 = temp2 + LDLTR(frame);
temp3 = temp3 + LTL(frame);
temp4 = temp4 + HTL(frame);
temp5 = temp5 + diff_lowtex(frame);
temp6 = temp6 + diff_hightex(frame);
temp7 = temp7 + diff_low_tex_low_lum(frame);
temp8 = temp8 + diff_high_tex_low_lum(frame);
end
LDHTR_F = temp1/w_frames
LDLTR_F = temp2/w_frames
LTL_F = temp3/w_frames
HTL_F = temp4/w_frames
LTC_F = LDLTR_F/LTL_F
HTC_F = LDHTR_F/HTL_F
mean_diff_lowtex = temp5/w_frames
mean_diff_hightex = temp6/w_frames
mean_diff_low_tex_low_lum = temp7/w_frames
mean_diff_high_tex_low_lum = temp8/w_frames

Subject: how could i run this code? and what big mistake in it?

From: Roger Stafford

Date: 1 Aug, 2011 19:02:26

Message: 2 of 11

  Amit, I object to the question you have posed. Without giving any hint as to what you regard as unsatisfactory about your 977 lines of code you have simply exhibited them in their entirety. Do you seriously believe that people are going to go through as much code as that with no more information than you have furnished? You need to fully explain what the trouble is and merely give a small, very small, sample of code illustrating this difficulty. Please try again.

Roger Stafford

Subject: how could i run this code? and what big mistake in it?

From: Jan Simon

Date: 1 Aug, 2011 22:31:28

Message: 3 of 11

Dear Roger,
You have counted the number of lines.
Wow.
Kind regards, Jan

Subject: how could i run this code? and what big mistake in it?

From: Roger Stafford

Date: 2 Aug, 2011 00:42:10

Message: 4 of 11

"Jan Simon" wrote in message <j179g0$n49$1@newscl01ah.mathworks.com>...
> Dear Roger,
> You have counted the number of lines.
> Wow.
> Kind regards, Jan
- - - - - - - - - - - -
  No, Jan, I have better ways of spending my time than that. I copied and pasted the whole lot into Microsoft Word and used its line count tool.

Roger Stafford

Subject: how could i run this code? and what big mistake in it?

From: TideMan

Date: 2 Aug, 2011 07:47:14

Message: 5 of 11

On Aug 2, 12:42 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Jan Simon" wrote in message <j179g0$n4...@newscl01ah.mathworks.com>...
> > Dear Roger,
> > You have counted the number of lines.
> > Wow.
> > Kind regards, Jan
>
> - - - - - - - - - - - -
>   No, Jan, I have better ways of spending my time than that.  I copied and pasted the whole lot into Microsoft Word and used its line count tool.
>
> Roger Stafford

Another way is to use Perl:
perl('countlines.pl','test.txt')

where coutlines.pl is:
while (<>) {};
print $.,"\n";

Subject: how could i run this code? and what big mistake in it?

From: TideMan

Date: 2 Aug, 2011 07:46:20

Message: 6 of 11

On Aug 2, 12:42 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Jan Simon" wrote in message <j179g0$n4...@newscl01ah.mathworks.com>...
> > Dear Roger,
> > You have counted the number of lines.
> > Wow.
> > Kind regards, Jan
>
> - - - - - - - - - - - -
>   No, Jan, I have better ways of spending my time than that.  I copied and pasted the whole lot into Microsoft Word and used its line count tool.
>
> Roger Stafford

Subject: how could i run this code? and what big mistake in it?

From: Steven_Lord

Date: 2 Aug, 2011 14:27:12

Message: 7 of 11



"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message news:j16t82$e1r$1@newscl01ah.mathworks.com...
> Amit, I object to the question you have posed. Without giving any hint
> as to what you regard as unsatisfactory about your 977 lines of code you
> have simply exhibited them in their entirety. Do you seriously believe
> that people are going to go through as much code as that with no more
> information than you have furnished? You need to fully explain what the
> trouble is and merely give a small, very small, sample of code
> illustrating this difficulty. Please try again.

When I pasted this into MATLAB Editor, it listed 975 lines and showed a
number of red Code Analyzer messages indicating errors that should be the
first things the OP investigates. I think the discrepancy between our counts
is due to the fact that a couple of lines are very long (particularly line
198) and would wrap onto multiple lines using Microsoft Word.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how could i run this code? and what big mistake in it?

From: amit

Date: 2 Aug, 2011 17:34:08

Message: 8 of 11

SRY 4 TROUBLE..ACTUALLY THIS CODE IS FOR WATERMARKING TECHNIQUE..
WE USE TWO VIDEOS ,ONE IS REFERENCE VIDEO AND ANOTHER IS VIDEO IS USED TO WATERMARKED...
"Steven_Lord" <slord@mathworks.com> wrote in message <j191g0$3bl$1@newscl01ah.mathworks.com>...
>
>
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> message news:j16t82$e1r$1@newscl01ah.mathworks.com...
> > Amit, I object to the question you have posed. Without giving any hint
> > as to what you regard as unsatisfactory about your 977 lines of code you
> > have simply exhibited them in their entirety. Do you seriously believe
> > that people are going to go through as much code as that with no more
> > information than you have furnished? You need to fully explain what the
> > trouble is and merely give a small, very small, sample of code
> > illustrating this difficulty. Please try again.
>
> When I pasted this into MATLAB Editor, it listed 975 lines and showed a
> number of red Code Analyzer messages indicating errors that should be the
> first things the OP investigates. I think the discrepancy between our counts
> is due to the fact that a couple of lines are very long (particularly line
> 198) and would wrap onto multiple lines using Microsoft Word.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: how could i run this code? and what big mistake in it?

From: Jan Simon

Date: 2 Aug, 2011 19:18:09

Message: 9 of 11

Dear Roger,

> No, Jan, I have better ways of spending my time than that. I copied and pasted the whole lot into Microsoft Word and used its line count tool.

You copied the message containing Matlab code into Microsoft Word.
What kind of dirty tricks are comming next...

Kind regards, Jan

Subject: how could i run this code? and what big mistake in it?

From: Roger Stafford

Date: 2 Aug, 2011 19:31:11

Message: 10 of 11

"Jan Simon" wrote in message <j19ihh$1ig$1@newscl01ah.mathworks.com>...
> You copied the message containing Matlab code into Microsoft Word.
> What kind of dirty tricks are comming next...
> Kind regards, Jan
- - - - - - - -
  I plead guilty as charged.

Roger Stafford

Subject: how could i run this code? and what big mistake in it?

From: Pat Finder

Date: 30 May, 2012 01:44:07

Message: 11 of 11

"Jan Simon" wrote in message <j19ihh$1ig$1@newscl01ah.mathworks.com>...
> Dear Roger,
> > No, Jan, I have better ways of spending my time than that. I copied and pasted the whole lot into Microsoft Word and used its line count tool.

In case anyone is still listening... "wc -l <filename>" in unix or linux, gives the "word count -lines" and returns the number of lines in the file. It also reads from stdin.

Okay, as for the original post: the big mistake is that it isn't modular.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us