waifu2x is a surprisingly good image processing utility for performing noise reduction and scaling of 2D art type images (anime, manga). It is way, way better than Photoshop etc for what it does. Examples: { 123 }
There are many variants of waifu2x. The best I have personally found is waifu2x-caffe, which has both high performance and updated (neural network) models for superior image quality.
Granted, most people don't care, and will just rescale their animu with bicubic and save it as a JPEG. But for you heroes who fight the good fight for your waifu with median filters and PNGs and want a superior tool, this is for you.
To get waifu2x-caffe running you need:
An Nvidia GPU (you can run it in CPU mode, but it's horribly slow)
Windows Vista/7/8/10
GPU vs. CPU
waifu2x-caffe will run in CPU mode with no additional configuration required.
This means all you have to do is download, unzip and run it.
It is much slower, but for small images or limited numbers of larger images this may be tolerable.
Unzip the archive from the above step into some path somewhere. (there is no installer)
Register to download cuDNN from Nvidia. Unfortunately, this is somewhat annoying and requires waiting for approval, and filling out a bunch of forms. You must actually make an attempt to fill them out, or Nvidia will reject your application. I just said I was doing image processing, linked back to the waifu2x-caffe page, and answered C/C++ and OpenCL to the technical questions.
Once Nvidia approves your application, copy cudnn64_4.dll from the cuDNN download to waifu2x-caffe's directory.
Running waifu2x-caffe:
The GUI makes this very straightforward. You can apply noise reduction and/or scaling to individual images or directories. Just drag and drop or browse to a file.
Make sure you have use "Use cuDNN" selected, or it'll run on the CPU.
After copying cudnn64_4.dll to waifu2x-caffe's path for the first time, remember to restart it and click the button to verify that cuDNN is operable. (or it'll run on the CPU...)
Use the 2D/RGB model for anime. It will work fairly well on pretty much everything.
Use the 2D/Y (luminance) model for grayscale manga. It will perform somewhat better than the RGB model.
Never use the "photo/anime" model even if you're processing anime, because it lacks a noise reduction model. Without the noise reduction, waifu2x's scaling isn't nearly as exceptional.
Advanced waifu2x use:
In rare cases, waifu2x-glsl's noise reduction model can produce better results than waifu2x caffe's. I only use waifu2x-glsl if the image had a *lot* of JPEG artifacts and waifu2x-caffe failed to remove them all. In such cases, running the image through both versions is useful.
If a color image contains intentional chromatic aberrations, and possibly similar artifacts, better results can be obtained by splitting the image into monochrome color channels, performing noise reduction on them individually using the Y/luma model, and then recombining them. (example)
To remove dithering in manga images and attempt to interpolate smooth grayscale tones, you can downscale the original image by 50% (bilinear or average, don't use a sharpening kernel like bicubic!) then run it through an extra scale2x pass in waifu2x. (example)
You can take the above a step further and reduce it to 25% or even 12.5% of the original size before waifu2x and get a trippy stained glass effect. (example)
For very dark images, waifu2x tends to leave the darker areas alone, with relatively more noise. If you plan on lightening the image, make sure to do it before waifu2x.
The PNG format is great, especially for anime-type images, compared to the evil of the JPEG format. Unfortunately, most software sucks at saving efficient PNGs, making them needlessly bloated.
optipng is basically a superior iteration of pngcrush, and recompresses PNGs losslessly to lower the filesize. For things that suck at saving PNGs (OS X Preview, MPC-HC) this results in filesize reduction of up to 50%.
The nice part about using optipng with waifu2x (explained above) is that waifu2x makes images more compressible by the PNG format by reducing noise, as PNG compression is based upon finding repeating patterns in the data. Thus, waifu2x -> optipng is highly recommended workflow.
Download the "Windows (32-bit) build" from the official page.
Unzip optipng.exe to somewhere in your path (I was lazy and tossed it in C:\windows\system32)
Using optipng (all)
Single file:
optipng -strip all filename.png
Multiple files:
optipng -strip all *.png
Caveats
For grayscale/manga images, it may be necessary to use another utility to force them to be true grayscale before running optipng. The PNG format has a special color mode for grayscale images that is significantly more efficient than the normal RGB/RGBA color modes, but optipng will only use it if there are no colored pixels at all. Often, what we think is "gray" can actually be a color like red=200, green=199, blue=200, which is not gray to optipng.
All Comments (0) Comments