Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_bayer_expand ( unsigned char *  input,
int  w,
int  h,
unsigned char *  output,
BayerTile  tile 
)

Expand a bayer raster style image to a RGB raster.

Parameters:
inputthe bayer CCD array as linear input
wwidth of the above array
hheight of the above array
outputRGB output array (linear, 3 bytes of R,G,B for every pixel)
tilehow the 2x2 bayer array is layed out

A regular CCD uses a raster of 2 green, 1 blue and 1 red components to cover a 2x2 pixel area. The camera or the driver then interpolates a 2x2 RGB pixel set out of this data.

This function expands the bayer array to 3 times larger bitmap with RGB values copied as-is. Pixels were no sensor was there are 0. The data is supposed to be processed further by for instance gp_bayer_interpolate().

Returns:
a gphoto error code

Definition at line 74 of file bayer.c.

References BAYER_TILE_BGGR, BAYER_TILE_BGGR_INTERLACED, BAYER_TILE_GBRG, BAYER_TILE_GBRG_INTERLACED, BAYER_TILE_GRBG, BAYER_TILE_GRBG_INTERLACED, BAYER_TILE_RGGB, BAYER_TILE_RGGB_INTERLACED, and GP_OK.

{
      int x, y, i;
      int colour, bayer;
      unsigned char *ptr = input;

      switch (tile) {

            case BAYER_TILE_RGGB:
            case BAYER_TILE_GRBG:
            case BAYER_TILE_BGGR:
            case BAYER_TILE_GBRG:

                  for (y = 0; y < h; ++y)
                        for (x = 0; x < w; ++x, ++ptr) {
                              bayer = (x&1?0:1) + (y&1?0:2);

                              colour = tile_colours[tile][bayer];

                              i = (y * w + x) * 3;

                              output[i+RED]    = 0;
                              output[i+GREEN]  = 0;
                              output[i+BLUE]   = 0;
                              output[i+colour] = *ptr;
                        }
                  break;

            case BAYER_TILE_RGGB_INTERLACED:
            case BAYER_TILE_GRBG_INTERLACED:
            case BAYER_TILE_BGGR_INTERLACED:
            case BAYER_TILE_GBRG_INTERLACED:


                  for (y = 0; y < h; ++y, ptr+=w)
                        for (x = 0; x < w; ++x) {
                              bayer = (x&1?0:1) + (y&1?0:2);

                              colour = tile_colours[tile][bayer];
      
                              i = (y * w + x) * 3;

                              output[i+RED]    = 0;
                              output[i+GREEN]  = 0;
                              output[i+BLUE]   = 0;
                              output[i+colour] = (x&1)? ptr[x>>1]:ptr[(w>>1)+(x>>1)];
                        }
                  break;
      }

      return (GP_OK);
}

Generated by  Doxygen 1.6.0   Back to index