Correction on Design and Method
This week, my supervisor had some discussion with me. The first problems was my timing circuits. Previously, I actually made the timing signals by altering the clock edge, controlling the flip flop using the logic circuits into the clock input. However, this is a serious problem to the design, because I should never mess up with the clock. The clock should always be supplied as the real main clock do. I had neglected the importance of propagation delay on the circuitry. As the circuits complication increases, the propagation delays increases, and it could lead to many different problems later. For example, the increase of propagation delay in the circuitry may delay the clock rising edge time, and lead to unstable input/output. The worst case scenario of propagation delay is making the circuitry output delay by more than one clock cycles, which make the circuit to be unpredictable and malfunctioned.
Besides, my supervisor also corrected me on my timing circuit design, as I was using many unnecessary components to accomplish the timing signals. In fact, the circuit became inefficient and complicated. One of the golden lesson that I learnt this week is, try to remove something from the design to maintain the same capability. This is true as the circuit design could be optimized if one can actually remove some components and still maintain the circuit could still having the same functionality.
High Quality Linear Interpolation
Since the timing circuits are completed, I move on into the next stage, which is to design the demosaicing algorithm. The Pixel Pattern Grouping (PPG) algorithm produce very good quality interpolated image, as it is also the default demosaic algorithm by Darktable software. However, the algorithm itself is complicated in calculation, it requires the buffering of Green pixels before the Red and blue pixels to be interpolated, which is not suitable to be implemented in hardware. Thus, I start looking for the new algorithm that is suitable to be implemented in hardware. After search around for quite a while, I decided to use the high quality linear interpolation (HQLI). Just like previously, I try the algorithm by implementing it in the C, and apparently the effect is nice. It shows that it produce lesser of zipper effect but with more color inconsistency effect. The images below show the comparison between PPG and HQLI algorithm.
Figure 1 : Zipper Effect in PPG
Figure 2 : Effect in HQLI
In overall, the algorithm is better and it is simpler to be implemented in hardware. HQLI only consists of 4 patterns to interpolate all R, G and B pixels, and it does not require buffering the pixel, but it can obtain all 3 color simultaneously.
The Defect Pixel Correction
As I work on the output of the image sensor, figuring out how to input the sensor output into the RAW image file, I found that I had forgot one important process that need to be included, which is the defect pixel correction. The image sensor would not giving perfect output pixel on every pixel, and these pixels are called defective pixel. These pixels are still in Bayer CFA form, and they can be interpolated and detected by defect pixel correction algorithm. However, the algorithm need not to be very robust, but able to detect and replace the defective pixel with their neighbor pixel. The image sensor output need to be undergo the defect pixel correction first, before being saved into RAW image file or undergo demosaicing and etc.