Embedding watermark in the color image.

3 views (last 30 days)
Balkar Singh
Balkar Singh on 19 May 2020
Commented: Balkar Singh on 19 May 2020
I am trying to embed a watermark image into the cover image, but during the reconstructing time the image is not visible.Code is given below and images are attached in the attachment.
RGB1=imread('Marksheet1.png');
RGB1=double(imresize(RGB1, [256 256]));
RGB2=imread('logo1.png');
RGB2=double(imresize(RGB2, [256 256]));
R1 = RGB1(:,:,1);
G1 = RGB1(:,:,2);
B1 = RGB1(:,:,3);
Y1 = 0.299 * R1 + 0.587 * G1 + 0.114 * B1;
U1 = -0.147 * R1 - 0.289 * G1 + 0.437 * B1;
V1 = 0.615 * R1 - 0.515 * G1 - 0.100 * B1;
YUV1=cat(3,Y1,U1,V1);
R2 = RGB2(:,:,1);
G2 = RGB2(:,:,2);
B2 = RGB2(:,:,3);
Y2 = 0.299 * R2 + 0.587 * G2 + 0.114 * B2;
U2 = -0.147 * R2 - 0.289 * G2 + 0.437 * B2;
V2 = 0.615 * R2 - 0.515 * G2 - 0.100 * B2;
YUV2=cat(3,Y2,U2,V2);
imshow(YUV2);
Factor = 8;
Q = zeros(8,8);
for i = 1:8
for j = 1:8
Q(i,j) = 1+(i+j)*Factor;
end
end
Y1_new=f1(Y1,Y2,Q);
U1_new=f1(U1,U2,Q);
V1_new=f1(V1,V2,Q);
R1 = Y1_new + 1.140 * V1_new;
G1 = Y1_new -0.394 * U1_new -0.581 * V1_new;
B1 = Y1_new + 2.028 * U1_new;
RGB_wat = cat(3,R1,G1,B1);
imwrite(uint8(RGB_wat),'RGB_watermarked.png');
a=imread('RGB_watermarked.png');
imshow(uint8(a))
Function f1 is given below
function [output]=f1(data,watermark,Q)
blksize=[8,8];
blk1 = our_blkproc(data,blksize);
blk2 = our_blkproc(watermark,blksize);
dct_img = zeros(8,8,size(blk1,3));
for i=1:size(blk1,3)
dct_img(:,:,i) = dct2(blk1(:,:,i));
end
dct_wat = zeros(8,8,size(blk2,3));
for j=1:size(blk2,3)
dct_wat(:,:,j) = dct2(blk2(:,:,j));
end
img_mat = zeros(8,8,size(blk1,3));
for j=1:size(blk1,3)
img_mat(:,:,j) = blk1(:,:,j)/Q;
end
wat_mat = zeros(8,8,size(blk2,3));
for k=1:size(blk2,3)
wat_mat(:,:,k) = blk2(:,:,k)/Q;
end
t = 0.98;
image_wat = (1-t)*wat_mat + t*img_mat;
image_old = zeros(8,8,size(image_wat,3));
for j=1:size(image_wat,3)
image_old(:,:,j) = (image_wat(:,:,j)*Q);
end
dct_inv = zeros(8,8,size(image_old,3));
for i=1:size(image_old,3)
dct_inv(:,:,i) = idct2(image_old(:,:,i));
end
output = our_blkproc_rev(dct_inv);

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!