# How to detect watermark applied on image in matlab

6 views (last 30 days)
John schwan on 6 Oct 2021
Answered: yanqi liu on 11 Oct 2021
Hi,
I am looking for a method which help me to detect watermark applied on image. The watermark I applied is using patchwork method in which I select random patches from an image half of patches I brighten and half of patches I darken.
how to detect watermarking??
I don't know how about detecting watermarking code.
I successed insert watermarking but I can't exctract watermark.
Here is my coding...
clc;
rnd_x = randperm(size(A,1)-128,7);%choose 7 random unique points on x-axis
rnd_y = randperm(size(A,2)-128,7);%choose 7 random unique points on y-axis
image(A)
for kk = 1:2
for ii = 1:4
for jj = 5:7
piece{jj} = A((rnd_x(jj):(rnd_x(jj)+127)),(rnd_y(jj):(rnd_y(jj)+127)),1:3)+1;
A((rnd_x(jj):(rnd_x(jj)+127)),(rnd_y(jj):(rnd_y(jj)+127)),1:3)= piece{jj}; % add the changed pixel values to the original image A
end
piece{ii} = A((rnd_x(ii):(rnd_x(ii)+127)),(rnd_y(ii):(rnd_y(ii)+127)),1:3)-1;%Convert chosen numbers to image pieces
A((rnd_x(ii):(rnd_x(ii)+127)),(rnd_y(ii):(rnd_y(ii)+127)),1:3)= piece{ii}; % add the changed pixel values to the original image A
end
end
Now I have required a method which helps me to detect this watermark applied on image.
DGM on 11 Oct 2021
Consider the cleanup:
% these parameters replicate the original behavior
numblocks = [3 4]; % number of [light dark] blocks
blocksize = 128;
tweakamount = [8 2]; % amount to [lighten darken]
%choose random unique points
rnd_y = randperm(size(A,1)-blocksize,sum(numblocks));
rnd_x = randperm(size(A,2)-blocksize,sum(numblocks));
% only need one loop
for jj = 1:sum(numblocks)
xrange = (rnd_x(jj):(rnd_x(jj)+blocksize-1));
yrange = (rnd_y(jj):(rnd_y(jj)+blocksize-1));
if jj <= numblocks(1)
% lighten this block
A(yrange,xrange,:) = A(yrange,xrange,:) + tweakamount(1);
else
% darken this block
A(yrange,xrange,:) = A(yrange,xrange,:) - tweakamount(2);
end
end
imshow(A)
I don't even know about trying to detect this. I spent my curiosity just doing this much.

Image Analyst on 11 Oct 2021
Not that I know of. If you're just brightening random patches of the image by one gray level, it's not really noticeable - it could be a totally legitimate/unaltered image. The only way I know of is if you have the original image to compare it with (subtract it). But it you don't have the original, I'm not sure how you'd find the random patches that are one gray level brighter.

yanqi liu on 11 Oct 2021
sir, may be use some decompose method，such as svd、dwt、dct and so on，and use logistics to gen location to make watermark R2015a

### Community Treasure Hunt

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

Start Hunting!