cImg function for "variable radius" blur, ie: faking depth of field blur using a depth/z-buffer image.
Closed this issue · 2 comments
First off, thanks for making the CImg library. It is really fantastic.
Does Cimg have a function for performing a fake depth of field blur using an input dataset (z buffer data per pixel) ? Sorry I don't know what the proper terminology for this technique is called, variable radius blur?
thanks!!
You can blur the image at various blur levels, stack the results along the "z" axis, and use interpolation to approximate the blur level you need at each (x,y) value. This tends to work pretty well even when using just a few blur levels.
Another trick would be to use an integral image in order to cheaply compute a box filter of the right size at each (x,y). Haven't tried that though.
Another solution is to use the generic image smoothing function CImg::blur_anisotropic() and provide it with a tensor field G
defined as isotropic diffusion tensors with spatially-varying radii.