Skip to content

Tutorial | Demosaicing

Sebastian Wahl edited this page Apr 13, 2019 · 3 revisions

This tutorial will cover the demosiac technique described at spillerrec.dk - Removing mosaic censor. This method tries to recover the original image so the results will vary a lot based on how much information is available in the input images.

Required software

This guide is based on what will become version 0.4.0 alpha 2 or 0.5.0. While the results shown in the link above were based on v0.4.0 alpha 1, I do not recommend using it.

Overmix is still missing the final step to fill in the missing data, which is what G'MIC is used for. G'MIC for Krita should also work, or any alternative to G'MIC which can do the same will also be fine. Issue #135 is about fixing this.

Finding a good slide

To get good results, your slide should:

  • Contain movement in both vertical and horizontal directions
  • Have saved every frame available. Use the video importer
  • Do not contain any animation in the censored area. It does work but the results are not nearly as good.
  • Be censored in the specific way mentioned in the blog post so there are still high frequency information in each image.

Original

Good, the mosaics change rapidly from frame to frame

Bad, the mosaics are blurred

Examples to try out:

  • Worksafe syntetic example used in this tutorial: pixelated-kurisu.zip Drag and drop the #align.xml.overmix file into Overmix which contains the correct alignment.
  • Real slide (NSFW), password is 'overmix': TFS-ep1-slide.7z

Detecting grid size

We need to find the size and offset of the mosaic. Getting this correct is essential to get a good result.

  1. Load all of the images into Overmix
  2. Open Tool -> Show Demosaic Calculator
  3. Align each dot with the corner of each mosaic square
  4. Check that it is still aligned on all images, it might need fine adjustment. (Again, this is important)
  5. Change the offset so the dots are now in the center of each mosaic square
  6. Click OK to copy the settings to the Demosaic render

You should have something like this:

Render the normal averaged image

Select the "Average" render in the "Render" box and draw the image. Save this image, which will be used for the non-censored areas. Re-align the image if anything looks wrong. The censored area will look blurry (unless if there is a bunch of images without movement, which is not a problem).

Creating a HR grid

Next we want to render the HR grid which avoids the blur. Select the "Demosaic" render, which should have the Skip and Offset values you found in the calculator. Save the image as hr.png.

Interpolate

Load the hr.png into GIMP and open the G'MIC plugin in Filters -> G'MIC.... Several filters are available, the one used here is called Solidify located in the Repair section. The Edge-oriented regularization seems to work the best. Don't worry about the preview and click Apply. The resulting image will look something like this:

Merge

Since the current image is the result of how it would look like if the entire image had been censored, we want to use the parts of average.png everywhere else than the censored area. Add average.png as a new layer (make sure it is centered properly on the decensored image) and use the rectangle tool to select the censored area. Remove the censored area by pressing Delete on your keyboard. (Pro-tip: Blur your selection slightly to make the transition between the two images less obvious. Click the small rectangle below the vertical ruler to enter selection mask mode, and apply a bit of blur from the Filters menu, before exiting selection mask mode again and pressing Delete.)

The final image should look like this: