Summary
This demonstration shows how to use the data-driven detector array feature to simulate a color filter array (CFA) focal plane. Specifically the 3-color, Bayer pattern is modeled. An figure illustrating the layout of red, green and blue filters in a Bayer pattern array is shown below:
The output is a single-channel image containing the mosaic’ed red, green and blue pixel values.
Pixel Database
The key component to this simulation is the "pixel database" file. This file describes each pixel in the array via an ASCII/Text file where each line includes a geometry and (optional) radiometric description of a pixel. The data-driven array mechanism allows each pixel record (or line) to include a user-defined number of "attribute" fields followed by a set of required fields. These optional "attribute" fields allow a very large database of pixels to be sub-selected at run-time. In the example presented here, we included two "attribute" fields that indicate the X/Y coordinates of the pixel. Note, there is not a master list of allowed fields. These fields are 100% user-driven and can be any alpha-numeric sequence that doesn’t include spaces. For example, you could have the first field be used to hold the "band" a given pixel belongs to and that field could contain the value "1" or the word "blue" for all the pixels in the "blue band". The only role these "attribute" fields have is in support of the run-time selection mechanism, which is discussed later.
The required geometric fields for each pixel include:
-
The X-axis pointing angle in radians
-
The Y-axis pointing angle in radians
-
The X-axis instantaneous field-of-view (IFOV) in radians
-
The Y-axis instantaneous field-of-view (IFOV) in radians
Note that in the DIRSIG platform model, the Y-axis is the nominal along-track axis of the platform, but the local focal plane coordinate system is subject to any of the various affine transforms included in the platform attachments and mounts.
The required geometric fields are followed by a set of optional radiometric fields. In this includes:
-
The spectral response model index
-
The gain response model index
-
The noise response model index
Generating a Pixel Database
In this example, we wrote a small C++ program to generate the
pixel database file (this program is included as bayer.cpp
).
However, this same file could have been generated in Excel or
any other environment that can export data as ASCII/Text. The
program is very simple an uses a set of hard-coded parameters
that could be made into variables in a more complicated example.
These fixed parameters include:
-
The focal length of the system (100 mm, in this example)
-
The pixel pitch or size (20 microns, in this example)
-
The Bayer filter pattern
The program then iterates through each pixel in the 320 x 240 array, and for each pixel:
-
It computes the X/Y angles using the pixel location, focal length and simple trigonometry
-
It computes the X/Y IFOV angles using the pixel size, focal length and simple trigonometry
-
It determines the appropriate color filter index using the Bayer Pattern rules
In this example, only the spectral response model was varied by pixel and this is the key element of this demonstration. The platform model has a set of red, green and blue spectral response functions (see image below). By varying the spectral response model index on a per-pixel basis, we encode the Bayer pattern into the array.
Example Pixel Database
The following excerpts from the pixels.dat
file shows the general
layout of the pixel database file employed in this example:
0 0 -0.0639128 -0.0479632 0.0002 0.0002 0
1 0 -0.0637136 -0.0479632 0.0002 0.0002 1
2 0 -0.0635145 -0.0479632 0.0002 0.0002 0
3 0 -0.0633153 -0.0479632 0.0002 0.0002 1
...
638 0 0.0635145 -0.0479632 0.0002 0.0002 0
639 0 0.0637136 -0.0479632 0.0002 0.0002 1
0 1 -0.0639128 -0.0477636 0.0002 0.0002 1
1 1 -0.0637136 -0.0477636 0.0002 0.0002 2
...
637 479 0.0633153 0.0477636 0.0002 0.0002 2
638 479 0.0635145 0.0477636 0.0002 0.0002 1
639 479 0.0637136 0.0477636 0.0002 0.0002 2
The first two columns are "attribute fields" containing the X and Y
pixel coordinates. The next 4 columns are the X/Y pixel angles and
the X/Y IFOVs. The final column is the spectral response index, where
0
maps to the blue, 1
maps to the green and 2
maps to the red
filter functions.
Run-Time Pixel Selection
In the description of the array, the user can include an arbitrary number of "attribute fields" which do are not used in the geometric or radiometric modeling of the pixel. In this example, we included the X and Y pixel coordinate as attribute fields, but that was done entirely to make the example easier to understand. In this demo, we do not employ any run-time selection using the attribute fields, but your application may. The run-time selection mechanism uses a set of regular expressions (regexps) to select specific records from the list of pixels. It is beyond the scope of this document to explain how to write regular expressions, but there are cases where you might not want to image every pixel in the database. For example, consider the case where you are modeling a large, modular pushbroom array. In some cases, you might want to only collect data from a single module in the system. If you add an attribute field for the module index (where each module in the array has a unique index), the you can write a simple regexp to select only pixels in that module.
Important
|
The correct number of attribute fields in your pixel database must be provided to DIRSIG so that it can skip these fields and extract the geometric and radiometric data fields. |
Simulation
For the scene, a binary (two color) material map featuring the text "Bayer Pattern" was created. This maps to a pair of high contrast materials (10% and 20% Lambertian reflectors). In the middle of the scene are a set of red, green and blue panels. The image below shows what the scene looks like when imaged with a RGB camera using three focal planes to simultaneously collect red, green and blue.
The platform was positioned at an altitude of 5,000 meters so that the entire map could be imaged. The spatial response of the individual pixels was modeled as a rectuangular (uniform) response using a 5x5 grid sampling.
Output Data
The output of the simulation is a raw pixel stream. The ENVI image header indicates that this is a single band image. Although the focal plane measured 3 colors, it did so by using different filters on different pixels. It does not measure all 3 colors at every pixel. Hence, the color information is modulated within the array and a de-bayering (or demosaicing) algorithm must be employed to extract a 3-color image.
The image below shows the raw radiance image produced by DIRSIG in the DIRSIG Image Viewer tool (note the ENVI image header was modified as described above in order to display the raw data in this 320 x 240 format). Notice that the Bayer pattern is visible in the zoom of the color panels. Also notice that the pixels along the high-contrast edges are not simply black or white because of the spatial response of the detectors.
De-Bayer Algorithm
This demonstration also includes the C++ program debayer.cpp
which
implements simple bi-linear interpolation scheme to interpolate the
color information from neighboring pixels that is not captured by
the current pixel. This program reads in the output DIRSIG image
file and writes out a 24-bit color image file in PNM format. The
PNM image file can be easily converted to another format using the
NetPBM toolbox or by reading it into one of the many image tools
that supports this format.
The image below is the resulting RGB image produced by the debayer program. Notice the artifacting that arises near the high contrast edges of the letters. This results from the interpolation of color information from neighboring pixels. This is a common artifact that occurs in regions with high frequency, high spectral contrast.
Note that the de-bayer program is not the focus of this demonstration. It has the dimensions of the DIRSIG image hard-coded and was written using the same Bayer pattern sequence logic employed by the program to generate the pixel database file. The debayer program source code is included only for the purposes of completeness. In practice, more complicated de-bayer algorithms would be employed with these types of focal planes.
References
-
The Bayer Pattern figure was aquired from Wikipedia: http://en.wikipedia.org/wiki/File:Bayer_pattern_on_sensor.svg
-
A survey of demosaic algorithms for Bayer Pattern focal planes can be found at: http://www.unc.edu/~rjean/demosaicing/demosaicing.pdf