Skip to main content

A self supervised learning technique for multi-focus image fusion [Baseline]
W&B Course Project Part-1: A report based on the Baseline model
Last updated: July 22, 2022
Overview
What is image fusion and why should I care ?
Image fusion is the process of combining/merging several images of the same scene in order to obtain a higher quality image. There are several kinds of image fusion techniques based on different types of images, the technique that is presented in this report is known as multi-focus image fusion. Here the images being fused have different regions in focus - and our objective is to obtain a fully focused image, the example image below explains it pictorially:

Multi-focus image fusion (image source: author)
There are many other types of image fusion techniques in the literature, for example multi-modal image fusion- in which we try to fuse images of different modalities (ex: X-ray + MRI images) and hope to bring out all the important details of both the modalities in a single image.
Our major objective is to combine all the useful complementary information from the source images, such that the fused image is of higher quality. Another benefit of this technique is that we can work with a single higher quality image rather than working with 2 or more images simultaneously- hence we are reducing extra data and work load !
Now let's have a look at the dataset that we will be working with.
Dataset Information
For this experiment I have considered the MFIF dataset. It contains 63 multi-focus image pairs to train and fuse, which is a rather small number for making an efficient deep learning model, but let's see what we can do !
Another challenging thing with this dataset is that all the image pairs are of different sizes and therefore resizing can alter the image quality which we do not want, hence for this baseline model I chose to perform a center-crop operation on every image to make the images of size 350x400x3.
Have a look at few of the images
Model Architecture
- A Siamese kind of Autoencoder based architecture is considered for the baseline model, having skip connections between encoder and decoder.
- At first, two source images will be passed through the encoder in a Siamese fashion, which will output two feature vectors say A and B of size 500 each
- We then stack them together horizontally, and pass it to the decoder.
- The decoder then outputs an image matrix of the same size as the input source images.
- The final step is to calculate the loss in a self supervised fashion.
- Let's say, the output to the decoder is F and the source images were I1 and I2. For the baseline model, we have created a custom MSE loss function which calculates the loss like this: L = Mean( (F - I1)^2 + (F - I2)^2 )

Baseline parameters
- Epochs = 70
- Learning rate = 0.0001
- Weight decay = 1e-4
- Optimizer = Adam
- Grad Clip = 0.9
- Batch size = 20 (due to computational limitations)
Have a look at the model's performance
What is expected from the model:
- Automatically capture the focus regions of each of the source images and put those features together and create a fused image.
- Capture the color and contrast information of both the source images.
- Make sure no additional artifacts are generated (noise, blurriness, etc.)
Actual Fusion Results:
****Teaser**** : Results were awful !
Have a look at the table below.
1. Criticism
- As can be seen, the model is not able to capture the following things:
- Color information
- Focus regions
- Basically everything that we want !!
- Even if we increase the number of epochs, this model wont be getting any better.
2. Technical
- If we look closely -- instead of capturing the focused parts of the images, this model is trying to capture the non-focused parts of the images, and the most probable reason for this is the loss function that we are using. Hence a simple MSE loss will not work!
3.Positives
- The model is able to construct similar looking images, i.e. rough/coarse features are being captured (when compared to their sources), hence we are at the right track, maybe a minor tweaking to the model architecture will help. Changing the loss function would certainly make things better, we just need to make sure that the loss function penalizes the de-focused parts of the output image.
That is all for this baseline report. :)
As you can see, this project is still under construction.. and so any kind of suggestions or tweaks are always welcome, please feel free to comment.