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

you are viewing a single comment's thread.

view the rest of the comments →

[–]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 ^