Converter translates Bayer raw data to RGB format

-February 04, 2010


 Read More
Design Ideas

CMOS image sensors include the color filters of an RGB (red/green/blue) Bayer array, which lets the sensor detect colors. The image data, the
output from the image sensor, is Bayer raw data (Figure 1). Unfortunately, most consumer-grade image-displaying devices require an RGB-image-data format with red, green, and blue in each pixel’s data. Therefore, you often need a Bayer-raw-data-to-RGB converter between an image sensor and a displaying device. This Design Idea describes such a converter in Verilog HDL (hardware-description language). Click here to download the code to implement into a CPLD or an FPGA.

Converter translates Bayer raw data to RGB format figure 2

To make the design easy to understand, the RGB data is only 24 bits deep. A 320×240-pixel test-bench pattern verifies the design (Figure 2). The image data for red, green, and blue are 88h, 66h, and 22h, respectively. Figure 3 shows the timing of the converter, and Figure 4 shows the flow chart. In Figure 3, the PCLK (processor-clock) signal’s rising edge latches the 24-bit RGB data. Converter translates Bayer raw data to RGB format figure 3The LVAL (line-valid) cap signal is the synchronized line-valid signal for reading the data. The process begins when the FVAL (frame-valid)-data signal goes high. When that action occurs, sensor data begins writing to FIFO1 (first-in/first-out), FIFO2, and the data register. After saving the data, FIFO1 reads out the data. FIFO2 and the data register read their data at the same time. Those readouts occur one clock cycle after FIFO1 starts reading. The next 24-bit RGB data remains the same in the data register, and it combines the data from FIFO1 and FIFO2, which read out at the same rising edge of the clock. The line-count signal shows whether the data is even or odd, which influences the combinational sequences of the data that reads out from FIFO1, FIFO2, and the data register.

Figure 5 is the ModelSim simulation waveform of the converter. The 24-bit RGB output-data values 88h, 66h, and 22h are red, green, and blue data, respectively. The figure shows the 24-bit RGB data as having red, green, and blue values of 88h, 66h, and 22h, respectively, during every line-data period. The line-data period matches the default pixel value in the image data’s test-bench pattern.

Loading comments...

Write a Comment

To comment please Log In