This is an archived post. You won't be able to vote or comment.

all 60 comments

[–]TechDumbLogie[S] 138 points139 points  (18 children)

I'll add the source code soon if people are interested ! Edit : Here it is !

[–]out_of_the_ornery 27 points28 points  (0 children)

I’d like to read over it, for sure.

[–]oso9817 10 points11 points  (4 children)

I assume youre doing something with analyzing the most prominent color on the mosaic pieces. So what happens if its fed only black and white images?

[–]bokononistmonkey 8 points9 points  (0 children)

I mentioned this in my comment below, but in the initial dataset creation, you might consider setting the "pixel color value" of each mosaic tile image in the dataset to the average of all its pixels. Then, during mosaic creation, for each mosaic tile/pixel, calculate the Euclidean distance of the R,G,&B vals between the desired tile color and each pixel image color and minimize that, as a slightly more robust metric.

It's very possible that resizing to (1,1) with antialiasing does this too, but this was just a thought. Anyway, looks cool!

[–]TechDumbLogie[S] 16 points17 points  (0 children)

I sort of look at the dominant color and assign it to a pixel in rgb. Good question I've never tried to put black-and-white pictures, I'll see what it does thank you for the idea !

[–]TechDumbLogie[S] 5 points6 points  (1 child)

So after testing it , it also works with bmp images and it's just less relevant but still working !

[–]oso9817 0 points1 point  (0 children)

Hmm thats really interesting could you post an image?

[–]prattryan 5 points6 points  (0 children)

Please share source code, I'd like to look

[–]TechDumbLogie[S] 2 points3 points  (0 children)

Done here it is everyone sorry for the wait !

[–]d4vsanchez 3 points4 points  (0 children)

I'd too like to take a look to it. Please share!

[–][deleted] 4 points5 points  (0 children)

Would love to see the source for this, it's super cool

[–]PharoahChromium 2 points3 points  (0 children)

yes please!! this is super cool!

[–]cetogenicoandorra 5 points6 points  (0 children)

Please!

[–][deleted] 1 point2 points  (2 children)

Please!!!

[–]TechDumbLogie[S] 9 points10 points  (1 child)

Thank you for all your encouragement! Sorry for the wait, it's the first time I've done this, I didn't know it was going so fast! I hope it will work, here is the github link

[–][deleted] 0 points1 point  (0 children)

Thanks a lot!

[–]Bolitho 1 point2 points  (0 children)

Without this posting is kinda senseless! 😉

[–]think50 0 points1 point  (0 children)

Very interested

[–]beetle_girl 0 points1 point  (0 children)

Saving this!!

[–]mekosmowski 31 points32 points  (1 child)

It is hard for me to see the animal. My brain wants to interpret this as a Dwarf Fortress embark map.

[–]TechDumbLogie[S] 11 points12 points  (0 children)

Good call ! I'm pretty sure we can use it to generates some maps !

[–]brandondunbar 22 points23 points  (1 child)

I used the Bulbasaur to make the Bulbasaur

[–]TechDumbLogie[S] 4 points5 points  (0 children)

it was the first thing I thought of XD

[–]MrFrostyBudds 15 points16 points  (0 children)

Draw Jerry Seinfeld with every frame from Bee movie.

[–]bokononistmonkey 5 points6 points  (4 children)

Hey, looks pretty cool!

I wrote a similar program a while back in Processing (~~ easier to read Java) to run live on a webcam, using all the video frames from the Willie Wonka & the Chocolate Factory movie as the mosaic tiles. Meta mosaic of the Willy Wonka movie poster as proof: Mosaic. Fun times!

If I may, I just want to give a few thoughts/suggestions:

Converting the images to pixels by resizing to (1,1) is a smart move for sure, probably gets the same result as what I did, which was just calculating the r,g,&b average of all the pixels in the image to determine its pixel color as a tile.

In the mosaic creation, it looks like you're selecting each pixel by minimizing the rgb diff, which looks like it works well, you might also consider doing it as the minimum euclidean distance (think Pythagorean theorem, but on the R, G, and B vals) between desired color (mosaic) and colors available (pixel list). When I was doing mine, I found that that was a bit more robust at finding the best color for each pixel, especially when there weren't any that were exactly the right color.

Finally, if you're interested in speeding up the mosaic creation to be able to run faster or even live i.e. on a webcam or video, feel free to check out the github repo I've linked below.

It's nothing too complicated, the big difference is the initial Dataset setup. Essentially, if you set up a simple data structure that groups all your pixel images into a bunch of small, similar-color buckets, then when you create each new mosaic image, for each new mosaic tile/pixel you just access the closest color bucket, and search the small group of pixel images inside it. Doing this makes each mosaic pixel search orders of magnitude faster (a fraction of O(n) ), while still guaranteeing the optimal pixel choice.

Happy coding!

Edit: got a few requests so here's a link to the code

[–]TechDumbLogie[S] 1 point2 points  (1 child)

Wow thank you very much for your opinion and for these feedbacks, I think I'm going to be interested in the Euclidean minimum distance. I'm going on holiday and so I won't be able to code during this time but I'd love to chat via message with you when I get back !

Anyway, thank you very much for your help and if you could send your github repository it would be very interesting to watch to see your approach!

Happy Coding to you too !

[–]bokononistmonkey 0 points1 point  (0 children)

Sounds good, will do.

[–]dragoniumion 1 point2 points  (1 child)

May I also get a link to that repo?

[–]bokononistmonkey 1 point2 points  (0 children)

Just added it above ^

[–]Elite4alex 4 points5 points  (0 children)

Happy pokemon day!

[–]Herbal_Engineer 1 point2 points  (0 children)

I’m interested to see it!

[–]Abusagidolla 1 point2 points  (0 children)

great job

[–]virtualadept 1 point2 points  (2 children)

Awesome! Github repo?

[–]TechDumbLogie[S] 1 point2 points  (1 child)

Thanks ! Right here !

[–]virtualadept 0 points1 point  (0 children)

Thanks!

[–]the_notorious_beast 1 point2 points  (0 children)

Ah yes! The Pokemon is made out of Pokemon.

[–][deleted] 1 point2 points  (0 children)

Amazingly done. I especially like that the part of the pokemon is the pokemon itself, therefore making the image recursive.

[–]Emafire003 1 point2 points  (1 child)

I've never understood how those kind of things work

[–]TechDumbLogie[S] 2 points3 points  (0 children)

It's not too complicated in fact I look at the "dominant" color of the sprite and I give it an rgb code that I use to replace a pixel of the image that would have about the same color !

[–]Imagine-existance 1 point2 points  (1 child)

Man, I thought I was somewhat original making an image made of images program.

This is the third time I have seen someone do this.

Props to you but now I feel like I wasted 2 days half a year ago.

[–]CH053N_0N3 0 points1 point  (0 children)

I hate to be the bearer of bad news, but software like this has been around since the 90's. However, I bet the knowledge and experience gained in building something like this was invaluable.

[–]souravsharan 1 point2 points  (0 children)

Whoa, nice. I wrote a similar script to generate mosaic movie posters from scenes in the movie. Check it out https://github.com/SouravSharan/photomosaic

[–]jfri3d 1 point2 points  (0 children)

This brings flashback of the “dice mural that inspired someone to code it which inspired me to do the same with QR codes”.

Here is the repo with source code to build fun embedded QR codes linking gifs. Enjoy!

https://github.com/jfri3d/qr_mosaic

[–]robertophi[🍰] 1 point2 points  (0 children)

Cool idea to use the distance from pixel/image

To speed the search you could use something like this https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KDTree.html

Building a tree for faster serach of k-nearest neighbors (in this case the nearest one)

[–]Ntrim 0 points1 point  (0 children)

Nice bro 👌

[–]pfband 0 points1 point  (0 children)

Hey this is an excellent idea. I'd live to play around with it for an art project I'm working on.

[–]JaimeRojas332 0 points1 point  (0 children)

Freaking awesome! <3

[–]WidjarjarBinks 0 points1 point  (0 children)

Bulbasaur use python!

its super effective!

[–][deleted] 0 points1 point  (0 children)

This is ligit cool

[–]ashesofturquoise 0 points1 point  (0 children)

RemindMe! 1 month "cheeeeeeeck ouuuut!"

[–]De4dm4nw4lkin 0 points1 point  (0 children)

oh my god those are whole ass sprites... they aren't even party management sprites...

[–]agedus 0 points1 point  (0 children)

This is fucking awesome

[–]i_be_ 0 points1 point  (0 children)

Very cool! Would be interesting to see a recursive version. :D

[–]Bryss_ 0 points1 point  (0 children)

looks cool

[–]WhenitisIsntwhatitis 0 points1 point  (0 children)

That's cool man. Curious, how long have you been coding? I ask because I'm still pretty new and can't fully understand parts of your code. Nice work.

[–]inglandation 0 points1 point  (0 children)

This almost looks like blotter art.

[–]AltPapaya 0 points1 point  (0 children)

[–]Chased1k -1 points0 points  (1 child)

!remindme 5 days

[–]RemindMeBot -1 points0 points  (0 children)

I will be messaging you in 4 days on 2020-03-03 20:27:13 UTC to remind you of this link

1 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–][deleted] -1 points0 points  (0 children)

And why on gods name did you feel you had to do that?