Wikinaut / descreen

FFT-based Python implementation of a GIMP descreen (anti-Moiré) plugin using OpenCV.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fourier transform descreen (anti-Moiré) filter

An implementation of GIMP descreen plugin in python with OpenCV. It utilizes a custom normalization of magnitude spectrum, found in fft plugin, which assigns more energy to pixels further away from the center, thus allowing to use regular binary threshold to localize high frequency areas and create a mask automatically. It turned out to be very helpful in case of periodic pattern removal, therefor I adapted it for python.

Usage

./descreen.py 
usage: descreen.py [-h] [--thresh THRESH] [--radius RADIUS] [--middle MIDDLE] input output

Example

python descreen.py images/example.png images/result.png

example result

Optional arguments include

  • --thresh INT, -t INT - Threshold level for normalized magnitude spectrum
  • --radius INT, -r INT - Radius to expand the area of mask pixels
  • --middle INT, -m INT - Ratio for middle preservation

The normalized spectrum and its multi-channel mask of the above example respectively

norm-spec spec-mask

Motivation

Originally intended to clean up deconvolution checkerboard artifacts, found in style transferred images, I thought it may have its uses in other areas, like cleaning low-dpi scans and therefor would be better off as a separate script. I excluded the optional despeckle step, found in original plugin for being too destructive. Instead, I find waifu2x to give a superior result in case of artistically styled images, thus tend to use it with maximum noise reduction as a second step.

Attribution

The script was taken from / originally written by https://github.com/6o6o/fft-descreen .

About

FFT-based Python implementation of a GIMP descreen (anti-Moiré) plugin using OpenCV.

License:MIT License


Languages

Language:Python 100.0%