I have a C# (Emgu CV) application where I capture mutliple images of the same scene at varying focal lengths. Now I want to create a multifocus image simular like described in this article http://blog.patdavid.net/2013/01/focus-stacking-macro-photos-enfuse.html
I could not find any approach doing it with OpenCV. I was able to create sharpness maps for my images with this code
private Image<Gray, float> GetFocusMask(string imgfile)
{
var img = new Image<Bgra,byte>(imgfile);
Image<Gray, byte> imgGray = img.Convert<Gray, byte>();
Image<Gray, float> roughSharpness = imgGray.Laplace(5);
roughSharpness = roughSharpness.Dilate(2);
roughSharpness._SmoothGaussian(3);
return roughSharpness;
}
Unfortunately I am stuck now and don’t know how to use this masks to calculate a single Depth of Field image of the original focus image collection.