This is a GIMP plugin that add the ability to perform a Lens Blur (also know as Bokeh Blur).
This code is based on Mike Pound's implementation created for this Computerphile video. I changed the code to use OpenCV for performance gains.
Many thanks to Niklas Liebig for the alpha channel correction! :)
This plugin has been tested on Ubuntu 18.04 and GIMP 2.10.8.
To use this plugin you have to install the following dependencies in the Python environment used by GIMP:
pip install numpy opencv-python
-
Open the terminal, move to the GIMP plug-ins folder (usually
~/.config/GIMP/2.10/plug-ins
). -
git clone https://github.com/Davide-sd/GIMP-lens-blur.git
-
cd GIMP-lens-blur
-
Change permission to allow execution:
chmod +x GIMP-lens-blur.py
-
Open GIMP and load the image you'd like to edit.
-
In the layer palette, select the layer you would like to apply the lens blur.
-
Go to
Filters/Blur/Lens Blur...
-
Adjust the parameters:
- Radius: The amount of blur to add.
- Components: The more components, the better the final result, but the slower the computation. Even with 2 components the result is very nice.
- Gamma: tweak the exposure to highlight bright spots.
-
Click
Ok
.
- Is it possible to implement a preview window?