Working:
Encoder:
First it asks for the two image files. You should enter the filenames with their extensions
Then the program hides the second image in the first one. For this the last nibble (last four bits)
of the first file will be replaced by the first nibble (first 4 bits) of the second image.
The resultant image has higher energy for first image. So the hidden image hardly seen.
During the process it asks for a name for coded image then the name given shouldn't have any extension.
The coded image is saved as BMP instead of JPEG because the JPEG files are compressed images.
So while compressing the hidden image will be affected.
If the two images are not in the same resolution then the program itself will change the resolution of first
image by second.
Decoder:
The image file name given should have extension. The program will do the reverse process of the encoding.
Example photos:
Image 1:
Image 2: (Image to be hid)
Image 3: Encoded image (Image 2 is present inside this)
Decoding image 3 and the decoded images as follows
Download: Hide image.rar
Example :
***** IMAGE HIDER*****
___Program for hidimg one image inside the other image___
_________________________________________________________
---Encode :- 1
---Decode :- 2
Enter your task:1
Welcome to Encoder
Enter the first image file name: vegas_fr.jpg
Enter the second image file name: 54.jpg
Do you want to save the file y/n [y] y
Enter a name for the encoded image: codedvegas
>>
The MATLAB program follows:
-------------------------------------------------------------------------------------------------------------------------------------------------
% Program for hiding an image inside the other
%By
% Mr. vipin.p.nair
% College of Engineering Kallooppara
% vipinpn@yahoo.com
% 06-Nov-2008
%*****************************************************
clc;
disp(' ');
disp(' ***** IMAGE HIDER*****');
disp('___Program for hidimg one image inside the other image___');
disp(' ');
disp('_________________________________________________________');
task = input('---Encode :- 1 \n---Decode :- 2\n Enter your task:');
% select task
if isempty(task)
task=1;
end
if task == 1
% reads two image files
x = imread(input(' Welcome to Encoder\n Enter the first image file name: ','s'));
y = imread(input(' Enter the second image file name: ','s'));
% check compatibility
sx = size(x);
sy = size(y);
if (sx(1) ~= sy(1))(sx(2)~=sy(2))
x=imresize(x,[sy(1),sy(2)]);
end
%
% clearing Ist files lsb bits & moving IInd files msbits bits to lsbits
x1 = bitand(x,uint8(240));
y1 = bitshift(y,-4);
% inserting IInd to Ist file
z=bitor(x1,y1);
% display the first image
figure(1)
image(x);
xlabel(' Ist Image ');
% display IInd image
figure(2);
image(y);
xlabel(' IInd Image ');
% display encoded image
figure(3);
image(z);
xlabel(' Encoded Image ');
% saving file
sav=input('Do you want to save the file y/n [y] ','s');
if isempty(sav)
sav='y';
end
if sav == 'y'
name=input('Enter a name for the encoded image: ','s');
if isempty(sav)
name='encoded_temp';
end
name=[name,'.bmp']; % concatination
imwrite(z,name,'bmp');
end
else
% Decoding encoded image
z=imread(input(' Welcome to Decoder\n Enter the image file to be decoded:','s'));
% xo is fist file- obtained by clearing lsb bits, yo is IInd file right
% shifting z by 4 bits
xo=bitand(z,uint8(240));
yo=bitshift(z,4);
% display Ist & IInd image from encoded image
figure(4);
image(xo);
xlabel('Ist Decoded Image ');
figure(5);
image(yo);
xlabel('IInd Decoded Image');
% saving file
sav=input('Do you want to save the file y/n [y] ','s');
if isempty(sav)
sav='y';
end
if sav == 'y'
name1=input('Enter a name for the first image: ','s');
name2=input('Enter a name for the second image: ','s');
if isempty(name1)
name1 = 'Ist_temp';
end
if isempty(name2)
name2 = 'IInd_temp';
end
please e-mail the description and related explanation with documentation(whichever possible, if all then all). my id is akshitbhasin@yahoo.com
ReplyDelete