WEBVTT
Kind: captions
Language: en

00:00:00.080 --> 00:00:02.899
This is a Pokémon card... It was made from a Pokémon card.  To

00:00:02.899 --> 00:00:07.617
be precise, there are 32,580.  And it is all done with code.

00:00:07.617 --> 00:00:10.628
But that's fine.  Let me tell you how this was actually made.

00:00:10.628 --> 00:00:12.760
Everything starts with two main elements.  It is a database containing

00:00:12.760 --> 00:00:15.429
reference images (the target to be reproduced)

00:00:15.429 --> 00:00:20.105
and all single Pokémon cards (currently) released.

00:00:20.105 --> 00:00:24.828
Now, "every single card" is a bit tricky to define because it depends on the item we are calculating.  If the

00:00:24.828 --> 00:00:29.843
language version is different, is it a separate card?  How about a slight reprint?

00:00:29.843 --> 00:00:35.680
However, for reference, the database currently contains 18,454 unique card images.  I built this database using a script that systematically downloads all available cards from APIs found online

00:00:35.680 --> 00:00:39.050


00:00:39.050 --> 00:00:44.345
(I will link all resources in the description).

00:00:44.345 --> 00:00:47.300
Along with images, the dataset

00:00:47.300 --> 00:00:52.680
also includes metadata such as the set each card belongs to, the release date, and even the full text of each Pokémon's attack.

00:00:52.680 --> 00:00:57.640
This metadata also reveals some interesting insights.  For example, it is the

00:00:57.640 --> 00:01:02.920
most commonly used word in Pokémon attack names.  Several trends stand out.  There

00:01:02.920 --> 00:01:09.040
are not only multiple mentions of physical attacks (e.g., tackles, punches, kicks), but also references to basic movements, energy-based terms, and even

00:01:09.040 --> 00:01:14.920
states (confusion, sleep, hypnosis, etc.).  And here is the surprising part.

00:01:14.920 --> 00:01:19.302
Some of the most common words sound like they belong to the battlefield,

00:01:19.302 --> 00:01:23.016
which is certainly not what I expected to see in Pokémon!

00:01:23.016 --> 00:01:26.002
Now, returning to the process itself, the algorithm

00:01:26.002 --> 00:01:30.795
starts by overlaying a grid on the reference image and dividing it into several sections.

00:01:30.795 --> 00:01:35.132
Each block is replaced with one Pokémon card.  You can

00:01:35.132 --> 00:01:39.057
select the grid size and have as many blocks as you want.

00:01:39.057 --> 00:01:42.794
Of course, the more cards you use, the smaller the size of each card becomes.

00:01:42.794 --> 00:01:47.713
At a certain point, it becomes too small, so the details start to blur when zoomed in.

00:01:47.713 --> 00:01:51.320
To solve this problem, we use standard pixel interpolation techniques to

00:01:51.320 --> 00:01:55.400
expand the entire collage to a higher resolution.  By doing this, the card remains clear even at a very small size and

00:01:55.400 --> 00:02:00.040
is visible clearly up close.  For every block of the grid, the first

00:02:00.040 --> 00:02:04.120
step is to determine the primary color that best represents the corresponding section of the image

00:02:04.120 --> 00:02:09.400
.  I plan to find the Pokémon card that best matches this color later.

00:02:09.400 --> 00:02:13.600
Computers process colors as numerical values.  For example, in the RGB model,

00:02:13.600 --> 00:02:17.720
each pixel is a combination of red, green, and blue intensities.  Therefore,

00:02:17.720 --> 00:02:22.640
to summarize all the colors of the block, these numbers must be compressed into a single value.

00:02:22.640 --> 00:02:26.680
Initially, I tried to take the average color by basically adding the red, green, and blue values ​​and dividing by the number of pixels, but

00:02:26.680 --> 00:02:31.360
this

00:02:31.360 --> 00:02:37.400
often resulted in blurry and gray tones.  So, I switched to using intermediate colors instead.  In mathematics, the median simply

00:02:37.400 --> 00:02:42.280
refers to the middle value when all numbers are listed, and because it is less affected by outliers, it

00:02:42.280 --> 00:02:47.800
tends to produce vivider and more representative colors.  Once the main color of the block is determined, the

00:02:47.800 --> 00:02:52.120
algorithm searches the database for the Pokémon card with the closest color.  Since

00:02:52.120 --> 00:02:56.000
this value does not change, the center color of all cards in the database can be calculated in advance

00:02:56.000 --> 00:03:01.480
.  But how can you tell if the card's color is actually similar to the block's main color?

00:03:01.480 --> 00:03:06.680
At what point are two colors considered "sufficiently close"?  I started with a simple approach.  We

00:03:06.680 --> 00:03:12.040
treated each color as a point in 3D space and measured the (Euclidean) distance between the colors.  The closer the points are,

00:03:12.040 --> 00:03:17.080
the more similar the colors become.  This method works at a basic level, but it does

00:03:17.080 --> 00:03:21.840
not fully capture the nuances of how colors are perceived.  To improve this, we

00:03:21.840 --> 00:03:27.000
explored alternative color spaces.  You have probably heard of RGB (Red, Green, Blue) and HSB (Hue, Saturation, Brightness)

00:03:27.000 --> 00:03:31.760
.  However, in this case, it

00:03:31.760 --> 00:03:36.800
proved to be much more effective because the LAB color space was designed to be perceptually uniform.  In Lab, "L" represents brightness, and

00:03:36.800 --> 00:03:41.400
"A" and "B"

00:03:41.400 --> 00:03:46.000
represent color components that show differences in a way that more closely matches how the human eye actually perceives them.  Based on this, the

00:03:46.000 --> 00:03:50.949
measurement criteria can be further improved by replacing Euclidean distance with one that is more suitable for color recognition.  The

00:03:50.949 --> 00:03:56.760
CIE Delta E 2000 index is a more sophisticated measure for quantifying crustal differences.

00:03:56.760 --> 00:04:01.720
Between two colors.  The mathematics behind it is complex, but essentially it

00:04:01.720 --> 00:04:06.520
tells us how similar two colors look to the human eye.  Since using a collage can

00:04:06.520 --> 00:04:11.480
cause some of the original image's effects to disappear, I

00:04:11.480 --> 00:04:16.400
added an adjustment that gives more weight to highly saturated colors to maintain brightness and vibrancy.  However, of course, the final result

00:04:16.400 --> 00:04:21.480
depends on the cards available in the dataset, so let's take a brief look at an interesting fact.  Certain types of cards are

00:04:21.480 --> 00:04:27.040
much more common than others.  Charizard has more than twice as many cards as Blastoise or Venusaur, and

00:04:27.040 --> 00:04:32.080
intermediate evolutions tend to have fewer versions overall.  It is probably

00:04:32.080 --> 00:04:39.000
because it is not as symbolic as the basic and final forms.  The number of Pokémon cards is much greater than that of Trainer and Energy cards, with

00:04:39.000 --> 00:04:43.974
Water types taking the lead and Grass and Psychic types following behind.  The

00:04:43.974 --> 00:04:50.320
stages of evolution follow a natural pattern, with the basic being the most common, followed by stage 1 and stage 2.

00:04:50.320 --> 00:04:55.320
Therefore, if I had to choose just one example of the most common card type, it would probably be

00:04:55.320 --> 00:05:00.560
Squirtle, the basic, Water-type Pokémon.  So, Charmander is the most popular of the three original starters

00:05:00.560 --> 00:05:03.720
, Squirtle is the most representative, and

00:05:03.720 --> 00:05:08.521
Bulbasaur is... well, my favorite.  Okay, let's get back to the algorithm.  The

00:05:08.521 --> 00:05:14.760
final color distance metric is a

00:05:14.760 --> 00:05:19.280
mixture of the CIE Delta E 2000 value and the weighted saturation difference in the LAB color space.  In the database,

00:05:19.280 --> 00:05:23.809
there is one card that received the highest score according to this metric when compared to the block's primary color.

00:05:23.809 --> 00:05:29.240
However, there will also be people who are very close.  To ensure diversity and prevent the same cards from repeating too often, the

00:05:29.240 --> 00:05:34.200
algorithm does not settle for just the best match but

00:05:34.200 --> 00:05:39.320
finds multiple candidates for each block.  To narrow down the range of options,

00:05:39.320 --> 00:05:44.920
start with a quick search using the Euclidean distance method, then apply the computationally more expensive CIE Delta E 2000

00:05:44.920 --> 00:05:48.854
metric (including saturation adjustment) to the pre-filtered candidates.

00:05:48.854 --> 00:05:54.320
Finally, randomly select one card from the top candidates to maintain an organic and diverse structure.

00:05:54.320 --> 00:05:59.840
In some cases, there are few cards that meet the criteria, so it may be repeated once those cards are exhausted

00:05:59.840 --> 00:06:06.040
.  One possible solution is to relax the acceptance threshold to allow more candidates even if they are not a perfect match

00:06:06.040 --> 00:06:11.880
.  However, this could mean that when there are many good cards to choose from, the algorithm selects a non-optimal card

00:06:11.880 --> 00:06:16.011
.  This is

00:06:16.011 --> 00:06:19.102
evident when looking at how Pokémon cards are distributed according to the color spectrum.

00:06:19.102 --> 00:06:22.800
Some colors are underrepresented,

00:06:22.800 --> 00:06:25.268
while others are much more common.

00:06:25.268 --> 00:06:27.920
Instead, the algorithm uses an adaptive threshold to

00:06:27.920 --> 00:06:31.800
slightly relax the criteria to allow for larger differences and

00:06:31.800 --> 00:06:34.762
re-evaluates candidates until sufficient matches are found.  Randomly rotate and offset the

00:06:34.762 --> 00:06:37.712
selected cards slightly before placing them in the final collage

00:06:37.712 --> 00:06:42.280
.  By doing this, the grid is separated,

00:06:42.280 --> 00:06:45.321
giving the image a more natural and handcrafted look.  In

00:06:45.321 --> 00:06:48.640
my opinion, while this produces more organic results and a

00:06:48.640 --> 00:06:53.840
perfectly structured grid is also appealing... now we have a choice.

00:06:53.840 --> 00:06:58.734
The algorithm has various settings that allow you to fine-tune the results.

00:06:58.734 --> 00:07:04.238
For example, you can adjust the grid size, control how strict the color matching should be, and

00:07:04.238 --> 00:07:09.015
modify elements such as rotation and offset ranges.  You can

00:07:09.015 --> 00:07:13.998
use all these options to experiment with and create collages with varying levels of detail.

00:07:13.998 --> 00:07:19.265
Depending on the settings, processing time may take from a few minutes to several days.  It

00:07:19.265 --> 00:07:23.102
took me 2 hours to process this collage on my personal laptop.  It

00:07:23.102 --> 00:07:28.819
consists of over 32,000 cards, and there are approximately 11,000 unique cards.

00:07:28.819 --> 00:07:33.825
The most repeated card is this card, which appeared 331 times.

00:07:33.825 --> 00:07:36.724
However, speaking of repeating cards, it is

00:07:36.724 --> 00:07:40.744
interesting that some Pokémon are represented much more frequently than others in the card database.  While

00:07:40.744 --> 00:07:45.360
iconic Pokémon such as Pikachu, Charizard, Mewtwo, and Eevee occupy the top spots,

00:07:45.360 --> 00:07:49.036
other Pokémon only have one card.  The

00:07:49.036 --> 00:07:53.672
interesting fact is that Unown R actually has fewer cards than other Unowns…

00:07:53.672 --> 00:07:56.059
Yes, I don't know.  I am

00:07:56.059 --> 00:07:58.448
really satisfied with the collage results.

00:07:58.448 --> 00:08:02.080
And I hope you enjoyed taking an artistic break from your usual game development content

00:08:02.080 --> 00:08:05.760
.  If you have any feedback regarding the project, please feel free to leave it.

00:08:05.760 --> 00:08:10.926
Leave a comment or join the discussion on Discord.  Thank you for watching, and I'll see you next time.

