This week, I had been spending time searching on way to test the demosaic algorithm. I did a misunderstanding on previous week, that there is a process between the image sensor output and raw image. The Raw image is directly the output from the image sensor output itself. Well, I could not judge the statement until I actually prove it myself. As I searched through the internet on the way to verify the statement, I found this link that actually describing how to demosaic your own image, by using the dcraw (pronounced “dee-see-raw”) tool.

Visualize the Real Raw Image from Camera

The dcraw is actually an open-source tool, that can be used to process raw image files. By utilizing the terminal command

dcraw -v -E -T -4 -o 0 Raw_file_name

The input raw file could be in DNG format. The output file will be converted into TIFF extension image file, with the actual Raw data that had been captured from the image sensor. The conversion into TIFF format is extremely useful because TIFF file can be easy processed in any language later.

The Darktable and most of the Raw image editing software are trying to enhance user experience, whereby they would perform certain image processing such as demosaicking, some gamma correction and etc before user actually starts to edit the image manually. Thus, the user would never see the Bayer filter using these software, where the Bayer filter color array actually exists in the Raw file itself.

Demosaicking in C

As I searched over the examples from the previous link, I found that this project, using the Self-similarity Driven Demosaicking technique actually written in C, with the input of TIFF image file. However, most of the code are written using floating point variables, which would be a very expensive approach to be implemented in hardware later. I had modified the code into int variables instead, and apparently it does not make any difference. Although from the comparison that could be made from the website itself, the Self-similarity Driven Demosaicking is not the best algorithm to be used, but I think it is a good idea to use the TIFF file to test for demosacking algorithm. The picture below shows the comparison between the raw image file (DNG) produced using dcraw and the image file that had been processed using the Self-similarity Driven Demosaicking.

raw_image

Raw Image : Bayer pattern can be seen

Demosaicked_image

Demosaicked image : Bayer pattern is interpolated and turned to green color instead

Note : Although most of the time the images that had been converted would resulting in black, but after altering the exposure level and white balance and etc, the picture should actually looks like a real image.

The Path between the Raw Image and the Real Image

As I searched through the internet to understand the usage of FPGA in image sensor application, I found this link from Xilinx very useful. The image processing pipeline, which is from the image sensor output to the real image formed, actually consists of multiple stages :

  • Defect Pixel Correction
  • Color Filter Array (demosaicking)
  • Color Correction Matrix
  • Gamma Correction

These processes are exactly what that had been done in digital cameras, to produce a JPEG image. After getting these things clear in mind, I hope that by next week I would be able to finalize the demosaicking algorithm that would be used for, and sketching the schematic for it.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.