Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Latest commit

 

History

History
47 lines (34 loc) · 3.63 KB

HOW-IT-WORKS-09.md

File metadata and controls

47 lines (34 loc) · 3.63 KB

How Does Anime4K Work (V0.9)?

As bloc97 described in his pseudo-preprint, the Anime4K algorithm is actually quite simple.
I, however, will only give a brief overview of the algorithm. If you want to read more, I highly suggest bloc97's preprint. The Algorithm itself can be summed up in five steps, one of which beign the initial upscaling of the image.

Let's assume we start with the following image:

We first scale the Image up using a arbitrary Image interpolation algorithm (bloc97 suggests bicubic interpolation, which is also what I went with)

We then calculate the luminance of every pixel and store it in the otherwise unused alpha channel (Image shows B/W representation of alpha channel)

In the third step, the color is pushed based on the luminance information in the alpha channel.
After doing this, we get a Image that looks nearly the same. But looking at the edges of lines and different colors reveals that they are lighter than in the original (this is especially noticeable at lines)

The following Image highlights the differences between the upscaled version of the image and the image after the push color step.
As you can see, the changes are mostly concentrated at edges between colors and lines.

The fourth step now detects the edges of the luminance map using a Sobel operator.
The result of the sobel operation is, again, stored in the alpha channel.
However, the result of the sobel operation is first inverted before storing it.
(Image shows B/W representation of alpha channel)

The fifth and last step is almost the same as step three, tho instead of getting the lightest color, we use the average color to remove some unwanted noise that is caused by the interpolation.
Before saving the image, the alpha value of each pixel is reset to completely dump the alpha channel. If this is not done, the output Image will still contain the gradient map. This would result in an image where all edges are transparent.
The output of this step is our final result (assuming we only do one pass)

To better show the differences, heres a zoomed- in comparison between bicubic interpolation and two passes of Anime4K:

Disclaimer

All art assets used are for demonstration and educational purposes. All rights are reserved to their original owners. If you (as a person or a company) own the art and do not wish it to be associated with this project, please contact me (eg by opening a Github issue) and I will gladly take it down.
Images used for Demonstration are from Cells At Work.

  • This Document is based on Anime4K 0.9. Other (newer) Versions of Anime4K do work somewhat differently
  • I do, by no means claim to be an expert when it comes to Anime4K. (Tho I think this explanation should capture the overall principle quite well)
  • Credits for Anime4K go to bloc97