How to do block based watermarking using random numbers?

1 visualización (últimos 30 días)
APARNA
APARNA el 17 de Mzo. de 2014
Comentada: APARNA el 18 de Mzo. de 2014
I have transformed a 256x256 cover image into DCT and then, to DWT. The LL size 128x128) of the DWT image is taken and divided into 32x32 blocks using mat2cell(). Same procedure I did for the watermark also of the same size. Then, I took the SVD of one block of the watermark. The diagonal values of the block of watermark is multiplied by the strength factor and added at the block of the cover image randomly. For that I produced random numbers from 1 to 32 for x and y position. But, I did not get the desired result. The code is given below. Is any thing wrong in that code or is it not the correct way to embed??
clc
clear all
k = 0.0025; %Strength factor
covImage = imread('lena.jpg'); %Read the cover image
covImage_res = imresize(covImage,[256 256]);
Image_ycbcr=rgb2ycbcr(covImage_res);
I=Image_ycbcr(:,:,1);
input_img=I;
I_dct=dct2(input_img);
[LL,LH,HL,HH] = dwt2(I_dct,'haar','mode','sym'); % applying redundant DWT
blockSizeR = 32; % Rows in block.
blockSizeC = 32;
[rows columns numberOfColorBands] = size(LL);
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
ca1 = mat2cell(LL, blockVectorR, blockVectorC, numberOfColorBands);
Wat_img=imread('same.jpg');
Watermark=imresize(Wat_img,[256 256]);
Watermark_ycbcr=rgb2ycbcr(Watermark);
W=Watermark_ycbcr(:,:,1);
water_img=W;
W_dct=dct2(water_img);
[WLL,WLH,WHL,WHH] = dwt2(W_dct,'haar','mode','sym'); % applying redundant DWT
blockSizeRW = 32; % Rows in block.
blockSizeCW = 32;
[wrows wcolumns wnumberOfColorBands] = size(WLL);
wholeBlockRowsw = floor(wrows / blockSizeRW);
blockVectorRW = [blockSizeRW * ones(1, wholeBlockRowsw), rem(wrows, blockSizeRW)];
wholeBlockColsw = floor(wcolumns / blockSizeCW);
blockVectorCW = [blockSizeCW * ones(1, wholeBlockColsw), rem(wcolumns, blockSizeCW)];
ca2 = mat2cell(WLL, blockVectorRW, blockVectorCW, wnumberOfColorBands);
temp=cell(4,4);
fid = fopen( 'ran.txt', 'wt' );%File for writing random numbers
%ca=ca1;
for a=1:32
x=randi([1 32]);
fprintf( fid, '%d\t', x);
y=randi([1 32]);
fprintf( fid, '%d\n', y);
for i=1:4
for j=1:4
[Wu,Ws,Wv]=svd(ca2{i,j});
ca=ca1{i,j};
for m=1:32
for n=1:32
ca(x,y)=ca(x,y)+(k*Ws(m,m));
%for p=1:4
%for q=1:4
temp{i,j}=ca;
%end
%end
end
end
end
end
end
fclose(fid);
c=cell2mat(temp);
%figure,imshow(c);
new_img = idwt2(c,LH,HL,HH,'haar','mode','sym');
Wmkd=idct2(new_img);
%figure,imshow(Wmkd);
Image_ycbcr(:,:,1)=uint8(Wmkd);
Watermarked=ycbcr2rgb(Image_ycbcr);
figure,imshow(Watermarked);
new=covImage_res-Watermarked;
figure,imshow(new);
  2 comentarios
Walter Roberson
Walter Roberson el 17 de Mzo. de 2014
What do you observe that leads you to conclude that you did not get the desired result ?
APARNA
APARNA el 18 de Mzo. de 2014
When I check the matrix values, the pixel positions at which the watermark was embedded, are same after and before the process. But, the resultant watermarked image shows that the watermark is embedded, but not in the position of the random numbers.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Denoising and Compression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by