Effacer les filtres
Effacer les filtres

how to extract the watermark after decryption. please help I am getting an error in watermark extraction steps. Thank you in advance

3 vues (au cours des 30 derniers jours)
watermark image
clc;
close all;
clear all;
imageinput=imread('lena.jpg');
imageinput=imresize(imageinput,[256,256]);
imageinput=rgb2gray(imageinput);
figure(1);imshow(imageinput);title('original Host image');
%P=im2double(imageinput);
[F1,F2]= wfilters('haar', 'd');
[LL,LH,HL,HH] = dwt2(imageinput,'haar','d');
[U1,S1,V1]= svd(LL);
S1_temp=S1;
imw2=imread('deblur.jpg');
imw2=imresize(imw2,[128 128]);
imw2=rgb2gray(imw2);
figure(2);imshow(imw2);title('watermark image');
%watermark=im2double(imw2);
[WF1,WF2]= wfilters('haar', 'd');
[L_L,L_H,H_L,H_H] = dwt2(imw2,'haar','d');
[U2,S2,V2]= svd(L_L);
[x y]=size(S2);
alfa= input('Insert the alfa Value = ');
for i=1:x
for j=1:y
S1(i,j) =S1(i,j) + alfa * S2(i,j);
end
end
wimg = U1*S1*V1';
Watermarkedimage=wimg;
%computing level-1 idwt2
Watermarkedimage_final_pre= idwt2(Watermarkedimage,LH,HL,HH,'haar');
Watermarkedimage_final=uint8(Watermarkedimage_final_pre);
figure(3);imshow(Watermarkedimage_final,[]), title('final Watermarkedimage ')
%3D chaotic map for image encryption
%3.53<l<3.81
%0<b<0.022
%0<a<0.015
% x(i+1)=l*x(i)*(1-x(i))+b*y(i)*y(i)*x(i)+a*z(i)*z(i)*z(i);
% y(i+1)=l*y(i)*(1-y(i))+b*z(i)*z(i)*y(i)+a*x(i)*x(i)*x(i);
% z(i+1)=l*z(i)*(1-z(i))+b*x(i)*x(i)*z(i)+a*y(i)*y(i);
%modify the chaos by this equation furthure
%z(i+1)=l*z(i)*(1-z(i))+b*x(i)*x(i)*z(i)+a*y(i)*y(i)*y(i);
%initial conditions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% 3D CHAOS GENERATION CODE%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x(1)=0.2350;
y(1)=0.3500;
z(1)=0.7350;
a(1)=0.0125;
b(1)=0.0157;
l(1)=3.7700;
image_height=256;
for i=1:1:70000
x(i+1)=l*x(i)*(1-x(i))+b*y(i)*y(i)*x(i)+a*z(i)*z(i)*z(i);
y(i+1)=l*y(i)*(1-y(i))+b*z(i)*z(i)*y(i)+a*x(i)*x(i)*x(i);
z(i+1)=l*z(i)*(1-z(i))+b*x(i)*x(i)*z(i)+a*y(i)*y(i);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%histogram equalization and preparation for use%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=ceil(mod((x*100000),image_height));
y=ceil(mod((y*100000),image_height));
z=ceil(mod((z*100000),image_height));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%IMAGE INPUT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
original=Watermarkedimage_final;
rgb=original;
[row,col]=size(rgb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%INITIALIZE THE VALUE OF ROTATION%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n=500;
p=600;
q=700;
for j=1:1:row
k(j)=x(j+n);
l(j)=y(j+p);
end
% for i=1:1:row
% k(i)=x(i+n);
% end
% for j=1:1:col
% l(j)=y(j+p);
% end
for j=1:1:col*row
m(j)=z(j+q);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% IF k is even right shift row else left shift row%%%%%%%%%%%%%%%%%
% If l is even shift up column else down shift column%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%ROTATION OPERATION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:1:row
for j=1:1:col
if(mod(k(i),2)==0)
if((j+k(i))<=col) %shift right of row
sh_row(i,j+k(i))=rgb(i,j);
row_shift_even(i,j)=j+k(i);
else
sh_row(i,(j+k(i)-col))=rgb(i,j);
row_shift_even(i,j)=(j+k(i)-col);
end
else
if((j-k(i))>=1) %shift left of row
sh_row(i,j-k(i))=rgb(i,j);
row_shift_odd(i,j)=j-k(i);
else
sh_row(i,(col+j-k(i)))=rgb(i,j);
row_shift_odd(i,j)=col+j-k(i);
end
end
end
end
for j=1:1:col
for i=1:1:row
if(mod(l(j),2)==0)
if((i-l(j))>=1) %shift up of column
sh_col(i-l(j),j)=sh_row(i,j);
col_shift_even(i,j)=i-l(j);
else
sh_col((row+i-l(j)),j)=sh_row(i,j);
col_shift_even(i,j)=row+i-l(j);
end
else
if((i+l(j))<=row) %shift down of column
sh_col(i+l(j),j)=sh_row(i,j);
col_shift_odd(i,j)=i+l(j);
else
sh_col((i+l(j)-row),j)=sh_row(i,j);
col_shift_odd(i,j)=(i+l(j)-row);
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%XOR IMAGE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
total_length=row*col;
column_image=reshape(sh_col,1,total_length);
for i=1:1:total_length
xorr1(1,i)=bitxor(column_image(i),m(j));
end
y=reshape(xorr1,row,col);
imwrite(y, 'encypted_peppers.jpg', 'Quality', 100);
figure
subplot(3,2,1)
imshow(rgb)
title('Original Image');
subplot(3,2,2)
imhist(rgb)
title('Histogram of original Image');
subplot(3,2,3)
imshow(y)
title('Encrypted Image');
subplot(3,2,4)
imhist(y)
title('Histogram of Encrypted Image');
[row,col]=size(y);
rgb=y;
total_length=row*col;
column_image=reshape(rgb,1,total_length);
for i=1:1:total_length
xorr1(1,i)=bitxor(column_image(i),m(j));
end
shuffled_image=reshape(xorr1,row,col);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% IF k is even right shift row else left shift row%%%%%%%%%%%%%%%%%
% If l is even shift up column else down shift column%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%ROTATION OPERATION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%ROW SHIFTING%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j=1:1:col
for i=1:1:row
if(mod(l(j),2)==0)
if((i+l(j))<=row) %shift down of column
sh_col(i+l(j),j)=shuffled_image(i,j);
col_shift_even(i,j)=i+l(j);
else
sh_col((i+l(j)-row),j)=shuffled_image(i,j);
col_shift_even(i,j)=(i+l(j)-row);
end
else
if((i-l(j))>=1) %shift up of column
sh_col(i-l(j),j)=shuffled_image(i,j);
col_shift_odd(i,j)=i-l(j);
else
sh_col((row+i-l(j)),j)=shuffled_image(i,j);
col_shift_odd(i,j)=row+i-l(j);
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:1:row
for j=1:1:col
if(mod(k(i),2)==0)
if((j-k(i))>=1) %shift left of row
sh_row(i,j-k(i))=sh_col(i,j);
row_shift_even(i,j)=j-k(i);
else
sh_row(i,(col+j-k(i)))=sh_col(i,j);
row_shift_even(i,j)=col+j-k(i);
end
else
if((j+k(i))<=col) %shift right of row
sh_row(i,j+k(i))=sh_col(i,j);
row_shift_even(i,j)=j+k(i);
else
sh_row(i,(j+k(i)-col))=sh_col(i,j);
row_shift_even(i,j)=(j+k(i)-col);
end
end
end
end
subplot(3,2,5)
imshow (sh_row)
title('decrypted image');
subplot(3,2,6)
imhist(sh_row)
title('histogram decrypted image');
imwrite(sh_row, 'Decrypted image.jpg', 'Quality', 100);
[F11,F22]= wfilters('haar', 'd');
[a b c d]=dwt2(sh_row,'haar','d');
[U3,S3,V3]= svd(a);
for i=1:x
for j=1:y
recov_image(i,j)=(S3(i,j)-S1_temp(i,j))/alfa;
end
end
ewatr = U2*recov_image*V2';
recovered_image=ewatr;
recovered_image_final=idwt2(recovered_image,L_H,H_L,H_H,'haar');
recovered_image_final=uint8(recovered_image_final);
figure(5);imshow(recovered_image_final);
title('extracted watermark')
  4 commentaires
Suniti Singh
Suniti Singh le 19 Mai 2022
sir i am getting the error as below:
Colon operands must be real scalars.
Error in Untitled (line 247)
for j=1:y

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 19 Mai 2022
for i=1:1:70000
x(i+1)=l*x(i)*(1-x(i))+b*y(i)*y(i)*x(i)+a*z(i)*z(i)*z(i);
y(i+1)=l*y(i)*(1-y(i))+b*z(i)*z(i)*y(i)+a*x(i)*x(i)*x(i);
x and y are long vectors
x=ceil(mod((x*100000),image_height));
y=ceil(mod((y*100000),image_height));
vector operations so x and y are still vectors after. The values are integers.
y=reshape(xorr1,row,col);
y is now a 2d image not related to its previous value
for i=1:x
for j=1:y
x is still a vector of integers, and matlab treats the first as 1:x(1). But y is a 2d array of non-integers
Perhaps you wanted to iterate over rows and columns?
  1 commentaire
Suniti Singh
Suniti Singh le 19 Mai 2022
Actually after decryption I want to extract the watermark from marked image at receiver end but getting this error.

Connectez-vous pour commenter.

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by