I have a problem with the watermark in the svd image. The NC value does not change. When extracting the protected image, it appears black, which means that there is a problem

2 次查看(过去 30 天)
orig_img = imread('C:\Users\info\Desktop\dfd\foto\1.tif');
watermark_img = imread('C:\Users\info\Desktop\dfd\foto\3.png');
if size(orig_img, 3) == 3
orig_img = rgb2gray(orig_img); end
if size(watermark_img, 3) == 3
watermark_img = rgb2gray(watermark_img); end
orig_img = im2double(orig_img); watermark_img = im2double(watermark_img);
watermark_img_resized = imresize(watermark_img, size(orig_img));
alpha = 0.03;
[U,S,V] = svd(orig_img);
watermarked_img = U*(S + alpha*watermark_img_resized)*V';
[Uw,Sw,Vw] = svd(watermarked_img);
extracted_watermark = (Sw - S)/alpha;
psnr = 10*log10(1/mean((orig_img(:)-watermarked_img(:)).^2));
nc =sum(extracted_watermark(:).*watermark_img_resized(:))/sqrt(sum(extracted_watermark(:).^2)*sum(watermark_img_resized(:).^2));
figure;
subplot(2,2,1); imshow(orig_img); title('Original Image');
subplot(2,2,2); imshow(watermark_img); title('Watermark Image');
subplot(2,2,3); imshow(watermarked_img); title('Watermarked Image');
subplot(2,2,4); imshow(extracted_watermark); title('Extracted Watermark');
disp(['PSNR = ', num2str(psnr)]);
disp(['NC = ', num2str(nc)]);

回答(1 个)

Gayathri
Gayathri 2024-8-12
编辑:Gayathri 2024-8-12
I was able to reproduce your issue. The issue is happening because the watermarked image is not being generated properly.
watermarked_img = U*(S + alpha*watermark_img_resized)*V';
The SVD of “watermark_img_resized” image should also be calculated and then the singular vectors should be used to generate the watermarked image.Correspondingly, extract the image back from the watermarked image. As this issue is solved, “nc” parameter will also change.
You can find below the Code Snippet for your reference.
[U,S,V] = svd(orig_img);
[U1,S1,V1] = svd(watermark_img_resized);
watermarked_img = U*(S + alpha*S1)*V';
[Uw,Sw,Vw] = svd(watermarked_img);
extracted_watermark =U1*((Sw - S)/alpha)*V1';
Hope you find this information useful and resolves the issue.
  1 个评论
DGM
DGM 2024-8-12
For example:
orig_img = imread('cameraman.tif');
watermark_img = fliplr(orig_img);
if size(orig_img, 3) == 3
orig_img = rgb2gray(orig_img);
end
if size(watermark_img, 3) == 3
watermark_img = rgb2gray(watermark_img);
end
orig_img = im2double(orig_img);
watermark_img = im2double(watermark_img);
watermark_img_resized = imresize(watermark_img, size(orig_img));
alpha = 0.03;
% --->
[U,S,V] = svd(orig_img);
[U1,S1,V1] = svd(watermark_img_resized);
watermarked_img = U*(S + alpha*S1)*V';
[Uw,Sw,Vw] = svd(watermarked_img);
extracted_watermark =U1*((Sw - S)/alpha)*V1';
% <---
psnr = 10*log10(1/mean((orig_img(:)-watermarked_img(:)).^2));
nc = sum(extracted_watermark(:).*watermark_img_resized(:))/sqrt(sum(extracted_watermark(:).^2)*sum(watermark_img_resized(:).^2));
subplot(2,2,1); imshow(orig_img); title('Original Image');
subplot(2,2,2); imshow(watermark_img); title('Watermark Image');
subplot(2,2,3); imshow(watermarked_img); title('Watermarked Image');
subplot(2,2,4); imshow(extracted_watermark); title('Extracted Watermark');
disp(['PSNR = ', num2str(psnr)]);
PSNR = 36.04
disp(['NC = ', num2str(nc)]);
NC = 1

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Eigenvalues 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by