我需要在不使用 MATLAB 中现有函数的情况下实现 3 LSB 水印。
我需要我的函数来获取 2 个图像,包括灰度级和使用 3 LSB 的预制水印。
我尝试了以下方法,但是从新图像中减去原始图像的结果全为零,这意味着它们是相同的。
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')