18 #ifndef PIC_FILTERING_FILTER_WHITE_BALANCE_HPP 19 #define PIC_FILTERING_FILTER_WHITE_BALANCE_HPP 21 #include "../util/std_util.hpp" 23 #include "../filtering/filter.hpp" 24 #include "../util/array.hpp" 50 int width = src[0]->width;
51 int channels = src[0]->channels;
52 float *data = src[0]->data;
54 int transformChannels =
MIN(channels,
nWhite);
56 for(
int j = box->
y0; j < box->y1; j++) {
59 for(
int i = box->
x0; i < box->x1; i++) {
61 int ind = indOut * channels;
63 for(
int k = 0; k < transformChannels; k++) {
64 dst->
data[ind + k] = data[ind + k] *
white[k];
116 float *out =
new float[
nWhite];
118 for(
int i = 0; i <
nWhite; i++) {
120 out[i] = white_mean /
white[i];
141 if(bComputeScalingFactors) {
144 this->white =
new float[
nWhite];
145 memcpy(this->white,
white,
sizeof(
float) *
nWhite);
148 for(
unsigned int i = 0; i <
nWhite; i++) {
149 if(fabsf(this->white[i]) <= 1e-9
f) {
150 this->white[i] = 1.0f;
164 if(imgIn == NULL || white_color == NULL) {
189 float *white_color = NULL;
194 white_color = (*imgIn)(x, y);
196 BBox patch(x - patchSize, x + patchSize, y - patchSize, y + patchSize);
197 white_color = imgIn->
getMeanVal(&patch, NULL);
200 out =
execute(imgIn, white_color, out);
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
int channels
Definition: image.hpp:80
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
float * getMeanVal(BBox *box, float *ret)
getMeanVal computes the mean for the current Image.
The Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_white_balance.hpp:44
T * delete_vec_s(T *data)
delete_vec_s
Definition: std_util.hpp:138
float * white
Definition: filter_white_balance.hpp:35
FilterWhiteBalance()
FilterWhiteBalance.
Definition: filter_white_balance.hpp:76
int y0
Definition: bbox.hpp:32
static float * getScalingFactors(float *white, int nWhite)
getScalingFactors
Definition: filter_white_balance.hpp:108
static Image * execute(Image *imgIn, int x, int y, bool bRobust=true, Image *out=NULL)
execute
Definition: filter_white_balance.hpp:183
The FilterWhiteBalance class.
Definition: filter_white_balance.hpp:31
static T sum(T *data, int size)
sum
Definition: array.hpp:416
int nWhite
Definition: filter_white_balance.hpp:36
#define MIN(a, b)
Definition: math.hpp:69
The Image class stores an image as buffer of float.
Definition: image.hpp:60
static Image * execute(Image *imgIn, float *white_color, Image *out)
execute
Definition: filter_white_balance.hpp:162
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
void update(float *white, unsigned int nWhite, bool bComputeScalingFactors)
update
Definition: filter_white_balance.hpp:135
~FilterWhiteBalance()
Definition: filter_white_balance.hpp:96
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
FilterWhiteBalance(float *white, unsigned int nWhite, bool bComputeScalingFactors)
FilterWhiteBalance.
Definition: filter_white_balance.hpp:88