View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Mosaic generator

4.6 | 8 ratings Rate this file 30 Downloads (last 30 days) File Size: 64.6 KB File ID: #30039 Version: 1.8
image thumbnail

Mosaic generator


Nikolay S. (view profile)


15 Jan 2011 (Updated )

Photo mosaic generator. Choose a tile image, and a directory with images, and see the magic.

| Watch this File

File Information

This functions goal generate a mosaic image based on a single (usually large) main image, and multiple small tile images. A large mosaic image will be randomly generated from the multiple tile images. The resulting mosaic image will be combined with the main image, forming the desired result. The ratio between images “strength” is defined by the Overlay Ratio ranging between [0:1]. Smaller value will make the large main image be dominant, while larger Overlay Ratio will make the mosaic image (formed from tiles images) more obvious, at the expense of the main image. The user can (and should) define regions with different Overlay Ratio values. For example when the main image is a portrait, the Overlay Ratio value around the face should be small (about 0.2), while it can be high about 0.7) in other less important areas. The user can also resize the final image, sharpen the small images, convert them to color (RGB) or Gray images, if needed.
The program was inspired by this video: . After a few attempts via Photoshop I’ve decided to switch to a field where I feel more confident (Matlab), and enjoyed doing it. Later on I’ve seen the other Matlab based implementation, some better than mine, but I believe mine can be useful to someone as well.

Have fun!
In case of comments I'll try to fix the code.
Get the most updated "input to files list" function (submission 34944- for this one.


Files Under Folders (Fuf) and List Of Files From Directories/Files List Or Browser inspired this file.

This file inspired Many Pieces.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (20)
28 Jan 2017 k vinay reddy

19 Sep 2014 Nikolay S.

Nikolay S. (view profile)

Hi Pe.
Thanks for the flattering grade and kind words.
You’ve hardly mentioned your role in the application optimization. You have brought some problems to my attention, helped with a few wishes, form the user side, and also did excellent QA work on my improvements. This indeed resulted in an improved application.
Thanks for your help!

Comment only
19 Sep 2014 Pe

Pe (view profile)

The author (Nikolay) did an awesome job in optimizing the way this app works.
Loaded images now remain in the memory of Matlab, making it super easy to play around with the parameters such as the overlay ratio without having to load all the images again.
Feedback by me was really appreciated by Nikolay and he implemented everything I wished for.
Thanks again for making this app even more accessible and better to work with!

20 Jul 2014 Nikolay S.

Nikolay S. (view profile)

Hi Pe.
I believe I've found a solution for your problem, using persistent variable type. Try the updated version. Hope this will help.

Comment only
15 Jul 2014 Pe

Pe (view profile)

This app gives some really nice results!

I was wondering if it is possible to use the loaded/read images more than once:
If I make a mosaic and want to play around with settings such as tile size or overlay value(s) I have to re-run the entire program and re-load all the images I want to use. Off course I can use the previously used settings, but that does not prevent the app from loading all the images into its memory again.
With 500+ images this takes several minutes each time I want to tweak the resulting mosaic.
Is it possible to keep using the images that I have already loaded for creating new mosaics?

Comment only
05 Feb 2014 Nikolay S.

Nikolay S. (view profile)

Thanks GianCarlo Pacitti

Comment only
05 Feb 2014 GianCarlo Pacitti

This is really cool! Awesome stuff.

04 Jun 2013 Hanan Kavitz

Hanan Kavitz (view profile)

04 May 2013 Nikolay S.

Nikolay S. (view profile)

Hi Nitin
You should either install the app, and pressing the app button will run the mosaic, or run the "NS_mosaic_main.m" function, when the functions folder is in Matlab path. You'll be shown relevant dialog menus- follow the instructions...
best regrds

Comment only
04 May 2013 Nitin

Nitin (view profile)

plz tell me how to use this code

Comment only
04 Apr 2013 Nikolay S.

Nikolay S. (view profile)

Good morning Claz.
You should either install the app, and pressing the app button will run the mosaic, or run the "NS_mosaic_main.m" function.
If running "NS_mosaic_main.m" still shows errors, please send me the error text
Best regards.

Comment only
04 Apr 2013 Calz

Calz (view profile)

sir, which file to run?? i have tried running all files, but it shows error

Comment only
20 Feb 2013 Lyuboslav Petrov

Great Stuff!

26 Apr 2012 Ruth Livingstone

Very cool! and fun as well :o)

12 Dec 2011 Nikolay S.

Nikolay S. (view profile)

You're welcome to ask, I usually answer quickly. Most of my contributions are GUI's, which (I hope) pretty intuitive. Anyways if there are many questions you can email me.

Comment only
12 Dec 2011 Sepz

Sepz (view profile)

Btw, i have ML R2010a 7.10

Comment only
12 Dec 2011 Sepz

Sepz (view profile)

I'm a starter in MatLab, the few things i know about it are the basics, for math operations, and i founded very interesting that you can mke your own scripts and share it, I found this pretty interesting but as the newbie i am, im going to ask you for help to use it, i already download the codes, so, what else? i'll appreciate it.

Comment only
20 Oct 2011 deniz kumlu

excellent work thanks for sharing

02 Aug 2011 Nikolay S.

Nikolay S. (view profile)

hactor fjdkfjdkf- thanks for the flattering comment "excellent work". Too bad the grade you choose is 2/5, which is a bit confusing...

Comment only
29 Jun 2011 hactor fjdkfjdkf

excellent work

07 Feb 2012 1.1

- Better GUI for sub images choosing.
- Better GUI- sub-image size.
- Compatibility issue with R2011b (fileparts) resolved.

07 Feb 2012 1.2

- Compatibility with R2011b (fileparts outputs change) resolved.
- Integration of "List of files form directories/files list or browser" allows flexible choice of sub-image files/directories.
- sub-image size GUI updated.

14 Feb 2012 1.3

Some bugs fixed, some new features added or modified.

15 Feb 2013 1.4

- Packed into an App, for easier use.
- Files selection function modified

05 Mar 2013 1.5

- some documentation inprovements
- filesListFromInput changed to support recursive files listing via (slightly modified) fuf.m thanks to Francesco di Pierro.

20 Jul 2014 1.6

Added persistent variable to prevent re-reading images. Consumes memeory.
Updated filesListFromInput function used

21 Jul 2014 1.7

Taken care of disappearing persistent variable (when Matlab is closed for example).

28 Aug 2014 1.8

Improved memory management and minor chnages

Contact us