Skip to content
Nat Lee

Keyboard shortcuts

Turn these off if they get in the way of a screen reader or voice control. The setting is saved in this browser.

1
Home
2
Work
3
Projects
4
About
5
Experience
/
Search projects
?
Show this panel

Computer Vision

Spin-off · Infortrend

Blur Generator

Bad photos on purpose, for training models

Makes perfectly good images worse on purpose: motion, lens, Gaussian and depth-aware blur, for training models that have to cope with bad photos.

Role
Creator & Maintainer
Period
2021.05 – 2026.11
Status
Completed
Categories
Libraries & toolsVision & imaging
Origin
Infortrend
Stack
  • Python
  • OpenCV
  • Image Processing
  • NumPy
  • Computer Vision
Blur Generator, screenshot 1

Overview

A comprehensive image processing tool that generates various types of blur effects including motion blur, lens blur, and gaussian blur using OpenCV. This tool is particularly useful for data augmentation in machine learning projects and creating realistic image effects.

What it's good for

For anyone training blur detection or deblurring models: every sharp photo becomes as many blurred copies as needed, each with a known type and strength. With a depth map and a focus point it also fakes a portrait mode.

Diagrams

Main paths only. The edge cases stayed in the code.

Before 1.2.0, a lens blur of 2.5 was quietly a 3.

Point at a box to see what it connects to.

  1. Read the input photo(--type picks the blur) → Depth map given?
  2. Depth map given? → yes: Check the depth map → no: Blur the whole photo once
  3. Blur the whole photo once(Motion, lens or Gaussian) → Write the output image
  4. Check the depth map(Same size, 8-bit, gray or BGR) → Focus depth given?
  5. Focus depth given?(--depth_focus or a focus point) → yes: Measure distance from the sharp band → no: Cut the values into layers
  6. Measure distance from the sharp band(The band itself stays sharp) → Cut the values into layers
  7. Cut the values into layers(10 layers by default) → Pick this layer's blur amount
  8. Pick this layer's blur amount(Between min_blur and max_blur) → Blur amount is zero?
  9. Blur amount is zero? → yes: Use the photo as it is → no: Blur the whole photo
  10. Use the photo as it is(min_blur=0 used to crash here) → Keep this layer, add it in
  11. Blur the whole photo(Same type, this layer's amount) → Keep this layer, add it in
  12. Keep this layer, add it in(Masked to its own pixels) → More layers left?
  13. More layers left? → yes: Pick this layer's blur amount → no: Write the output image
  14. Write the output image(Bad photo, made on purpose)

Features

  • Multiple blur types (motion, lens, gaussian)
  • Batch image processing
  • Customizable blur parameters
  • Preview functionality
  • Command-line interface

The problem

  • Realistic blur simulation
  • Parameter optimization
  • Batch processing efficiency
  • Quality preservation

What I did

  • Implemented advanced blur algorithms
  • Created parameter tuning interface
  • Optimized batch processing pipeline
  • Added quality control mechanisms

Results

  • High-quality blur generation
  • Widely used in ML data augmentation
  • Efficient batch processing
  • Positive community feedback
Motion blur on a logo: the same colours, smeared along one direction
Motion blur on a logo: the same colours, smeared along one direction

What I learned

  • Up to 1.2.0 a decimal lens radius blurred like the next whole number: 2.5 gave the picture of 3. It now lands in between.
  • With the default sigma of 5, Gaussian kernels wider than about 31 px all look the same; sigma=0 lets the kernel size set the strength.
  • min_blur=0 used to crash motion and lens blur by depth; a blur amount of 0 now simply means an untouched copy.
  • Lens blur by depth: the rocks up front melt into bokeh, the far temple stays sharp
    Lens blur by depth: the rocks up front melt into bokeh, the far temple stays sharp
  • The depth map it used: brighter means nearer, so the front gets the most blur
    The depth map it used: brighter means nearer, so the front gets the most blur
  • Focused on the rock pile instead, a homemade portrait mode
    Focused on the rock pile instead, a homemade portrait mode
  • Libraries & toolsVision & imaging2626 stars on GitHub

    HEIC2PNG

    Turns iPhone HEIC photos into PNG from the CLI, a shell pipe or Python. A small tool for a small, recurring annoyance.

    2022Completed
  • Spin-off · Infortrend
    Libraries & toolsVision & imaging7676 stars on GitHub

    Batch Crop Images

    Draw a crop box once and it is applied to a whole folder of similar images. Written because I refused to crop them one by one, and apparently other people refused too.

    2019Completed
  • Spin-off · Infortrend
    Libraries & toolsVision & imaging1717 stars on GitHub

    Fisheye Warping

    Unrolls top-down fisheye images into panoramas and rolls them back again, so nobody has to squint at round photos.

    2020Completed