Need a help in this code
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Karbala'a Unvi. Science
 el 18 de Oct. de 2019
  
    
    
    
    
    Editada: Karbala'a Unvi. Science
 el 19 de Oct. de 2019
            Hi every one,
I wrote this code trying to embed and image as a secret image in a 2nd DWT level cover image by anding the secret image directly in the 2nd HH image 
and that is working but reasambling the imag is not working with me, becouse the PSNR and MSE is giving zero and infinity and the images is attached to this Question.
 I am donig this code for a reserch for me help is need ASAP
Thanks in advance 
  the code is :
clc, clear all, close all
%reading the cover image and difene the pixels 
I = imread('67.bmp');
cover_image=I(:,:,1);
figure, imshow (cover_image);
% transforming (Cover_imag) into red chanal , later into blue chanal, to 
% detected the difference in between.
R_imag = cover_image(:,:,1);
% now detect the eyes to be the madia to cary the information
EyeDetect = vision.CascadeObjectDetector('EyePairsmall');
BB = step(EyeDetect,R_imag);
hold on
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
Y = imread('10-12.jpg');
Y1 = Y(:,:,3);
figure(4),imshow(uint8(Y1)); title('Stego image');
Y2 = imresize(Y1,[200 200]);
%% Apply the DWT on the left eye to hide the data at the HH2 level of the 
% Haar wavelet transformation  using addtion directly when detecting the left
% eye which is a croped area from the face 
   x=length(BB(:,4));
   %To detect Eyes
I2 = imcrop(R_imag,BB(x,:));
    figure,imshow(I2);
   rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
  %To detect the left 
  na1 = I2(:, 1 : floor(end/2.3));
  %figure,imshow(na1);
%%here the left eye is the croped area and we can resize the left eye image 
% and find the HH2 to make it ready for work
% converting the Left Eye into DWT and get the HH2
cc= imresize (na1,[400 400]);                     %# resize the image to be squear;
n = 256;              %# Number of values per color component
Level = 2;             %# Number of decompositions
LL = cell(1,Level);    %# Approximation coefficient storage
LH = cell(1,Level);    %# Horizontal detail coefficient storage
HL = cell(1,Level);    %# Vertical detail coefficient storage
HH = cell(1,Level);    %# Diagonal detail coefficient storage
startImage = cc;
for iLevel = 1:Level  %# Apply nLevel decompositions
  [LL{iLevel},LH{iLevel},HL{iLevel},HH{iLevel}] = dwt2(startImage,'haar');
  startImage = LL{iLevel};
end
tiledImage = wcodemat(LL{Level},n);
for iLevel = Level:-1:1
  tiledImage = cat(1,cat(2,tiledImage,...
                           wcodemat(LH{iLevel},n)),...
                     cat(2,wcodemat(HL{iLevel},n),...
                           wcodemat(HH{iLevel},n)));
end
figure;
imshow(uint8(tiledImage-1));  %# Convert to unsigned 8-bit integer to display
rr=(HH{1});
whos rr;
whos Y2
%%
rr2 = im2uint8(rr);
figure,imshow(uint8(rr2));
HH_Ori = rr2+ Y2;
figure, imshow (HH_Ori);
rr2 = HH_Ori;
imwrite(rr2,'HH_Ori.bmp')
%%%%%%% try to reconstruct the image %%%%%%%%%%%%%%%%%
HH_Ori = HH{1};
fullRecon =R_imag;
for i = n:1
  fullRecon = idwt2(LL{i},LH{i},HL{i},fullRecon,'Haar');
end
whos fullRecon
figure(112),imshow(uint8(fullRecon));
%% Now applying PSNR & MSE %%%%%%%%%%%5
[rows, columns] = size(R_imag);
squaredErrorImage = (double(R_imag) - double(fullRecon)) .^ 2;
subplot(2, 2, 1);
imshow((squaredErrorImage, []));
title('Squared Error Image');
mse = sum(sum(squaredErrorImage)) / (rows * columns);
% Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 20 * log10( (255) / mse);
% Alert user of the answer.
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR);
msgbox(message);
2 comentarios
  KALYAN ACHARJYA
      
      
 el 18 de Oct. de 2019
				
      Editada: KALYAN ACHARJYA
      
      
 el 18 de Oct. de 2019
  
			becouse the PSNR and MSE is giving zero
Check the values of image and reference image? It can be easly detect.
Respuesta aceptada
  Sulaymon Eshkabilov
      
 el 19 de Oct. de 2019
        Hi,
problem is in your loop set up:
for i = n:1  % <---- ERROR
  fullRecon = idwt2(LL{i},LH{i},HL{i},fullRecon,'Haar');
end
Good luck.
0 comentarios
Más respuestas (1)
  Karbala'a Unvi. Science
 el 19 de Oct. de 2019
        
      Editada: Karbala'a Unvi. Science
 el 19 de Oct. de 2019
  
      
      0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



