A console/terminal demo of image deblurring by Wiener deconvolution, supporting Windows 11 and Ubuntu Linux 24.04, based on the OpenCV deconvolution sample. The input is read as grayscale, the blur is modeled with a point-spread function (PSF), either a defocus circle or a motion-blur line, and the image is restored in the frequency domain with cv2.dft, cv2.mulSpectrums and cv2.idft. Three example images ship under data/, and the results are saved to model/deblur/. No GPU is involved.

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • data/: the example images Lena.png, SC-150.png and sample.png.
  • model/deblur/: the results gray.png (the grayscale image), psf.png (the point-spread function) and deblur.png (the restored image); the Lena examples are included.
  • tool/tools.py: shared helpers.
  • src/: the demo, the launcher scripts and this document.
  • venv/: Python virtual environment, created by step 01.

[Prerequisites]

  • Operating system: Windows 11 or Ubuntu Linux 24.04.
  • Python 3 and pip.
  • No GPU required; an ordinary CPU is enough.

[Instructions]

Step 1: Create the virtual environment

Delete the old venv/, create a fresh one and install the packages listed in src/requirements.txt. The script aborts loudly if pip fails.

 

Windows: src\01_venv_create.bat

Linux: bash src/01_venv_create.sh

Step 2: Activate the virtual environment

Activate the venv. On Linux, source the script.

 

Windows: src\02_venv_activate.bat

Linux: source src/02_venv_activate.sh

Step 3: Run the deblur demo

Run the Wiener-deconvolution deblur demo. Any extra arguments are forwarded to the program.

 

Windows: src\03_deblur.bat

Linux: bash src/03_deblur.sh

For the motion-blur PSF or your own image, for example:

bash src/03_deblur.sh --psf motion --angle 135 --d 22 --snr 25

bash src/03_deblur.sh --source data/SC-150.png

 

Step 4: Remove the virtual environment

Delete the venv/ folder.

 

Windows: src\99_venv_clear.bat

Linux: bash src/99_venv_clear.sh

[Python Entry Point]

  • src/deblur.py: [--source IMG] [--psf circle|motion] [--angle 135] [--d 2] [--snr 25] [--output-dir DIR] [--show]. The defaults are the defocus-circle PSF with d = 2 and an SNR of 25 dB; --angle only applies to --psf motion, where it sets the direction of the motion. It saves gray.png, psf.png and deblur.png to model/deblur/; --show also opens the results in windows. The border is pre-blurred with blur_edge so the DFT does not ring, so the soft vignette at the output border is by design.

[References]

 

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately:  USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.