Logo Search packages:      
Sourcecode: libgphoto2 version File versions

static int do_rb_ctr_row ( unsigned char *  image_h,
unsigned char *  image_v,
int  w,
int  h,
int  y,
int *  pos_code 
) [static]

Missing reds and/or blues are reconstructed on a single row.

Parameters:
image_h three-row window, horizontal interpolation of row 1 is done
image_v three-row window, vertical interpolation of row 1 is done
w width of image
h height of image.
y row number from image which is under construction
pos_code position code related to Bayer tiling in use

Definition at line 99 of file ahd_bayer.c.

References GP_OK.

Referenced by gp_ahd_interpolate().

{
      int x, bayer;
      int value,value2,div,color;
      /*
       * pos_code[0] = red. green lrtb, blue diagonals 
       * pos_code[1] = green. red lr, blue tb 
       * pos_code[2] = green. blue lr, red tb 
       * pos_code[3] = blue. green lrtb, red diagonals 
       *
       * The Red channel reconstruction is R=G+L(Rs-Gs), in which
       *    G = interpolated & known Green
       *    Rs = known Red
       *    Gs = values of G at the positions of Rs
       *    L()= should be a 2D lowpass filter, now we'll check 
       *    them from a 3x3 square
       *    L-functions' convolution matrix is 
       *    [1/4 1/2 1/4;1/2 1 1/2; 1/4 1/2 1/4]
       * 
       * The Blue channel reconstruction uses exactly the same methods.
       */
      for (x = 0; x < w; x++) 
      {
            bayer = (x&1?0:1) + (y&1?0:2);
            for (color=0; color < 3; color+=2) {
                  if ((color==RED && bayer == pos_code[3]) 
                              || (color==BLUE 
                                        && bayer == pos_code[0])) {
                        value=value2=div=0;
                        if (x > 0 && y > 0) {
                              value += image_h[AD(x-1,0,w)+color]
                                    -image_h[AD(x-1,0,w)+GREEN];
                              value2+= image_v[AD(x-1,0,w)+color]
                                    -image_v[AD(x-1,0,w)+GREEN];
                              div++;
                        }
                        if (x > 0 && y < h-1) {
                              value += image_h[AD(x-1,2,w)+color]
                                    -image_h[AD(x-1,2,w)+GREEN];
                              value2+= image_v[AD(x-1,2,w)+color]
                                    -image_v[AD(x-1,2,w)+GREEN];
                              div++;
                        }
                        if (x < w-1 && y > 0) {
                              value += image_h[AD(x+1,0,w)+color]
                                    -image_h[AD(x+1,0,w)+GREEN];
                              value2+= image_v[AD(x+1,0,w)+color]
                                    -image_v[AD(x+1,0,w)+GREEN];
                              div++;
                        }
                        if (x < w-1 && y < h-1) {
                              value += image_h[AD(x+1,2,w)+color]
                                      -image_h[AD(x+1,2,w)+GREEN];
                              value2+= image_v[AD(x+1,2,w)+color]
                                    -image_v[AD(x+1,2,w)+GREEN];
                                                div++;
                        }
                        image_h[AD(x,1,w)+color]=
                                    CLAMP(
                                    image_h[AD(x,1,w)+GREEN]
                                    +value/div);
                        image_v[AD(x,1,w)+color]=
                                    CLAMP(image_v[AD(x,1,w)+GREEN]
                                    +value2/div);
                  } else if ((color==RED && bayer == pos_code[2]) 
                              || (color==BLUE 
                                        && bayer == pos_code[1])) {
                        value=value2=div=0;
                        if (y > 0) {
                              value += image_h[AD(x,0,w)+color]
                                    -image_h[AD(x,0,w)+GREEN];
                              value2+= image_v[AD(x,0,w)+color]
                                    -image_v[AD(x,0,w)+GREEN];
                                    div++;
                        }
                        if (y < h-1) {
                              value += image_h[AD(x,2,w)+color]
                                    -image_h[AD(x,2,w)+GREEN];
                              value2+= image_v[AD(x,2,w)+color]
                                    -image_v[AD(x,2,w)+GREEN];
                              div++;
                        }
                        image_h[AD(x,1,w)+color]=
                                    CLAMP(
                                    image_h[AD(x,1,w)+GREEN]
                                    +value/div);
                        image_v[AD(x,1,w)+color]=
                                    CLAMP(
                                    image_v[AD(x,1,w)+GREEN]
                                    +value2/div);
                  } else if ((color==RED && bayer == pos_code[1]) 
                              || (color==BLUE 
                                        && bayer == pos_code[2])) {
                              value=value2=div=0;
                        if (x > 0) {
                              value += image_h[AD(x-1,1,w)+color]
                                    -image_h[AD(x-1,1,w)+GREEN];
                              value2+= image_v[AD(x-1,1,w)+color]
                                    -image_v[AD(x-1,1,w)+GREEN];
                              div++;
                        }
                        if (x < w-1) {
                              value += image_h[AD(x+1,1,w)+color]
                                    -image_h[AD(x+1,1,w)+GREEN];
                              value2+= image_v[AD(x+1,1,w)+color]
                                    -image_v[AD(x+1,1,w)+GREEN];
                              div++;
                        }
                        image_h[AD(x,1,w)+color]=
                                    CLAMP(
                                    image_h[AD(x,1,w)+GREEN]
                                    +value/div);
                        image_v[AD(x,1,w)+color]=
                                    CLAMP(
                                    image_v[AD(x,1,w)+GREEN]
                                    +value2/div);
                  }
            }
      }
      return GP_OK;
}


Generated by  Doxygen 1.6.0   Back to index