Hi I am trying to produce an image which is a combination of multiple images such as in focus stacking. Now I have 6 photos and I want to produce a final image such that the final image uses blocks of individual images with maximum value of the block. But I want to do edge detection of these 6 images first and based on the maximum edges produce a final image such that the final image has the maximum edges from the combination of all images. But the final image produced should be a color image and not in the edge detected form. Is it possible to do so? Images can be accessed here
First of all, thanks for sharing this problem. I hope it can foster some good discussions here at stack-exchange. I guess this problem is commonly called Multi-Focus Multi-Image Fusion (MF-MIF).
Let's look at all the images together with their grayscale histograms and the gradient magnitude (information content in each image):
As the original question requires an edge-based (or rather gradient as I take it) method, I will follow the idea presented in the following paper:
S. Paul, I.S. Sevcenco, P. Agathoklis, "Multi-exposure and Multi-focus image fusion in gradient domain", Journal of Circuits, Systems, and Computers, Vol. 25, No. 10 (2016), DOI: 10.1142/S0218126616501231 https://pdfs.semanticscholar.org/114b/835c5ea86e93efff1027cd6da7188c0cc92f.pdf
Essentially, the method aims to blend the gradients of the luminance components of the input images using the maximum gradient magnitude at each pixel location and then to obtain the fused luminance using a Haar wavelet-based image reconstruction technique. The algorithm also includes a Poisson solver at each resolution to eliminate artifacts that may appear due to the non-conservative nature of the resulting gradient.
The official source code of the method is given in this github repository and in your, kind of challenging dataset, the output looks like the following:
I am not sure if this is a sufficiently good output, but I bet further investigations can quickly lead to improved results. A small observation: The first image seems to be quite sharp. It seems like it has a global focus and already looks (only looks though) better than the resulting image.