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');


