Iris Blur Bokeh Effect?

That’s the exact technique I tried for Krita except with non-destructive filters and clone layers, but it seems to ignore color information, and big white areas can’t be ignored. So, there has to be some sort of way to replicate the effect. Also, while shapes are seen in Krita, it just looks ugly around the edge.

Do you have an example picture with white areas to show what you mean, I did not get this. And do you have example pictures to play with, best with the original picture and what you expect (not for me, at least not now, already bed time, but it could help to find a solution).

Yes, before and after examples would be appreciated. I don’t quite know what an iris blur is but it piques my interest :slight_smile:.

Hmm, I just realized that Bokeh seem to take into account of edges, which would mean I need to see if a technique with edges will work. Pics will come, but not soon.

@Reptorian Is this the tutorial that you were following? After reading it I have a better picture of what you are talking about. Looks like there are a few things going on. The uniformly blurred area, the untouched area and the transitional area in between; and then there is the bokeh. I think they could be addressed separately.

There was a very excellent script for GIMP which rendered a realistic bokeh and allowed for a realistic graduated blur using a depth map. Unfortunately the GIMP scripts website is broken, I can’t even switch to any page other than the first of each glossary letter: http://registry.gimp.org/glossary/a
If you manage to search it, look for “bokeh” and for “graduated blur” or “depth blur”.

1 Like

I think it was this one, Focus Blur:
http://registry.gimp.org/node/1444
http://registry.gimp.org/files/

I tried compiling focusblur-3.2.6. Had to update glib and libgimp includes:

diff --git a/src/aaa.h b/src/aaa.h
index 4a6d90b..c74cab2 100644
--- a/src/aaa.h
+++ b/src/aaa.h
@@ -19,8 +19,7 @@
 #ifndef __AAA_H__
 #define __AAA_H__
 
-#include <glib/gmacros.h>
-#include <glib/gtypes.h>
+#include <glib.h>
 
 
 G_BEGIN_DECLS
diff --git a/src/brush.c b/src/brush.c
index d17c7ac..1c197c0 100644
--- a/src/brush.c
+++ b/src/brush.c
@@ -26,7 +26,7 @@
 #include <math.h>
 #include <string.h>
 
-#include "libgimp/stdplugins-intl.h"
+#include "libgimp/gimp.h"
 
 #include "brush.h"
 
diff --git a/src/brush.h b/src/brush.h
index 685b253..8778fec 100644
--- a/src/brush.h
+++ b/src/brush.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_BRUSH_H__
 #define __FOCUSBLUR_BRUSH_H__
 
-#include <glib/gtypes.h>
+#include <glib.h>
 #include "focusblurtypes.h"
 
 G_BEGIN_DECLS
diff --git a/src/depthmap.c b/src/depthmap.c
index 196d4f5..0c9ee5a 100644
--- a/src/depthmap.c
+++ b/src/depthmap.c
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <libgimp/gimp.h>
 
-#include "libgimp/stdplugins-intl.h"
+#include "libgimp/gimp.h"
 
 #include "focusblur.h"
 #include "focusblurparam.h"
diff --git a/src/depthmap.h b/src/depthmap.h
index 78f5e99..baee540 100644
--- a/src/depthmap.h
+++ b/src/depthmap.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_DEPTHMAP_H__
 #define __FOCUSBLUR_DEPTHMAP_H__
 
-#include <glib/gtypes.h>
+#include <glib.h>
 
 #include "focusblurtypes.h"
 #include "focusblurenums.h"
diff --git a/src/diffusion.h b/src/diffusion.h
index 07ffe4b..3c1e4b9 100644
--- a/src/diffusion.h
+++ b/src/diffusion.h
@@ -23,7 +23,7 @@
 #define __FOCUSBLUR_DIFFUSION_H__
 
 
-#include <glib/gtypes.h>
+#include <glib.h>
 
 #include "focusblur.h"
 #include "focusblurtypes.h"
diff --git a/src/fftblur.h b/src/fftblur.h
index 124bcba..cd809fa 100644
--- a/src/fftblur.h
+++ b/src/fftblur.h
@@ -23,8 +23,7 @@
 #define __FOCUSBLUR_FFTBLUR_H__
 
 
-#include <glib/gmacros.h>
-#include <glib/gtypes.h>
+#include <glib.h>
 #include <libgimpwidgets/gimpwidgetstypes.h>
 
 #include "focusblurparam.h"
diff --git a/src/fftblurbuffer.h b/src/fftblurbuffer.h
index b34d682..972404f 100644
--- a/src/fftblurbuffer.h
+++ b/src/fftblurbuffer.h
@@ -28,10 +28,9 @@
 #endif
 #include <fftw3.h>
 
-#include <glib/gmacros.h>
-#include <glib/gtypes.h>
+#include <glib.h>
 #include <gtk/gtkstyle.h>
-#include <libgimp/gimptypes.h>
+#include <libgimp/gimp.h>
 #include <libgimpwidgets/gimpwidgetstypes.h>
 
 #include "focusblur.h"
diff --git a/src/fftblurproc.h b/src/fftblurproc.h
index 495572d..10a34f4 100644
--- a/src/fftblurproc.h
+++ b/src/fftblurproc.h
@@ -23,8 +23,7 @@
 #define __FOCUSBLUR_FFTBLUR_PROC_H__
 
 
-#include <glib/gmacros.h>
-#include <glib/gtypes.h>
+#include <glib.h>
 
 #include "focusblurtypes.h"
 
diff --git a/src/focusblur.h b/src/focusblur.h
index 54ca40a..d7e13a6 100644
--- a/src/focusblur.h
+++ b/src/focusblur.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_H__
 #define __FOCUSBLUR_H__
 
-#include <glib/gmacros.h>
+#include <glib.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/focusblurenums.c b/src/focusblurenums.c
index a107d7c..86adf21 100644
--- a/src/focusblurenums.c
+++ b/src/focusblurenums.c
@@ -24,7 +24,7 @@
 #include <glib-object.h>
 #include <libgimpbase/gimpbasetypes.h>
 
-#include "libgimp/stdplugins-intl.h"
+#include "libgimp/gimp.h"
 
 #include "focusblurenums.h"
 
diff --git a/src/focusblurenums.h b/src/focusblurenums.h
index fafde51..92bb5f0 100644
--- a/src/focusblurenums.h
+++ b/src/focusblurenums.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_ENUMS_H__
 #define __FOCUSBLUR_ENUMS_H__
 
-#include <glib-object.h>
+#include <glib.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/focusblurparam.h b/src/focusblurparam.h
index 64c887b..484fd7d 100644
--- a/src/focusblurparam.h
+++ b/src/focusblurparam.h
@@ -22,10 +22,9 @@
 #ifndef __FOCUSBLUR_PARAM_H__
 #define __FOCUSBLUR_PARAM_H__
 
-#include <glib/gmacros.h>
-#include <glib/gtypes.h>
+#include <glib.h>
 #include <gtk/gtkstyle.h>
-#include <libgimp/gimptypes.h>
+#include <libgimp/gimp.h>
 
 #include "focusblurtypes.h"
 #include "focusblurenums.h"
diff --git a/src/focusblurstock.h b/src/focusblurstock.h
index 15f3603..cfc0567 100644
--- a/src/focusblurstock.h
+++ b/src/focusblurstock.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_STOCK_H__
 #define __FOCUSBLUR_STOCK_H__
 
-#include <glib/gtypes.h>
+#include <glib.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/focusblurtypes.h b/src/focusblurtypes.h
index 0954c60..1531c84 100644
--- a/src/focusblurtypes.h
+++ b/src/focusblurtypes.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_TYPES_H__
 #define __FOCUSBLUR_TYPES_H__
 
-#include <glib/gmacros.h>
+#include <glib.h>
 
 
 G_BEGIN_DECLS
diff --git a/src/interface.h b/src/interface.h
index 6defd27..e819c60 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -22,7 +22,7 @@
 #ifndef __FOCUSBLUR_INTERFACE_H__
 #define __FOCUSBLUR_INTERFACE_H__
 
-#include <glib/gtypes.h>
+#include <glib.h>
 
 #include "focusblurtypes.h"
 
diff --git a/src/render.h b/src/render.h
index febbd24..ce1ca60 100644
--- a/src/render.h
+++ b/src/render.h
@@ -24,9 +24,9 @@
 
 #include "config.h"
 
-#include <glib/gtypes.h>
+#include <glib.h>
 //#include <libgimp/gimp.h>
-#include <libgimp/gimpui.h>
+#include <libgimp/gimp.h>
 
 #include "focusblurtypes.h"
 
diff --git a/src/shine.h b/src/shine.h
index c5a3621..a15ea41 100644
--- a/src/shine.h
+++ b/src/shine.h
@@ -22,8 +22,8 @@
 #ifndef __FOCUSBLUR_SHINE_H__
 #define __FOCUSBLUR_SHINE_H__
 
-#include <glib/gtypes.h>
-#include <libgimp/gimptypes.h>
+#include <glib.h>
+#include <libgimp/gimp.h>
 
 #include "focusblurtypes.h"
 #include "focusblurenums.h"
diff --git a/src/source.h b/src/source.h
index 50d34ca..c5b40de 100644
--- a/src/source.h
+++ b/src/source.h
@@ -24,8 +24,8 @@
 
 #include "config.h"
 
-#include <glib/gtypes.h>
-#include <libgimp/gimptypes.h>
+#include <glib.h>
+#include <libgimp/gimp.h>
 
 #include "focusblurtypes.h"
 #include "focusblurenums.h"

Stuck on this:

../../src/focusblurenums.c: In function ‘focusblur_model_type_get_type’:
../../src/focusblurenums.c:51:36: warning: implicit declaration of function ‘N_’ [-Wimplicit-function-declaration]
           { FBLUR_MODEL_FLAT,      N_("Flat"),      NULL },
                                    ^~
../../src/focusblurenums.c:51:36: error: initializer element is not constant
../../src/focusblurenums.c:51:36: note: (near initialization for ‘descs[0].value_desc’)
../../src/focusblurenums.c:52:36: error: initializer element is not constant
           { FBLUR_MODEL_SPHERICAL, N_("Spherical"), NULL },
                                    ^~
../../src/focusblurenums.c:52:36: note: (near initialization for ‘descs[1].value_desc’)
../../src/focusblurenums.c:53:36: error: initializer element is not constant
           { FBLUR_MODEL_GAUSSIAN,  N_("Gaussian"),  NULL },
                                    ^~
../../src/focusblurenums.c:53:36: note: (near initialization for ‘descs[2].value_desc’)
../../src/focusblurenums.c:54:36: error: initializer element is not constant
           { FBLUR_MODEL_RING,      N_("Ring"),      NULL },
                                    ^~
../../src/focusblurenums.c:54:36: note: (near initialization for ‘descs[3].value_desc’)
../../src/focusblurenums.c:55:36: error: initializer element is not constant
           { FBLUR_MODEL_CONCAVE,   N_("Concave"),   NULL },
                                    ^~
../../src/focusblurenums.c:55:36: note: (near initialization for ‘descs[4].value_desc’)
../../src/focusblurenums.c:56:36: error: initializer element is not constant
           { FBLUR_MODEL_BRUSH,     N_("Brush"),     NULL },
                                    ^~
../../src/focusblurenums.c:56:36: note: (near initialization for ‘descs[5].value_desc’)
../../src/focusblurenums.c: In function ‘focusblur_shine_type_get_type’:
../../src/focusblurenums.c:86:37: error: initializer element is not constant
           { FBLUR_SHINE_LUMINOSITY, N_("Luminosity"), NULL },
                                     ^~
../../src/focusblurenums.c:86:37: note: (near initialization for ‘descs[0].value_desc’)
../../src/focusblurenums.c:87:37: error: initializer element is not constant
           { FBLUR_SHINE_SATURATION, N_("Saturation"), NULL },
                                     ^~
../../src/focusblurenums.c:87:37: note: (near initialization for ‘descs[1].value_desc’)
../../src/focusblurenums.c: In function ‘focusblur_quality_type_get_type’:
../../src/focusblurenums.c:119:38: error: initializer element is not constant
           { FBLUR_QUALITY_BEST,      N_("Best"),      NULL },
                                      ^~
../../src/focusblurenums.c:119:38: note: (near initialization for ‘descs[0].value_desc’)
../../src/focusblurenums.c:120:38: error: initializer element is not constant
           { FBLUR_QUALITY_NORMAL,    N_("Normal"),    NULL },
                                      ^~
../../src/focusblurenums.c:120:38: note: (near initialization for ‘descs[1].value_desc’)
../../src/focusblurenums.c:121:38: error: initializer element is not constant
           { FBLUR_QUALITY_LOW,       N_("Low"),       NULL },
                                      ^~
../../src/focusblurenums.c:121:38: note: (near initialization for ‘descs[2].value_desc’)
../../src/focusblurenums.c:122:38: error: initializer element is not constant
           { FBLUR_QUALITY_DEFECTIVE, N_("Defective"), NULL },
                                      ^~
../../src/focusblurenums.c:122:38: note: (near initialization for ‘descs[3].value_desc’)

You want good bokeh, or bad bokeh?

Here’s a kernel for bad bokeh:

A photo of real stars:

Convolved with the kernel:

I accidentally published a page on Camera blurs. The page is very rough and unfinished, but shows how it can be done.

1 Like

Perhaps, for some (windows) users, this Japanese GIMP- website is interesting:

(“focus blur” etcetera)

http://www.geocities.jp/gimproject1/sample/extra-filter.html#top
http://www.geocities.jp/gimproject1/sample/extra-scripts.html#top

Very interesting returns! Thank you! :slight_smile:
Actually, to “create” lens blur, you need a kernel to convolve on an image. Like shown with Image Magick (so easily scriptable :slight_smile: ).
My idea: it may be better is to alter the gamma curve before convolving, so that it mostly appears on highlights, and then, with the processed image, return to original gamma curve. Which should be nicer now with higher bit depth support of Gimp. (Image Magick also can deal with that within its raw modes (RGB or RGBA)).

But… a side effect is that applying a large kernel denoises the image compared to parts you would want to keep in focus…

In the example I showed, I took an sRGB image made by the camera, linearized it (removing the gamma curve), convolved, and converted back to sRGB. The command (using 16-bit integer ImageMagick) in a Windows 8.1 BAT script was:

convert ^
  real_stars.png ^
  -colorspace RGB ^
  -define convolve:scale="^!" ^
  -morphology convolve %KNLD% ^
  -colorspace sRGB ^
  real_stars_badbokeh.png

… where KNLD is the kernel I showed, expressed as a string.

To do the job more correctly I could take the raw file, de-Bayer etc to get a floating-point scene-linear image, convolve that, then continue the normal workflow to get an sRGB image.

Yes, this applies the same de-focus to all parts of the image. More ideally the kernel would be resized, perhaps according to a gradient mask, to vary the effect across the image.

I stumbled upon this post today and have continued with your work on getting focusblur to compile again: GitHub - JMoerman/gimp-focusblur-plugin: Focus blur plugin by Kyoichiro Suda with lazy fixes applied to it to get it working again
I couldn’t be bothered to fix the ~15000 line of build scripts so I’ve made a small cmake script to build it instead.
I was able to compile and use it with gimp 2.10.

1 Like

@Jonathan_Moerman fantastic, it compiled successfully in Sabayon using GCC 7.3.0, GIMP-2.10.8 and fftw 3.3.6-pl2.

make install aborts with:

No rule to make target ‘install’.  Stop.

Should that work? The INSTALL file contains that step, though it is boilerplate text:
gimp-focusblur-plugin/INSTALL at master · JMoerman/gimp-focusblur-plugin · GitHub

The INSTALL file is still for the original build scripts. I haven’t yet added an option to install the plugin. (I’ve basically done the minimal amount of work to get it working again, so you will find some rough corners.)

I installed the plugin the following way:

mkdir build
cd build
cmake ..
make
sudo cp ./gimp-plugin-focusblur /usr/lib/gimp/2.0/plug-ins/

@Jonathan_Moerman great, I wrote a script to make compiling + installing it a breeze:

  1. Download the script:
    wget https://github.com/pixlsus/Scripts/raw/master/build-focusblur
  2. Make it executable:
    chmod +x build-focusblur
  3. Run it:
    ./build-focusblur
    Done.
1 Like

Nice!

I have updated CMakeLists.txt and updated INSTALL, now you can install the plugin with make install:

...
cmake -DPLUGIN_DIR="/some/path" ..
make
make install

The default installation path is set to /usr/lib/gimp/2.0/plug-ins/.

@Jonathan_Moerman @Morgan_Hardwood
I have include the focusblur plugin into my GIMp AppImage. It would be great if you could help me to test it and report any issues you might find…

Here is the link to the AppImage package: https://github.com/aferrero2707/gimp-appimage/releases/download/continuous/GIMP_AppImage-git-2.10.9-withplugins-20190223-x86_64.AppImage

One just needs to download the package, make it executable, and run it.

Thanks!

2 Likes

I gave it a brief spin when I wrote the script, and it did seem to work, though the preview didn’t handle the gamma encoding of the working space well as the preview was dark when my image was in linear mode. The preview in the plugin window is also still of the old type which cannot be resized.

I recently saw this video about creating bokeh on the Computerphile channel: https://www.youtube.com/watch?v=vNG3ZAd8wCc