File Exchange

image thumbnail

Hide Images In Image

version (10.1 MB) by Divakar Roy
Embedding Utility


Updated 12 Jan 2010

View License

Embed/Hide one or more images inside one bigger image (source image).

Code also tells how much of the source image you are using for embedding and as long as it's less than 100 percent, you can obviously cramp in more images.

Hide n seek!!

Comments and Ratings (25)

I am also getting errors

fahim rfiee

exract_image function has error for the word szim.why?

Pritam Nath

Error using imwrite (line 454)
Unable to open file "embedded.png" for writing. You might not have write permission.

Error in hide_image (line 60)

Error in imhi (line 1)

What to do with these errors?

error showing in first line itself, how to edit and correct it

Is there any reference paper used fro this program.




Dhrumil Shah

Dhrumil Shah

I tried to run you code for other images. And embedding part is done successfully but while extracting

*??? Error using ==> zeros
Out of memory. Type HELP MEMORY for your options.

Error in ==> extract_image at 23
the above mentioned error is faced.

Hi Divakar!!I am a new user to matlab and i have just tried the code u have given and faceing error in the initial line itself
??? Error: File: hide_image.m Line: 1 Column: 23
Unexpected MATLAB expression.
can u please help me in getting out of this problem and run the code.

Divakar Roy

Jitha, There was no paper followed for this one, it's entirely home-grown. Refer to my earlier comments in here for the underlying techniques.


Jitha (view profile)

Which is the base paper for this extraction?


myes (view profile)

plz can someone give me a code of image stegano that hide image into other image ...i have tried lsb technique want some other ...i need embeding and extracting codes ....thanks



amer jod

sabir khan

please give me some idea about how i hide an image into another image using matlab, please send me details code for encoding and decoding, i will be very gladful.
thanking you,

Divakar Roy

It's not exactly LSB-algorithm, it basically uses 8 pixels from source to form the 8bit of the embedded image. Idea was to minimize the change in the source, so that there is negligible change in it.


Hamsah (view profile)

Hi Mr. Divakar, Would u please tell me is it the LSB algorithm concept that you have been used in this program? by changing every 8pixel from the cover image? or what do u call your algorithm?

Divakar Roy

Yes you can insert as many images as you want, as long as you are not using more than 100 percentage of the source image(see the screenshot). It was clearly said in the description.


poo (view profile)

i am having two images(jpg) of same size 512x512 .i want to hide one image into another image.
any code change required in your program?

Divakar Roy

For explanation of commands, nothing better than "help function_name". Algorithm is simple and described in my previous comment. Regarding GUI making, you need to go through GUI tutorial, lots around here on File-exchange and outside as well.

Divakar Roy

First of all, thanks a lot for reviews.

As said in the requirements, it needs larger source image for embedding smaller images. So if you are trying to use a small image as source image, it will throw error. Roughly the size of the image to be embedded inside the source image should be less than 1/8th of the source image.

Theory is quite simple: Every 8 pixels of source image are altered for each pixel of image to be embedded and that’s why that 1/8th requirement.




nug (view profile)


I dowloaded your program and was playing around with it. I took the image that you provided 'pano.jpg' and tried embedding it with a different image. I used a new image which was of size 480x640. The extraction algorithm was successful in extracting the embedded image but when I tried using this image as the source image and tried embedding it with one of the images that you provided I was getting an error message saying

Too Many Images or Too Big Image for Hiding [Used 341.7648 percent of the source image].

Your algorithms look simple and pretty straightforward. Is there any literature out there expliaing how you implemented this. I would like to know the idea behind the actual code.

Thanks and I appreciate your work.
Good Luck


Small Change In 'Readme.txt'

Now it saves in png format that reduces file size over the previous bmp format.

Just changed the screenshot and description, code remains same.

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor