I need to implement 3 LSB watermarking without using the existing functions in MATLAB.
I need my function to get 2 images, both gray-level, and preform watermarking using 3 LSB.
I tried the following, but the result of the original image subtracted from the new image is all zeros which means they are the same.
function [C] = Q2(image,watermark)
% clc;
% image=imread('moon.tif');
% watermark=imread('cameraman.tif');
[X,Y] = size(image);
rewatermark = imresize(watermark,[X,Y]); % resizing watermark to fit image
% iterate the 3 LSB of the watermark and set them to a copy of the original
% image 3 LSB
C = image;
for i = 1:X
for j = 1:Y
for k = 1:3
if(bitget(rewatermark(i,j),k) == 1)
bitset(C(i,j),k,1);
else
bitset(C(i,j),k,0);
end
end
end
end
subplot(1,3,1)
imshow(image);
title('Original');
subplot(1,3,2);
imshow(rewatermark)
title('Watermark');
subplot(1,3,3)
imshow(C)
title('Invisble watermarked');
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
set(gcf,'name','Q2 - Results','numbertitle','off')