libgphoto2 photo camera library (libgphoto2) Internals
2.5.26
|
Adaptive Homogeneity-Directed Bayer array conversion routine. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "config.h"
#include "bayer.h"
#include <gphoto2/gphoto2-result.h>
#include <gphoto2/gphoto2-port-log.h>
Go to the source code of this file.
Macros | |
#define | MAX(x, y) ((x < y) ? (y) : (x)) |
#define | MIN(x, y) ((x > y) ? (y) : (x)) |
#define | CLAMP(x) MAX(MIN(x,0xff),0) |
#define | RED 0 |
#define | GREEN 1 |
#define | BLUE 2 |
#define | AD(x, y, w) ((y)*(w)*3+3*(x)) |
Functions | |
static int | dRGB (int i1, int i2, unsigned char *RGB) |
This function computes distance^2 between two sets of pixel data. More... | |
static int | do_rb_ctr_row (unsigned char *image_h, unsigned char *image_v, int w, int h, int y, int *pos_code) |
Missing reds and/or blues are reconstructed on a single row. More... | |
static int | do_green_ctr_row (unsigned char *image, unsigned char *image_h, unsigned char *image_v, int w, int h, int y, int *pos_code) |
Missing greens are reconstructed on a single row. More... | |
static int | get_diffs_row2 (unsigned char *hom_buffer_h, unsigned char *hom_buffer_v, unsigned char *buffer_h, unsigned char *buffer_v, int w) |
Differences are assigned scores across row 2 of buffer_v, buffer_h. More... | |
int | gp_ahd_interpolate (unsigned char *image, int w, int h, BayerTile tile) |
Interpolate a expanded bayer array into an RGB image. More... | |
int | gp_ahd_decode (unsigned char *input, int w, int h, unsigned char *output, BayerTile tile) |
Convert a bayer raster style image to a RGB raster. More... | |
Adaptive Homogeneity-Directed Bayer array conversion routine.
Definition in file ahd_bayer.c.
#define AD | ( | x, | |
y, | |||
w | |||
) | ((y)*(w)*3+3*(x)) |
Definition at line 72 of file ahd_bayer.c.
#define BLUE 2 |
Definition at line 58 of file ahd_bayer.c.
Definition at line 55 of file ahd_bayer.c.
#define GREEN 1 |
Definition at line 57 of file ahd_bayer.c.
#define MAX | ( | x, | |
y | |||
) | ((x < y) ? (y) : (x)) |
Definition at line 53 of file ahd_bayer.c.
#define MIN | ( | x, | |
y | |||
) | ((x > y) ? (y) : (x)) |
Definition at line 54 of file ahd_bayer.c.
#define RED 0 |
Definition at line 56 of file ahd_bayer.c.
|
static |
Missing greens are reconstructed on a single row.
image | the image which is being reconstructed |
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 233 of file ahd_bayer.c.
References AD, BLUE, CLAMP, GP_OK, GREEN, and RED.
Referenced by gp_ahd_interpolate().
|
static |
Missing reds and/or blues are reconstructed on a single row.
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 97 of file ahd_bayer.c.
References AD, BLUE, CLAMP, GP_OK, GREEN, and RED.
Referenced by gp_ahd_interpolate().
|
static |
This function computes distance^2 between two sets of pixel data.
i1 | location of a pixel |
i2 | location of another pixel |
RGB | some RGB data. |
Definition at line 80 of file ahd_bayer.c.
References BLUE, GREEN, and RED.
Referenced by get_diffs_row2().
|
static |
Differences are assigned scores across row 2 of buffer_v, buffer_h.
hom_buffer_h | tabulation of scores for buffer_h |
hom_buffer_v | tabulation of scores for buffer_v |
buffer_h | three-row window, scores assigned for pixels in row 2 |
buffer_v | three-row window, scores assigned for pixels in row 2 |
w | pixel width of image and buffers |
Definition at line 327 of file ahd_bayer.c.
References dRGB(), GP_OK, MAX, and MIN.
Referenced by gp_ahd_interpolate().
int gp_ahd_decode | ( | unsigned char * | input, |
int | w, | ||
int | h, | ||
unsigned char * | output, | ||
BayerTile | tile | ||
) |
Convert a bayer raster style image to a RGB raster.
input | the bayer CCD array as linear input |
w | width of the above array |
h | height of the above array |
output | RGB output array (linear, 3 bytes of R,G,B for every pixel) |
tile | how the 2x2 bayer array is laid 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 and interpolates the bayer array to 3 times larger bitmap with RGB values interpolated. It does the same job as gp_bayer_decode() but it calls gp_ahd_interpolate() instead of calling gp_bayer_interpolate(). Use this instead of gp_bayer_decode() if you want to use or to test AHD interpolation in a camera library.
Definition at line 640 of file ahd_bayer.c.
References gp_ahd_interpolate(), gp_bayer_expand(), and GP_OK.
int gp_ahd_interpolate | ( | unsigned char * | image, |
int | w, | ||
int | h, | ||
BayerTile | tile | ||
) |
Interpolate a expanded bayer array into an RGB image.
image | the linear RGB array as both input and output |
w | width of the above array |
h | height of the above array |
tile | how the 2x2 bayer array is laid out |
This function interpolates a bayer array which has been pre-expanded by gp_bayer_expand() to an RGB image. It applies the method of adaptive homogeneity-directed demosaicing.
Definition at line 418 of file ahd_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, do_green_ctr_row(), do_rb_ctr_row(), get_diffs_row2(), GP_ERROR_NO_MEMORY, and GP_OK.
Referenced by gp_ahd_decode().