18 #ifndef PIC_ALGORITHMS_POISSON_FILLING_HPP 19 #define PIC_ALGORITHMS_POISSON_FILLING_HPP 21 #include "../util/std_util.hpp" 22 #include "../util/buffer.hpp" 23 #include "../util/mask.hpp" 24 #include "../util/array.hpp" 25 #include "../util/math.hpp" 26 #include "../image.hpp" 61 #pragma omp parallel for 63 for(
int i = 0; i < imgIn->
height; i++) {
64 for(
int j = 0; j < imgIn->
width; j++) {
65 float *src = (*imgIn)(j, i);
66 float *n0 = (*imgIn)(j + 1, i);
67 float *n1 = (*imgIn)(j - 1, i);
68 float *n2 = (*imgIn)(j, i + 1);
69 float *n3 = (*imgIn)(j, i - 1);
71 int ind = i * imgIn->
width + j;
73 float *out = (*imgOut)(j, i);
75 for(
int k = 0; k < imgIn->
channels; k++) {
103 out[k] = out[k] / float(div);
112 tmp += -src[k] + n0[k];
117 tmp += -src[k] + n1[k];
122 tmp += -src[k] + n2[k];
127 tmp += -src[k] + n3[k];
131 out[k] = src[k] + tmp / float(div);
197 imgOut = imgIn->
clone();
219 update(work[i % 2], work[(i + 1) % 2]);
Image * execute(Image *imgIn, Image *imgOut, bool *mask=NULL)
execute
Definition: poisson_filling.hpp:177
bool * maskPoisson
Definition: poisson_filling.hpp:39
void assign(const Image *imgIn)
assign
Image * imgTmp
Definition: poisson_filling.hpp:40
static bool * clone(bool *bufferOut, bool *bufferIn, int n, int channels)
clone
Definition: filter_radial_basis_function.hpp:704
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
~PoissonFilling()
Definition: poisson_filling.hpp:156
bool isSimilarType(const Image *img)
isSimilarType checks if the current image is similar to img; i.e. if they have the same width...
static T * genValue(T value, int n, T *ret)
genValue
Definition: array.hpp:132
T * delete_vec_s(T *data)
delete_vec_s
Definition: std_util.hpp:138
void update(Image *imgOut, Image *imgIn)
update
Definition: poisson_filling.hpp:57
The PoissonFilling class.
Definition: poisson_filling.hpp:33
float threshold
Definition: poisson_filling.hpp:37
int nPixels() const
nPixels computes the number of pixels.
Definition: image.hpp:499
float value
Definition: poisson_filling.hpp:37
PoissonFilling(float value)
PoissonFilling.
Definition: poisson_filling.hpp:144
bool * convertToMask(float *color, float threshold, bool cmp, bool *mask)
convertToMask converts an Image into a boolean mask.
static bool empty(bool *dataIn, int width, int height)
MaskEmpty checks if a mask is empty.
Definition: mask.hpp:183
The Image class stores an image as buffer of float.
Definition: image.hpp:60
bool * mask
Definition: poisson_filling.hpp:39
Image * clone() const
Clone creates a deep copy of the calling instance.
void release()
release
Definition: poisson_filling.hpp:45
int maxIter
Definition: poisson_filling.hpp:36
Definition: bilateral_separation.hpp:25
bool isValid()
isValid checks if the current image is valid, which means if they have an allocated buffer or not...
PIC_INLINE bool equalf(float a, float b)
equalf checks if two float values are the same or not.
Definition: math.hpp:119
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
void setup(float value)
setup
Definition: poisson_filling.hpp:165