Programmatically create Photomosaic

Programmatically create Photomosaic

Ask Question

11 years, 1 month ago

4 years, 2 months ago

3k times




Goal: Create Photomosaics programmatically using .NET and C#.

Main reason I’d like to do this programatically is to be able to record which image and where it goes myself, so I can create an animated effect of the images coming together to create the photomosaic. It would be great to just find something existing already that I could use to accomplish this almost right out of the box.

Any ideas?

c# .net graphics

share|improve this question

asked Dec 19 ’08 at 18:03

Chris CraftChris Craft

5,07766 gold badges4141 silver badges6363 bronze badges

add a comment

4 Answers






There’s source code available

share|improve this answer

answered Dec 19 ’08 at 18:17


56644 silver badges1212 bronze badges

Link seems to be dead, not sure if we have a better one available?

– Abe Petrillo
Nov 2 ’18 at 15:24

add a comment


I think you can borrow ideas from color quantization. For each photograph, calculate it’s average color. Since it’s small, that’s how it will look when viewed from a distance. Then split your target image in photograph-sized rectangles and calculate their average colors. Or, for better results, properly downsize it so, that every photograph corresponds to one pixel in the target picture. Then, for every pixel of the target picture, choose the photograph which has the color value closest to the pixels color. (Closest – as in closest in the 3D RGB cube). You can also apply some dithering for it to look better (Floyd-Steinberg’s algorithm is one of the best algorithms out there).

share|improve this answer

answered Dec 19 ’08 at 18:15


91.3k7575 gold badges247247 silver badges386386 bronze badges

add a comment


You can look up metapixel, it has code for doing the photomosaic analysis, but can also record an output file that lists exactly what source image was used in each location. That should do what you need. Unsure about windows support though.

share|improve this answer

answered Dec 19 ’08 at 23:30

Nathan NeulingerNathan Neulinger

23811 silver badge1111 bronze badges

add a comment


Not really an answer to your question, but you should be aware that there is both a patent and trademark associated with Photomosaic. You can find information in the wikipedia article you already referenced.

share|improve this answer

answered Dec 19 ’08 at 18:09

community wiki

Mark Ransom

add a comment

Your Answer

Thanks for contributing an answer to Stack Overflow!Please be sure to answer the question. Provide details and share your research!But avoid …Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.

Draft saved
Draft discarded

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password


Post as a guest


Required, but never shown

Post Your Answer


By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you’re looking for? Browse other questions tagged c# .net graphics or ask your own question.


Podcast: Make my Monolith a Micro

When laziness is efficient: Make the most of your command line

Featured on Meta

TLS 1.0 and TLS 1.1 removal for Stack Exchange services

Did Stack Exchange cut the number of negative comments nearly in half between…

An account of my meeting with the Stack Overflow management team

Visit chat


711How to create a new object instance from a Type639What is the correct way to create a single-instance WPF application?1145Create Generic method constraining T to an Enum1840How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?880Creating a byte array from a stream496Programmatic equivalent of default(Type)821Creating a comma separated list from IList<string> or IEnumerable<string>6Vignetting image effect algorithm with .NET458How do I exit a WPF application programmatically?1How to create a fade-in animation for a newly created control in C# UWP

Hot Network Questions

How do we convey scale in 2D games?

Why am I only level 4 after leaving White Orchard?

What documents were needed for a woman to register to vote in UK elections after 1918

Simplifying constructing native SQL query with nested if-else’s

What are the official opposing schools of magic?

In the UK parliament, how much of Prime Minister’s Questions is pre-planned?

Is the graphic designer asking too much of me as a customer?

QGIS and PostGIS, dimensions problems

Can you cast a spell with a casting time of 1 action while falling?

Group Anagrams (C#)

7zip : Why does encrypting the same file with AES-256 not give the same output?

What are these chair-like things in hotels?

Points, Hours, Capacity

Does showing my opponent I have an effective win condition qualify as improperly determining a winner?

In Uno, can you quickly finish a two player game by skipping your opponent’s final turn and without saying Uno?

Re-do paint over plaster in bathroom: How to feather/match?

What purpose are the transistors in this diagram serving?

Is it possible for master, tempdb, model and msdb to have a database_id other than 1,2,3,4 respectively?

Why so many STS-61’s?

Double deck vs wide body airliner, why would anyone build a double deck one?

Security risk of connecting to two networks simultaneously

How Do I Define Smells I Have Never Experienced?

What should I (a professor) do if a student keeps answering other students’ questions before I start explaining?

Using two tires on one wheel to prevent punctures?

more hot questions

Question feed

Subscribe to RSS

Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.


Leave a Reply

Your email address will not be published. Required fields are marked *