-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecoding.m
43 lines (43 loc) · 1.79 KB
/
Decoding.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Extracted_Red_Image =Steganographed_Image1/255;
Extracted_Red_Image = (im2double(Extracted_Red_Image))*255;
[n3 n4] = size(Extracted_Red_Image);
DCT_Image_Recieved = zeros(n3,n4);
for i = 1:DCT_Block_Size:n3
for j = 1:DCT_Block_Size:n4
Block_Matrix = Extracted_Red_Image(i:i+DCT_Block_Size-1 , j:j+DCT_Block_Size-1);
DCT_Image_Recieved(i:i+DCT_Block_Size-1,j:j+DCT_Block_Size-1) = CosineTransform(Block_Matrix);
end
end
%performing dct on the steganographed image
DCT_Image_Recieved = round(DCT_Image_Recieved);
Quantized_Image_Recieved = zeros(n1,n2);
for i = 1:DCT_Block_Size:n1
for j = 1:DCT_Block_Size:n2
for k = 1:DCT_Block_Size
for l = 1:DCT_Block_Size
Quantized_Image_Recieved(i+k-1,j+l-1) = (DCT_Image_Recieved(i+k-1,j+l-1)/Quantization_Table(k,l));
end
end
end
end
%performing quantiation on the steganographed image
Quantized_Image_Recieved = round(Quantized_Image_Recieved);
%Zigzag converts the image into a row matrix
ZigZag_Recieved = [];
for i = 1 : DCT_Block_Size : n1
for j = 1 : DCT_Block_Size : n2
Block_Matrix = Quantized_Image_Recieved(i:i+DCT_Block_Size-1,j:j+DCT_Block_Size-1);
ZigZag_Recieved = [ZigZag_Recieved zigzag(Block_Matrix)];
end
end
counter = 1;
Extracting_Length = Embedding_Length;
Lsbbit = mod(ZigZag_Recieved(1:Embedding_Length),2);
%This line extracts lsb bit of all the steganoraphed image
Huffman_Decoded = huffmandeco(Lsbbit,Huffman_Dictionary);
%Performing the huffman decoding
%reshaping the extracted image Again to remove noise
Reshaped_Decoded_Image = reshape(Huffman_Decoded,[256 256]);
Obtained_Image = (Reshaped_Decoded_Image)/255;
imwrite(Obtained_Image,"SecretImage.jpg");
%mat2gray converts matlab array into a greyscale image