One YouTuber has created meticulous mosaics of Pokémon cards using a database containing thousands of other tiny Pokémon cards. Newbie Indie Game Dev shared a video on March 10 explaining “The Code Behind My 30,000 Pokémon Card Mosaic”, where they detail the algorithm that makes generating these works of art possible.
Newbie Indie Game Dev began the project with a database of images that documents 18,454 different Pokémon TCG cards – supposedly every one ever. “I built this database using a script that systematically downloaded every available card from an API I found online”, the YouTuber explains in the video below. With these resources available, Newbie Indie Game Dev could begin crafting mosaics.
The first step their algorithm takes is to overlay a grid (whose number of blocks can be adjusted to suit) onto the Pokémon card the user plans to recreate. Then, the algorithm will fill each block with a Pokémon card from the database. Said card is chosen depending on how well it matches the color of its intended block, but selection isn’t as simple as it sounds.

“At first, I tried taking the average color [of a block]”, Newbie Indie Game Dev says. “But this often produced dull, grayish tones, so I switched to using the median color instead.” “In math, the median is the middle value when you line up all the numbers, and since it’s less affected by outliers, it tends to produce a more vibrant and representative color.”
For the algorithm to find a matching Pokémon card, the YouTuber had to decide the values of each color. Newbie Indie Game Dev modified the CIE Delta E 2000 metric, a complex bit of math relating to how color is perceived by the human eye, to help their algorithm compare blocks of color with Pokémon cards.
Multiple cards are selected for a particular block, and one is selected at random so there isn’t too much repetition. Some colors (like pink) are vastly underrepresented in the database, so this isn’t always possible, but the machine does its best.
Finally, the Youtuber’s algorithm offsets the angle of each card slightly “to create a more organic result”. Newbie Indie Game Dev says the complete process can take anywhere from “a few minutes to several days”. That’s a lot to generate a single image, but the final collages are certainly impressive.
Not impressed yet? Check out the prices of these rare Pokémon cards – they’re sure to surprise you. Or, if you’d like to talk about the newest Pokémon set and best Pokémon cards, be sure to join us in the Wargamer Discord.
Source: Wargamer