Azzera filtri
Azzera filtri

Karhunen-Loeve Transform for watermarking

4 visualizzazioni (ultimi 30 giorni)
Emile Van Vaerenbergh
Emile Van Vaerenbergh il 12 Dic 2022
Risposto: Harsh Sanghai il 23 Mar 2023
Does someone have any code for digital watermarking using the KLT transform? Any help would be welcome!

Risposte (1)

Harsh Sanghai
Harsh Sanghai il 23 Mar 2023
Hi,
Here is a sample code which you can use for digital watermarking using KLT transform in using MATLAB:
% Read the original image
I = imread('original_image.jpg');
% Convert the image to grayscale
I_gray = rgb2gray(I);
% Generate the watermark image
W = rand(size(I_gray)) > 0.5;
% Perform KLT transform on the original image
C = dct2(I_gray);
% Calculate the covariance matrix
R = cov(C);
% Calculate the eigenvalues and eigenvectors
[V,D] = eig(R);
% Sort the eigenvalues in descending order
[~,ind] = sort(diag(D),'descend');
V = V(:,ind);
% Use the first N eigenvectors to embed the watermark
N = 5;
W_embedded = C + 0.1*W.*repmat(V(:,1:N)*V(:,1:N)',size(C,1),size(C,2));
% Perform inverse KLT transform
I_watermarked = idct2(W_embedded);
% Display the original and watermarked images
figure;imshow(I_gray);title('Original Image');
figure;imshow(I_watermarked);title('Watermarked Image');

Community Treasure Hunt

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

Start Hunting!

Translated by