Algorithmic Demosaic Work

This page uses a number of Copyrighted images to illustrate the techniques. I believe that this is permissable under the fair use doctrine. However, if any copyright holder objects, either e-mail me or leave a comment below and I'll remove the offending image.

Overview

One of the recurrent post-WW2 scams in Japan is some kind of technological solution to remove mosaic censorship from images or videos. Since the imposition of censorship by the United States in the post-war settlement, there has been a demand for uncensored material. While Hentai artists have found ways to circumvent the law, notably including Toshio Maeda who is widely credited with the modern proliferation of tentacle-based pornography as a way to avoid censorship, this demand has not abated.

While undoing a mosaic effect (recovering the original image that was obscured by the mosaic) is clearly impossible - and indeed, may not actually work if the image was not drawn in sufficient detail to begin with - replacing the censored parts of the image with an uncensored version is. Indeed, there are a number of prolific fan groups who uncensor Hentai Mangas (although Mangas typically use censor bars and so are not in the scope of this work). Technology is used extensively in this process in order to try and faithfully reconstruct the censored image, through the use of image editting tools and techniques (most notably, the use of clone brushing).

Deep learning neural networks (DLNNs) have the potential to automate the process further. There are a number of existing DLNN implementations which are relevant. If the problem is viewed as a hyper-resolution problem, i.e. viewing the mosaic as a low resolution image and therefore the demosaic process as a highly advanced form of upscaling, then DLNN models such as Waifu2x can provide a starting point. In addition, research has been conducted by on Image Infill, i.e. using DLNN models to reconstruct parts of an image which are completely missing. A recent example of this is research conducted by nVidia that utilises partial convolutions.

Given the current state of the art, it is my belief that it is possible to construct a DLNN that is capable of replacing mosaic censored images, although perhaps with some constraints. If true, then many works which have essentially been defaced with mosaic censorship could be (to an extent) repaired. Ideally, the availablility of a product which can repair mosaic censorship images could also force a rethink of the laws in Japan and other countries which mandate the censorship of pornography.

Proof-of-concept Work

To demonstrate that, at the very least, something is possible, the following proof-of-concept process has been implemented. A description of this process is provided below, followed by a number of example images.

Proof-of-Concept Algorithmic Decensor: 1. Original Image

1. Original Image

Proof-of-Concept Algorithmic Decensor: 2. Image shrunk to remove mosaic effect

2. The image is shrunk by cubic interpolation by a factor of the mosaic size (in this case, a factor of 8). To all intents and purposes, this removes the mosaic censorship, although we now have a tiny image.

Proof-of-Concept Algorithmic Decensor: 3. Shrunken Image grown by Waifu2x

3. The shrunken image is now grown by the factor it was shrunk by, using the Waifu2x algorithm in Anime mode. The image has now been "decensored", but has terrible artifacts due to running Waifu2x far outside of its designed parameters (Waifu2x is designed with a scale factor of 2 in mind, and this used 8). Typically due to pixel arithmetic, the image will also be slightly the wrong size, so it is also resized to match the original dimensions.

Proof-of-Concept Algorithmic Decensor: 4. Uncensored image merged back into original

4. To remove as many artifacts as possible, the decensored image is manually merged with the original, replacing only the parts of the original that were censored.

Example Image Copyright Searothonc (2015), Virgin's Protection Magic.

As can be seen, in this limited example an acceptable decensored image is produced. However, it should be noted that the original image had a very limited amount of mosaic censorship, and there was a limited amount of detail to restore. Below are some further examples.

Original

Original

Demosaic

Demosaic

Image Copyright Searothonc (2015), Virgin's Protection Magic.

This image works well.

Original

Original

Demosaic

Demosaic

Image Copyright Searothonc (2015), Virgin's Protection Magic.

This image works relatively well, although suffers due to poor image editing work and lack of detail in the demosaic version.

Original

Original

Demosaic

Demosaic

Image Copyright Searothonc (2015), Virgin's Protection Magic.

This image exhibits some clear pixellation artifacts.

Original

Original

Demosaic

Demosaic

Image Copyright Tsuki-no-Mizu (2018), Nightmare Girls Demo.

This image suffers from a small amount of blurring.

Original

Original

Demosaic

Demosaic

Image Copyright Atelier Europa (2016), Treasures.

This image suffers from a blurring in the red channel only, and lines which may be in the wrong places.

Current Limitations

The proof-of-concept images that displayed have many limitations, but the three primary limitations that prevent this from being a generally useful technique are as follows:

  1. The process is not automatic, and requires some effort for each image, making it unfeasible for general deployment on games which can have hundreds of censored images.
  2. Large areas which are censored lack detail.
  3. Relatively high chance of strange artifacts.

Scope of Work / Limitations of Work

This work will only examine the decensoring of Hentai images. There are a number of reasons for this, including ethical considerations and the difficulty of assembling a corpus of data. Further, this work will only examine static images. While I have no doubt that the work could be applied to a frame of a mosaic censored video, I do not believe that an initial version will be capable of removing the censorship from an animation successfully. Specifically, details added by the decensor process would likely not be consistent frame to frame, resulting in somewhat disturbing animation.

Statement of Ethics

This research is designed to tranform mosaic censored Hentai images (defined as images drawn in an anime style) into uncensored hentai images. Hence, as there is not expected to be any identification of actual persons, and the work transforms erotic images into erotic images, the primary portion of this work is ethically sound.

There are a some secondary considerations. This work, for example, could be applied to mosaic censored faces. While there is no realistic prospect of extracting the original detail of the face, it could be used to get an idea of the person behind the mosaic. In certain situations, this is a deeply unethical thing to do, and hence this research restricts itself to drawn images.

Further, this work skirts very close to the law in Japan and several countries that mandate the censorship of commercial pornography. Other than in countries which heavily censor the Internet (e.g. China), these laws seem redundant. It is trivial to find freely available uncensored pornography on the Internet, and so I do not believe these laws serve much of an ethical purpose. The only consequence of this research I can forsee in countries with these laws is potential reformation of censorship laws to either allow the distribution of uncensored materials or to ban automated decensoring methods.

A final ethical consideration is the copyright status of the data used to train the model. The data that us being used is publicly available, but it is difficult to determine if the data is licensed for use in machine learning. Further, it is unclear if the fair use doctrine applies in such cases. Unfortunately, it is unclear how to proceed on this matter.

Requests for Help

Unfortunately, creating machine learning models is not particularly cheap. I'm not poor, but I'm not particularly rich either. Given the price of nVidia high-end GPU's these days (which, annoyingly, are the main consumer available machine learning tool) I'm not sure I can actually afford one. And it goes without saying, but there are quite a lot of restrictions on what cloud providers will accept with regards to research that involves pornography.

I am currently attempting to make do with the resources that I presently have - an AMD RX 480. However, it is likely that in the future I will look to monetize this research to recoup costs. This could be any number of things, including but not limited to:

  1. Electricity
  2. New hardware
  3. Services from cloud providers

In summary, I am not currently seeking donations for this research. However, if you are interested and in the would consider donating in the future, please leave a comment to that effect below. I'll use this information to try and determine potential future monetisation, which in turn may allow me to buy more up-to-date hardware and thus accelerate the research.

Update regarding DeepCreamPy (01/11/2018)

Recently I have become aware of a library that claims it can decensor anime style images, under the name of DeepCreamPy. As far as I am aware, this library simply uses nVidia's Partial Convolution approach trained on data sourced from the Danbooru data set. There is no new research to this, as such.

The approach of DeepCreamPy has several noticeable weaknesses; these included only being able to relibably remove small amounts of black bar censoring (and in particular, failing quite badly on mosaic censored images), the fact that it cannot automatically detect censorship, and the fact that in some cases it produces results which are frankly, disturbing. I believe this is because the original nVidia research was geared towards photographic images which have much more texture detail than anime style images, and hence the neural network is struggling to recreate detail, and therefore has a relatively high chance of picking the wrong detail to reconstruct.

Or to put it another way, a perceptual loss function that assumes photorealistic input data is unsuited to the lack of detail found in anime style images.

Still, the fact that the research worked at all is promising, and the fact that people got excited about it perhaps speaks more to my inability to market this approach (which has very similar limitations). However, I am not convinced that the researcher behind DeepCreamPy will make progress; their research so far has consisted of training an already extant model with new data, and their proposed enhancements are only to create new models with different data. My preliminary analysis of the problem suggests that there will only be limited benefit from this, and that the image infill technique proposed by nVidia is fundamentally unsuitable for anime images, or at least not without modifications.

Comments