Image hidding using DWT
Hello every one
I am finding a problime in my code for hidding 325*325 image into 2300*2300 image after decompose it using into HH{3} to get the best PSNR and MSE
and the erroe say that the matrix in not matching.
the code is as follow:-
% Main code
clc
close all;
clear all;
%
a=imgetfile();
coverImage1 = imread(a);
coverImages = imresize(coverImage1,[2600 2600]);
R=coverImages(:,:,1); %red = 1, green = 2, blue = 3
G=coverImages(:,:,2);
B=coverImages(:,:,3);
coverImage=B;
% figure;
% imshow(coverImage);
% title(‘Blue Image’);
%%%%%
b=imgetfile();
secretImage1 = imread(b);
%secretImage=B1;
secretImage= rgb2gray(secretImage1);
secretImage = imresize(secretImage,[1300 1300]);
row = size(secretImage,1);
col = size(secretImage,2);
s = row*col;
%secretImage = imresize(secretImage,[280 280]);
% figure(1); imshow (coverImages)
% figure(2); imshow (secretImage)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Perform DNA encryption on the secret image
key = randi([0, 255], size(secretImage)); % Generate random key
encryptedImage = DNAEncrypt(secretImage, key);
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nColors = 256;
n =3 ; %# Number of decompositions
LL = cell(1,n); %# Approximation coefficient storage
LH = cell(1,n); %# Horizontal detail coefficient storage
HL = cell(1,n); %# Vertical detail coefficient storage
HH = cell(1,n); %# Diagonal detail coefficient storage
X = coverImage ;
for i = 1:n %# %# Apply nLevel decompositions
[LL{i},LH{i},HL{i},HH{i}] = dwt2(X,’Haar’);
X = LL{i}; % gives you the last quarter of the image
end
%coverImage = LL{i}; % gives you the last quarter of the image
%alpha = 0.02; % Embedding strength
OO= HH{1}; OOO = HH{2}; OOOO=HH{3};% here I want to get the need HH{1,2,3} for the good hidding
%%
HH_embedded = HH{1} + ( encryptedImage);
stegoImage = idwt2(LL{i}, LH{i}, HL{i}, HH_embedded, ‘haar’);
imshow(uint8(stegoImage));
% %%
% tiledImage = wcodemat(LL{n},nColors);
% for i = n:-1:1
% tiledImage = cat(1,cat(2,tiledImage,…
% wcodemat(LH{i},nColors)),…
% cat(2,wcodemat(HL{i},nColors),…
% wcodemat(HH{i},nColors)));
% end
% figure(1);imshow(uint8(tiledImage-1));
%%
B2=uint8(stegoImage);
RGB= cat(3, R, G, B2);
stg= double(im2gray(RGB));
% figure (5)
% subplot(1, 2, 1);
% imshow(RGB);
% title(‘RGB after Analysis’);
%%%%
% Display the stego image
figure;
subplot(1, 2, 1);
imshow(coverImages);
title(‘Cover Image’);
subplot(1, 2, 2);
imshow(RGB);
title(‘Stego Image’);
%%%%%%%%%%%%%
%TT = immse(stg, double(coverImage));
mse = sum(sum((coverImage – uint8(stg)) .^ 2)) / numel(coverImage);
% Display the MSE
fprintf(‘Mean Squared Error (MSE): %.4fn’, mse);
%CC = mse(stgcoverImage);
C = psnr((uint8(stg)),coverImage);
%fprintf(‘n The Mean Sq. Erorr value is %0.4f’, CC );
fprintf(‘n PSNR value is %0.6f’, C);
%%
%
I will write the code here and provide you the images, hope to get it downHello every one
I am finding a problime in my code for hidding 325*325 image into 2300*2300 image after decompose it using into HH{3} to get the best PSNR and MSE
and the erroe say that the matrix in not matching.
the code is as follow:-
% Main code
clc
close all;
clear all;
%
a=imgetfile();
coverImage1 = imread(a);
coverImages = imresize(coverImage1,[2600 2600]);
R=coverImages(:,:,1); %red = 1, green = 2, blue = 3
G=coverImages(:,:,2);
B=coverImages(:,:,3);
coverImage=B;
% figure;
% imshow(coverImage);
% title(‘Blue Image’);
%%%%%
b=imgetfile();
secretImage1 = imread(b);
%secretImage=B1;
secretImage= rgb2gray(secretImage1);
secretImage = imresize(secretImage,[1300 1300]);
row = size(secretImage,1);
col = size(secretImage,2);
s = row*col;
%secretImage = imresize(secretImage,[280 280]);
% figure(1); imshow (coverImages)
% figure(2); imshow (secretImage)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Perform DNA encryption on the secret image
key = randi([0, 255], size(secretImage)); % Generate random key
encryptedImage = DNAEncrypt(secretImage, key);
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nColors = 256;
n =3 ; %# Number of decompositions
LL = cell(1,n); %# Approximation coefficient storage
LH = cell(1,n); %# Horizontal detail coefficient storage
HL = cell(1,n); %# Vertical detail coefficient storage
HH = cell(1,n); %# Diagonal detail coefficient storage
X = coverImage ;
for i = 1:n %# %# Apply nLevel decompositions
[LL{i},LH{i},HL{i},HH{i}] = dwt2(X,’Haar’);
X = LL{i}; % gives you the last quarter of the image
end
%coverImage = LL{i}; % gives you the last quarter of the image
%alpha = 0.02; % Embedding strength
OO= HH{1}; OOO = HH{2}; OOOO=HH{3};% here I want to get the need HH{1,2,3} for the good hidding
%%
HH_embedded = HH{1} + ( encryptedImage);
stegoImage = idwt2(LL{i}, LH{i}, HL{i}, HH_embedded, ‘haar’);
imshow(uint8(stegoImage));
% %%
% tiledImage = wcodemat(LL{n},nColors);
% for i = n:-1:1
% tiledImage = cat(1,cat(2,tiledImage,…
% wcodemat(LH{i},nColors)),…
% cat(2,wcodemat(HL{i},nColors),…
% wcodemat(HH{i},nColors)));
% end
% figure(1);imshow(uint8(tiledImage-1));
%%
B2=uint8(stegoImage);
RGB= cat(3, R, G, B2);
stg= double(im2gray(RGB));
% figure (5)
% subplot(1, 2, 1);
% imshow(RGB);
% title(‘RGB after Analysis’);
%%%%
% Display the stego image
figure;
subplot(1, 2, 1);
imshow(coverImages);
title(‘Cover Image’);
subplot(1, 2, 2);
imshow(RGB);
title(‘Stego Image’);
%%%%%%%%%%%%%
%TT = immse(stg, double(coverImage));
mse = sum(sum((coverImage – uint8(stg)) .^ 2)) / numel(coverImage);
% Display the MSE
fprintf(‘Mean Squared Error (MSE): %.4fn’, mse);
%CC = mse(stgcoverImage);
C = psnr((uint8(stg)),coverImage);
%fprintf(‘n The Mean Sq. Erorr value is %0.4f’, CC );
fprintf(‘n PSNR value is %0.6f’, C);
%%
%
I will write the code here and provide you the images, hope to get it down Hello every one
I am finding a problime in my code for hidding 325*325 image into 2300*2300 image after decompose it using into HH{3} to get the best PSNR and MSE
and the erroe say that the matrix in not matching.
the code is as follow:-
% Main code
clc
close all;
clear all;
%
a=imgetfile();
coverImage1 = imread(a);
coverImages = imresize(coverImage1,[2600 2600]);
R=coverImages(:,:,1); %red = 1, green = 2, blue = 3
G=coverImages(:,:,2);
B=coverImages(:,:,3);
coverImage=B;
% figure;
% imshow(coverImage);
% title(‘Blue Image’);
%%%%%
b=imgetfile();
secretImage1 = imread(b);
%secretImage=B1;
secretImage= rgb2gray(secretImage1);
secretImage = imresize(secretImage,[1300 1300]);
row = size(secretImage,1);
col = size(secretImage,2);
s = row*col;
%secretImage = imresize(secretImage,[280 280]);
% figure(1); imshow (coverImages)
% figure(2); imshow (secretImage)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Perform DNA encryption on the secret image
key = randi([0, 255], size(secretImage)); % Generate random key
encryptedImage = DNAEncrypt(secretImage, key);
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nColors = 256;
n =3 ; %# Number of decompositions
LL = cell(1,n); %# Approximation coefficient storage
LH = cell(1,n); %# Horizontal detail coefficient storage
HL = cell(1,n); %# Vertical detail coefficient storage
HH = cell(1,n); %# Diagonal detail coefficient storage
X = coverImage ;
for i = 1:n %# %# Apply nLevel decompositions
[LL{i},LH{i},HL{i},HH{i}] = dwt2(X,’Haar’);
X = LL{i}; % gives you the last quarter of the image
end
%coverImage = LL{i}; % gives you the last quarter of the image
%alpha = 0.02; % Embedding strength
OO= HH{1}; OOO = HH{2}; OOOO=HH{3};% here I want to get the need HH{1,2,3} for the good hidding
%%
HH_embedded = HH{1} + ( encryptedImage);
stegoImage = idwt2(LL{i}, LH{i}, HL{i}, HH_embedded, ‘haar’);
imshow(uint8(stegoImage));
% %%
% tiledImage = wcodemat(LL{n},nColors);
% for i = n:-1:1
% tiledImage = cat(1,cat(2,tiledImage,…
% wcodemat(LH{i},nColors)),…
% cat(2,wcodemat(HL{i},nColors),…
% wcodemat(HH{i},nColors)));
% end
% figure(1);imshow(uint8(tiledImage-1));
%%
B2=uint8(stegoImage);
RGB= cat(3, R, G, B2);
stg= double(im2gray(RGB));
% figure (5)
% subplot(1, 2, 1);
% imshow(RGB);
% title(‘RGB after Analysis’);
%%%%
% Display the stego image
figure;
subplot(1, 2, 1);
imshow(coverImages);
title(‘Cover Image’);
subplot(1, 2, 2);
imshow(RGB);
title(‘Stego Image’);
%%%%%%%%%%%%%
%TT = immse(stg, double(coverImage));
mse = sum(sum((coverImage – uint8(stg)) .^ 2)) / numel(coverImage);
% Display the MSE
fprintf(‘Mean Squared Error (MSE): %.4fn’, mse);
%CC = mse(stgcoverImage);
C = psnr((uint8(stg)),coverImage);
%fprintf(‘n The Mean Sq. Erorr value is %0.4f’, CC );
fprintf(‘n PSNR value is %0.6f’, C);
%%
%
I will write the code here and provide you the images, hope to get it down dwt, image processing MATLAB Answers — New Questions