Watermarking in the Frequency Domain
Show older comments
I am new in Matlab and I have an assignment that is asking for watermarking an image using DCT transform:
- Read Lin.jpg color image and apply DCT.
- Threshold the logo.jpg (watermark) into binary and ten times of its strength, and then add it to the coefficient of transformed Lin image.
Here are the two images:

I have three questions:
- Am I supposed to divide Lin.jpg into 8x8 blocks and logo.jpg into 2x2 blocks or that is not necessary?
- what does it mean by : "ten times of its strength"? Is that just multiplying by 10?
- How can I get the coefficient of transformed Lin.jpg image?
Here is what I tried:
img = imread('Lin.jpg');
wImg = imread('njit_logo.jpg');
wImgBinary = imbinarize(wImg) * 10;
[rows, cols] = size(img(:,:,1));
[Wrows, Wcols] = size(wImgBinary);
% make the watermark image as large as the original
watermark = zeros(size(img), 'uint8');
for column = 1:cols
for row = 1:rows
watermark(row, column) = wImgBinary(mod(row,Wrows)+1, mod(column,Wcols)+1);
end
end
watermark = watermark(1:rows, 1:cols);
% apply dct and add with watermark at each channel
for i = 1:3
imgDct = dct2(img(:,:,i));
C = imgDct + double(watermark);
Iw(:,:,i) = round(real(idct2(C)));
end
IIw = uint8(Iw);
figure, imshow(IIw), title('watermarked image');
9 Comments
Walter Roberson
on 11 Nov 2020
I would tend to think the ten times would be multiplying the binary (0, 1) by 10, getting either 0 or 10.
wImgDct = dct2(wImgBinary);
That is not asked for. Just add the wImgBinary to imgDct .
Hadi Ghahremannezhad
on 11 Nov 2020
Walter Roberson
on 11 Nov 2020
The watermarked image does differ from the original. Do
imshowpair(IIw, img)
and
imshowpair(IIw, img, 'diff')
Hadi Ghahremannezhad
on 12 Nov 2020
Jevan Watson
on 12 Nov 2020
Hadi if you look when you do the side by side it kind of looks like his note in HW4R in the top left, so I think its strange to us but correct. Have you figured out the inverse or part B?
Hadi Ghahremannezhad
on 12 Nov 2020
Jevan Watson
on 12 Nov 2020
So wait because he confuses me too... isn't idct supposed to be one of the five images in part A too? or does part B provide the last 2 images he asked for in A. Because in the above I didn't notice where you did the inverse dct on Lin
Hadi Ghahremannezhad
on 12 Nov 2020
Answers (0)
Categories
Find more on Watermarking in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!