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 Center および File ExchangeEigenvalues についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by