INTRODUCTION
Similar to Rosette Nebula, this project also deals with creating stunning images which require various improvisation of raw images obtained using a camera. A single image is often blurry, dim, or has many defects. This can be corrected by using multiple images that increase the correct light signals. There are many aspects of image processing that this project will turn upon. The main objective of this project is to produce stunning images of Pleideas star cluster from 23 raw .dng images.
The 23 raw images supplied are DNG and require extra work to be read in MATLAB. The following code will read these files into MATLAB array called raw and will also create metadata about each image. The code also crops the image into meanigful area which contains required information. Apart from the raw images, we are also given three images - Master dark, Master flat, and Master bias. These are three different images that will be used for calibration. Master bias is an image exposed to short term electronic noise. Master Dark is obtained by a camera with a closed lens cap. This image represents long term exposure to background noise. The master flat is an image that represents optical irregularities in the optics. It is also a long term exposure image but with uniform light exposure.
WORK FLOW
The 1st image is loaded and rest of the images are registered with each other using MATLAB inbuilt imregister command. Since the images are captured using the same camera, it is advantageous to use "monomodal" argument for registering the images along with translation command. This is done by calling each image in a loop and registering it with previously registered image.
Before proceeding to the calibration, it is importnat to note that the master images are of different sizes as compared to the raw image. Hence it is necessary to pad the raw images to make it equal in size with the master images.
Raw image after
calibration and registration
Performing calibration by subtracting dark and then dividing it by the difference of flat and bias. This removes all the camera irregularities from the image.
Now this will act as the starting image on which all the modifications will be carried out to see improvements. Starting with smoothing the image using 7x7 filter
Image after smoothing
Smoothing is performed using 7x7 Laplacian filter
H = ones(7,7)/49;
X = conv2(raw_flat*65535,H,'same');
Demosaic/DeBayer
A majority of one-shot color (OSC) cameras are able to produce a color image from a single shot. This work by placing a color filter on top of every sensor pixel. The sensor is still a monochrome detector, but the color filter ensures that each pixel collects only photons from one of the three primary colors. The missing color information is then computed algorithmically from neighboring pixels. This arrangement is called Color Filter Array, or CFA. A typical CFA is composed of red, green and blue filters, although other combinations are possible as well, such as cyan, magenta and yellow. The process of computing the missing color values from a CFA is called color recovery, color reconstruction, or demosaicing.
As the most typical CFA pattern is the Bayer pattern, demosaicing is also often referred to as debayering. The Debayer process implements several methods of color recovery for RGB CFA images. The input image can be either a grayscale image or a color CFA image where each pixel has non-zero values for only one channel. The process creates a new RGB color image with the same view identifier as the input image.
The demosaic function of MATLAB specifies the particular arrangement of Color Filter Array used by the camera. There are four possible arrangements/patterns of how red, green and blue pixels can be placed on the camera sensor. The number of green pixels is always doubled compared to red or blue pixels. This is because the human eye is more sensitive to green light, and most OSC cameras have been designed for day light use. For normal daylight RGB images the green channel usually is a good approximation to the luminance component, where our vision system perceives most of the detail. The following image shows an example of a CFA matrix and the four supported CFA patterns.
Image after demosaicing using rggb Bayer filter
The demosaicing uses rggb Bayer filter. The reason for using filter is to have reduced region with red color and more with blue or white color. As red affects and white protects.
Histogram equalisation
Now we have the correct Bayer filter applied, lets further enhance the image using histogram equalisation. Here, I have tried to match the histogram of a targeted image color by color layer. The target image is as follows
Target Image
Target image cumulative color distribution
The cumulative distribution of original image is interpolated based on the targeted image using interp1 MATLAB command.
Original image cumulative color distribution
Original image cumulative color distribution after interpolation
The final image
The MATLAB code is available here