I need the MATLAB and VHDL code for image steganography using LSB substitution and DWT. Plz suggest the code.

2 views (last 30 days)
Program to Implement stegnography using Wavelet Decomposition
clc;
close all;
clear all;
tic
img = imread('D:/images/rice.png');
%img = rgb2gray(img);
img=imresize(img,[300 300]);
img = double(img);
c = 0.003; % Initialise the weight of stegnography
subplot(221);imshow(uint8(img)),title('Original Image');
[p q] = size(img);
p1=p;
q1=q;
%Generate the key
n = imread('D:/images/testpat1.png');
key = imresize(double(n),[p q]);
subplot(222); imshow(uint8(key)),title('Key');
[ca,ch,cv,cd] = dwt2(img,'db1'); % Compute 2D wavelet transform
%Perform the encryption
y = [ca ch;cv cd];
Y = y + c*key;
p=p/2;q=q/2;
for i=1:p
for j=1:q
nca(i,j) = Y(i,j);
ncv(i,j) = Y(i+p,j);
nch(i,j) = Y(i,j+q);
ncd(i,j) = Y (i+p,j+q);
end
end
%Display the stego image
wimg = idwt2(nca,nch,ncv,ncd,'db1');
subplot(223); imshow(uint8(wimg)),title('stego Image');
%Extraction of key from stego image
[rca,rch,rcv,rcd] = dwt2(wimg,'db1');% Compute 2D wavelet transform
n1=[rca,rch;rcv,rcd];
N1=n1-y;
subplot(224); imshow(double(N1));
%%%%Calculating PSNR & MSE
origImg = double(img);
stegoImg = double(n);
[M N] = size(origImg);
stegoImg1=imresize(stegoImg,[M N]);
error = origImg - stegoImg1;
MSE = sum(sum(error .* error)) / (M * N);
if(MSE > 0)
PSNR = (10*log(255*255/MSE)) / log(10);
else
PSNR = 99;
end
PSNR1 = PSNR
MSE1 = MSE
% disp(PSNR)
% disp(MSE)
%
%%%%Normalisation of stego image
stego=double(n)./255;
% psnrop=psnr(N1,key)
title('Extracted key from stego image')
toc
  3 Comments
Suchita Singh
Suchita Singh on 9 Feb 2016
When I implemented this code, the error mentioned below occured.Kindly help me with that.
Error using dwt2 Too many input arguments.
Error in three (line 18) [ca,ch,cv,cd] = dwt2(img,'db1'); % Compute 2D wavelet transform

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 11 Jan 2016
You are going to need the HDL Coder toolbox to general VHDL. You are going to need Fixed Point Designer to generate the arithmetic. You will probably need to implement dtw2 as a pair of dwt calls.
It takes a lot of space on VHDL to generate a floating point core, so it is seldom done; rewriting in terms of fixed point values is done instead. You need to do a numeric analysis to determine what range of values you need to support and thus how many bits of fixed point word you need. The fewer bits of fixed point you can get away with, the less space it takes in VHDL.
Note: HDL Coder is available only to Professional / Commercial, and Academic licenses, and not to Student Version licenses.

Products

Community Treasure Hunt

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

Start Hunting!