Error in extracting watermark in DCT domain

1 view (last 30 days)
Hello everyone I am working on a watermarking project in the DCT domain , The embedding process seems to be good, but the extraction fails, I think the problem in scaling values . Because of subtracting and dividing. Plz help me, I do not have any time more.
Cover_image_gray=imresize(Cover_image_gray,[512 512]);
Cover_image_gray=im2double(Cover_image_gray);
figure(1)
imshow(uint8(255*Cover_image_gray)),title('Original Image');
Watermark_image_gray=imresize(Watermark_image_gray,[512 512]);
Watermark_image_gray=im2double(Watermark_image_gray);
figure(2)
imshow(uint8(255*Watermark_image_gray)),title('Watermark Image');
alpha=0.1;
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
after_dct = blockproc(Cover_image_gray,[8 8],dct);
%embedding
after_dct=after_dct+(Watermark_image_gray*alpha);
invdct = @(block_struct) T' * block_struct.data * T;
I_MIXxx = blockproc(after_dct ,[8 8],invdct);
minval=min(I_MIXxx(:));
maxval=max(I_MIXxx(:));
% I_MIXxx = (I_MIXxx- min(I_MIXxx(:))) / (max(I_MIXxx(:)) - min(I_MIXxx(:)));
I_MIXx=im2uint8(I_MIXxx);
figure(3)
imshow(I_MIXx)
%%%%%%%%%%%%
%extracting when using I_MIXxx directly it works good but I have to save
%watermarked image then attck it then extract the watermark so, the
%extraction must take input image
I_MIX2=im2double(I_MIXx);
I_MIX2 = I_MIX2- min(I_MIX2(:));
I_MIX2 = (I_MIX2/range(I_MIX2(:)))*(maxval-minval);
I_MIX2= I_MIX2 + minval;
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
Ex = blockproc(I_MIX2 ,[8 8],dct);
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
cov = blockproc(Cover_image_gray,[8 8],dct);
Ew=(Ex-cov)/alpha;
% Ew=(Ew- min(Ew(:)))/(max(Ew(:)) - min(Ew(:)));
Ew=(im2uint8(Ew));
figure(4)
imshow(Ew)

Answers (0)

Community Treasure Hunt

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

Start Hunting!