3

I have a source image like left picture and a set of elements like right picture: Source Image And Elements...

..and I need to generate a mosaic picture like this.

But until this moment I have not worked with images, аnd I do not know where I should start.

I worked several years with C#, but you can give examples in other similar languages.

tshepang
  • 12,111
  • 21
  • 91
  • 136
ForeverSmiling
  • 111
  • 3
  • 10
  • 1
    First and foremost, you'll need an algorithm that can generate the pattern. Drawing it afterwards is simple in comparison. – Sebastian Paaske Tørholm May 18 '11 at 07:34
  • googling on "image mosaic algorithm" gives a lot of interesting results – Fredrik Pihl May 18 '11 at 07:39
  • Thx, but the algorithm is not such a big problem for me as searching tools for its implementation. I wrote above that it is the first time I'll work with images and graphics. I probably need help with the selection tools available in C # (?) for analyzing the source image, slitting it into elements from set and displaying mosaic (and it will be great if user could edit it manualy after generation like real mosaic). Any ideas? – ForeverSmiling May 18 '11 at 09:04
  • Will you always have an image like your given start image that has the same colors for the smallest unit? Like, in your start image, you have squares of approximately 10x10 pixels that are of the same color, which represents the smallest of your building blocks. If this will always be the case, you just need to find an algorithm to divide one color plane into your building blocks. If this is not always the case, then you'll have to merge a square area of 10x10 differently colored pixels into one solid color for all pixels first, and then let the algorithm run over that modified start image. – takrl May 18 '11 at 14:30

1 Answers1

2

The result image you gave is apparently a ministeck pattern - in 2011 they had a downloadable software that seemed to do what you want. (Which is not available anymore by ministeck directly, but it seems that pfci.de still provides a download).

So, if you're just looking to generate the patterns for ministeck out of a given image, use their software. If you're after an algorithm to achieve something different, this won't help.

EDIT

Ok, if you're after analyzing your image, you need to load it into an object like this:

using(Bitmap b = new Bitmap(yourFileName))
{
  MessageBox.Show(string.Format("image size {0} by {1} pixels", b.Width, b.Height));
  MessageBox.Show(string.Format("color of pixel (100,100) is {0}", b.GetPixel(100, 100).ToString()));
}

The Bitmap object has several properties and methods that will help you to analyze the image content. Try this to get started with analyzing your image, and don't forget to either dispose your bitmap afterwards or wrap it into a using statement as shown above ...

takrl
  • 6,356
  • 3
  • 60
  • 69
  • No, I need use only elements and colors that i define. Also i think that most of existing programms have unfriendly gui. For me will be very interesting to write it by myself to learn someting about working with images and graphics in C#. – ForeverSmiling May 18 '11 at 09:50
  • Some alternative software is [Perro Ministeck Creator](http://www.moor-software.com/0.php?page=perro-ministeck-creator), but it is also quite nasty. =( – ForeverSmiling May 18 '11 at 09:58
  • Thank you very much. However, I thought about it and decided to try to use WPF for my purposes. Moreover, I found a good example of working with [graphics in WPF](http://www.codeproject.com/KB/WPF/WPF_DrawTools.aspx). Also, I have little experience with XAML. – ForeverSmiling May 19 '11 at 05:32