how to recoup a watermark image !

1 view (last 30 days)
Ess Ma
Ess Ma on 29 Dec 2021
Edited: DGM on 29 Dec 2021
clear all; close all; clc;
mat=imread('cameraman.tif');
watermark=imread('cameraman.tif');%% watermark
B2=im2bw(watermark);%% watermark en binair
Marque_V=B2(:);%% vecteur
bitplandepth=1
matW = Wnsrtion(mat,Marque_V,bitplandepth);%% insertion dans mat
subplot(1,2,1)
imshow(mat)
title('image original')
subplot(1,2,2)
imshow(matW)
title('image tatouée')
t=all(all(mat==matW))
psnr =calcul_psnr(mat,matW)
%%extraction
Lbits=length(Marque_V);
Marque_V_recup = extractw( matW,bitplandepth,Lbits );
the function "Wnsrtion()"
function [matW ] = Wnsrtion(mat,Marque_V,bitplandepth)
[L,C]=size(mat)
matv=mat(:);
matvW=matv;
bitplan=1
for i=1:length(Marque_V)
matvW(i)=bitset(matv(i),bitplan,Marque_V(i));
end
matW=reshape(matvW,[C,L]);
end
the function "extractw()"
function [Marque_V_recup] = extractw( matW,bitplandepth,Lbits )
[n,m]=size(matW);
pitplandepth=1;
matV=matW(:);
for i=1:Lbits
Marque_V_recup(i) =bitget(matV(i),bitplandepth);
end
  1 Comment
DGM
DGM on 29 Dec 2021
It may be safe to assume that this is some form of LSB watermarking, but without knowing how the data is being manipulated, it's not possible to instruct how the process should be reversed.
Nobody can guess precisely what the user-defined functions Wnsrtion() and extractw() do, so unless you provide that information, the implied question is not answerable.

Sign in to comment.

Accepted Answer

DGM
DGM on 29 Dec 2021
Edited: DGM on 29 Dec 2021
Try this.
mat = imread('cameraman.tif'); % host image
watermark = imread('cameraman.tif'); % payload image
B2 = im2bw(watermark); % watermark en binair
Marque_V = B2(:); % vecteur
bitplandepth = 1;
matW = Wnsrtion(mat,Marque_V,bitplandepth); % insertion dans mat
subplot(1,2,1)
imshow(mat)
title('image original')
subplot(1,2,2)
imshow(matW)
title('image tatouée')
%t = all(all(mat==matW))
%psnr = calcul_psnr(mat,matW)
Lbits = numel(Marque_V);
Marque_V_recup = extractw(matW,bitplandepth,Lbits);
arraysaresame = all(Marque_V == Marque_V_recup) % vectors are equal
% if you want to reshape it into a 2D image
B2_recovered = reshape(Marque_V_recup,size(B2));
function [mat] = Wnsrtion(mat,Marque_V,bitplandepth)
nel = numel(Marque_V);
samp = mat(1:nel);
mat(1:nel) = bitset(samp(:),bitplandepth,Marque_V(:));
end
function [Marque_V_recup] = extractw(matW,bitplandepth,Lbits)
Marque_V_recup = logical(bitget(matW(1:Lbits),bitplandepth));
Marque_V_recup = Marque_V_recup(:);
end

More Answers (0)

Products


Release

R2011a

Community Treasure Hunt

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

Start Hunting!