Many assume that the captured images that we view on our cameras represent what its sensors captured. However photo sensors are highly sensitive to a wide range of light thus making them unable to distinguish between different colours. In order to obtain coloured images cameras use what are known as Colour Filter Arrays (CFA). When using a CFA each pixel is represented by one of the three primary colours red green or blue. Cameras that use CFA’s commonly store image colours in what is known as a Bayer Pattern. To retrieve an image with accurate colours demosaicing algorithms are used to determine the true colours of the image. This lab explores the use of a linear regression based demosaicing algorithm how it is implemented and the accuracy it yields.
1. Ensure you have MATLAB installed on your computer. This code was tested on MATLAB R2022a.
2. Install the Image Processing Toolbox.
3. Download the code and files from this repository.
4. Open the folder in MATLAB. Change the testing and/or training images if you wish.
5. Run the script.
The image above shows the original raw mosaic data. The image is sorted in the RGGB pattern and converted to a single channel, monochrome image. The image on the right shows the results of using a linear regression based demosaicing algoriithm to reconstruct the colours of the image.
This project is licensed under the MIT