18 #ifndef PIC_FILTERING_FILTER_GUIDED_A_B_HPP 19 #define PIC_FILTERING_FILTER_GUIDED_A_B_HPP 21 #include "../filtering/filter.hpp" 23 #include "../util/array.hpp" 25 #include "../util/matrix_3_x_3.hpp" 27 #include "../util/math.hpp" 97 width = imgIn[0]->width;
98 height = imgIn[0]->height;
100 frames = imgIn[0]->frames;
110 auto n = imgIn.
size();
129 auto n = imgIn.
size();
176 float *p_mean =
new float [p->
channels];
178 for(
int j = box->
y0; j < box->y1; j++) {
179 for(
int i = box->
x0; i < box->x1; i++) {
180 float *tmpQ = (*q)(i, j);
189 for(
int c = 0; c < p->
channels; c++) {
190 float I_mean_p_mean = I_mean * p_mean[c];
195 float *I_i = (*I)(i + l, j + k);
196 float *p_i = (*p)(i + l, j + k);
197 a += I_i[0] * p_i[c] - I_mean_p_mean;
202 float b = p_mean[c] - a * I_mean;
217 float *I_mean =
new float[I->
channels];
218 float *p_mean =
new float[p->
channels];
221 float *tmp_A =
new float[I->
channels];
225 for(
int j = box->
y0; j < box->y1; j++) {
226 for(
int i = box->
x0; i < box->x1; i++) {
227 float *tmpQ = (*q)(i, j);
242 for(
int c = 0; c < p->
channels; c++) {
248 float *I_i = (*I)(i + l, j + k);
249 float *p_i = (*p)(i + l, j + k);
251 for(
int n = 0; n < I->
channels; n++) {
252 tmp_A[n] += I_i[n] * p_i[c] - I_mean[n] * p_mean[c];
260 a = inv.
mul(tmp_A, a);
265 for(
int n = 0; n < I->
channels; n++) {
271 tmpQ[index] = p_mean[c] - a_dot_I_mean;
float data[9]
Definition: matrix_3_x_3.hpp:37
float * getCovMtxVal(float *meanVal, BBox *box, float *ret)
getCovMtxVal computes the convariance matrix for the current Image.
Matrix3x3 mul(const Matrix3x3 &mtx)
mul
Definition: matrix_3_x_3.hpp:116
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int size() const
size computes the number of values.
Definition: image.hpp:481
FilterGuidedAB(int radius, float e_regularization)
FilterGuidedAB.
Definition: filter_guided_a_b.hpp:82
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.
void add(float value)
Add adds a value to the diagonal.
Definition: matrix_3_x_3.hpp:234
FilterGuidedAB()
FilterGuidedAB.
Definition: filter_guided_a_b.hpp:72
The Matrix3x3 class provides methods for managing a 3 by 3 matrix.
Definition: matrix_3_x_3.hpp:29
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_guided_a_b.hpp:278
float e_regularization
Definition: filter_guided_a_b.hpp:39
Matrix3x3 * inverse(Matrix3x3 *ret)
inverse computes the inverse of the matrix.
Definition: matrix_3_x_3.hpp:257
Image * getI(ImageVec &imgIn)
getI
Definition: filter_guided_a_b.hpp:108
int y0
Definition: bbox.hpp:32
void Process3Channel(Image *I, Image *p, Image *q, BBox *box)
Process3Channel.
Definition: filter_guided_a_b.hpp:214
PIC_INLINE ImageVec Double(Image *img1, Image *img2)
Double creates an std::vector which contains img1 and img2; this is for filters input.
Definition: image_vec.hpp:49
float nPixels
Definition: filter_guided_a_b.hpp:39
#define PIC_INLINE
Definition: base.hpp:33
The FilterGuidedAB class.
Definition: filter_guided_a_b.hpp:34
void update(int radius, float e_regularization)
update
Definition: filter_guided_a_b.hpp:165
static T dot(T *data0, T *data1, int n)
dot
Definition: array.hpp:281
The Image class stores an image as buffer of float.
Definition: image.hpp:60
static void div(T *data, int size, T value)
div
Definition: array.hpp:353
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
Definition: bilateral_separation.hpp:25
void Process1Channel(Image *I, Image *p, Image *q, BBox *box)
Process1Channel.
Definition: filter_guided_a_b.hpp:172
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_guided_a_b.hpp:95
int radius
Definition: filter_guided_a_b.hpp:38
static Image * execute(Image *imgIn, Image *guide, Image *imgOut, int radius, float e_regularization)
execute
Definition: filter_guided_a_b.hpp:157
float * getVarianceVal(float *meanVal, BBox *box, float *ret)
getVarianceVal computes the variance for the current Image.
Image * getp(ImageVec &imgIn)
getp
Definition: filter_guided_a_b.hpp:127