/** * @file alg_ccm.h * @brief color correction algorithm definition * @author Patrick Roth - roth@stettbacher.ch * @copyright Stettbacher Signal Processing AG * * @remarks * *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* 
* */ /* * This code inplements color correction algorithm and is pixel size independent. Including this code at the * C-Source file will define the pixel-bit-depth (see color.c). */ // static void rgb_color_correction8(uint8_t *img_calib, const uint8_t *img_uncalib, const int color_bit_depth, const int height, const int width, float a[3][3]) // static void rgb_color_correction16(uint16_t *img_calib, const uint16_t *img_uncalib, const int color_bit_depth, const int height, const int width, float a[3][3]) { int y, x; int uncal_red, uncal_green, uncal_blue; int cal_red, cal_green, cal_blue; int index; int pix_max_val; const int shift_fact = 16; const int a11 = (int) (a[0][0]*(1<> shift_fact; cal_green = (uncal_red*a21 + uncal_green*a22 + uncal_blue*a23) >> shift_fact; cal_blue = (uncal_red*a31 + uncal_green*a32 + uncal_blue*a33) >> shift_fact; // range check if(cal_red > pix_max_val) cal_red = pix_max_val; else if(cal_red < 0) cal_red = 0; if(cal_green > pix_max_val) cal_green = pix_max_val; else if(cal_green < 0) cal_green = 0; if(cal_blue > pix_max_val) cal_blue = pix_max_val; else if(cal_blue < 0) cal_blue = 0; // save calibrated color values at output image img_calib[index] = cal_red; img_calib[index+1] = cal_green; img_calib[index+2] = cal_blue; index += 3; } } }