Andrey Filippov - 2004-07-11

Thanks to Corvin Zahn who noticed the problem - wrong colors in the areas of high gradients. Right sides of the white areas on dark background were red, and left sides - blue. It was so because Cb and Cr color components where calculated in for each group of 2x2 (GR/BG) pixels independently and there was no way to tell color from the gradient. New FPGA extracts colors differently - it does so only for R and B pixels according to the standard formulae:
Cb = 0.564*(B-Y)+128
Cr = 0.713*(R-Y)+128
As intensity (Y) is already calculated for each pixel taking into account the pixel itself and 8 neighbors, this calculation it is not sensitive to gradients (and uses less resources too).

Additionally Bayer->YCbCr converter is made more universal now to support arbitrary phase of Bayer pattern - 0 (GR/BG), 1 (RG/GB), 2 (BG/GR) and 3 (GB/RG). There is no software support yet but it is possible to control the phase right now with bits 1 and 2 of the FPGA control register (i.e. "hello -c 1 3" and "hello -c 2 3"). Also "skip first line" (register bit 7) feature is added to sensor data input ("skip 1-st pixel" - control register bit 5 was implemented earlier and used in the driver). So now it is possible to adjust input tiles to the sensor window (in Micron sensors the first pixel always had even coordinates) and independently specify the color filters phase. That can improve processing in decimation modes as when skipping rows/columns groups of 2x2 pixels are preserved, so in the output data even pixels are neighbors with the next odd, but not to the previous ones.

For now only the FPGA code is updated, not the drivers (but it will work with old software 6.2.19A3 or later). To try new color processing you may just update fpga/x3x3/x313.bit from the CVS. It is possible to update this file in the camera (etc/x313.bit) using ftp (root/pass) without installing new flash image.
When you reboot camera with new version x313.bit you may verify its version with
fpcf -r 13
command - it should return 03130053.