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.
Read the input photo--type picks the blur
Depth map given?
Blur the whole photo onceMotion, lens or Gaussian
Check the depth mapSame size, 8-bit, gray or BGR
Focus depth given?--depth_focus or a focus point
Measure distance from the sharp bandThe band itself stays sharp
Cut the values into layers10 layers by default
Pick this layer's blur amountBetween min_blur and max_blur
Blur amount is zero?
Use the photo as it ismin_blur=0 used to crash here
Blur the whole photoSame type, this layer's amount
Keep this layer, add it inMasked to its own pixels
More layers left?
Write the output imageBad photo, made on purpose
Read the input photo(--type picks the blur) → Depth map given?
Depth map given? → yes: Check the depth map → no: Blur the whole photo once
Blur the whole photo once(Motion, lens or Gaussian) → Write the output image
Check the depth map(Same size, 8-bit, gray or BGR) → Focus depth given?
Focus depth given?(--depth_focus or a focus point) → yes: Measure distance from the sharp band → no: Cut the values into layers
Measure distance from the sharp band(The band itself stays sharp) → Cut the values into layers
Cut the values into layers(10 layers by default) → Pick this layer's blur amount
Pick this layer's blur amount(Between min_blur and max_blur) → Blur amount is zero?
Blur amount is zero? → yes: Use the photo as it is → no: Blur the whole photo
Use the photo as it is(min_blur=0 used to crash here) → Keep this layer, add it in
Blur the whole photo(Same type, this layer's amount) → Keep this layer, add it in
Keep this layer, add it in(Masked to its own pixels) → More layers left?
More layers left? → yes: Pick this layer's blur amount → no: Write the output image
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
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.
How it fits together
Simplified on purpose. The real thing has more arrows and at least one config file nobody understands.
Screenshots
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
Focused on the rock pile instead, a homemade portrait mode
Related projects
Libraries & toolsVision & imaging2626 stars on GitHub
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