Producing sharp-to-bokeh transitions in software

Inspired by this thread… Convolution with Fourier Transform: Bokeh!:

Not directly related to the work being discussed there, (way over my head!), but the thing that always sticks out like a sore thumb to me about most ‘artificial bokeh’ is the transition from sharp to blurry. A real lens will effectively have a small blur radius where it’s only slightly out of focus, getting steadily larger where the scene is further out of focus. Whereas a mask just fades in the blur, giving a bloom effect over the transition instead.

Which to me (I must be super particular) looks absolutely terrible, tbh, although I’ve seen it done quite often, i.e. in diffuse and sharpen in darktable

Anyone know if there’s a way of getting a realistic looking transition?

1 Like

What one would need to do is to create several masks for different depths and apply a different blur radius to each. For this to work properly you need a good estimate of the depth-map.

Check out this video which talks about how different algorithms look, even if you have a good depth-channel.
VFXstudy on Youtube

2 Likes

ImageMagick can vary the width and height of an elliptical Gaussian blur, controlled by a mask. For examples, see Selective blur.

I would like that ability for general kernels, not necessarily Gaussian. For example, the kernel for a blur from a camera lens aperture is generally more circular, or hexagonal, or whatever.

1 Like

Gimp provides a number of interesting blurring options which may be more suitable than DT’s option to create fake lens blur effects.
image

1 Like