28 namespace SourceXtractor {
35 m_variance(variance), m_threshold(threshold) {
40 return "BgConvolutionImageSource(" +
getImageRepr() +
")";
45 int start_x,
int start_y,
int clip_w,
int clip_h,
SeFloat threshold) {
49 for (
int cy = 0; cy < kernel.
getHeight(); ++cy) {
50 for (
int cx = 0; cx < kernel.
getWidth(); ++cx) {
51 int clip_x2 = start_x + cx;
52 int clip_y2 = start_y + cy;
54 if (clip_x2 >= 0 && clip_x2 < clip_w && clip_y2 >= 0 && clip_y2 < clip_h) {
55 if (variance_chunk.
getValue(clip_x2, clip_y2) < threshold) {
57 conv_weight += kernel.
getValue(cx, cy);
69 const int hx =
m_kernel->getWidth() / 2;
70 const int hy =
m_kernel->getHeight() / 2;
71 const int clip_x =
std::max(start_x - hx, 0);
72 const int clip_y =
std::max(start_y - hy, 0);
73 const int clip_w =
std::min(width + hx * 2, image->getWidth() - clip_x);
74 const int clip_h =
std::min(height + hy * 2, image->getHeight() - clip_y);
77 auto image_chunk = image->getChunk(clip_x, clip_y, clip_w, clip_h);
78 auto variance_chunk =
m_variance->getChunk(clip_x, clip_y, clip_w, clip_h);
81 const int off_x = start_x - clip_x;
82 const int off_y = start_y - clip_y;
84 for (
int iy = 0; iy <
height; ++iy) {
85 for (
int ix = 0; ix <
width; ++ix) {
86 if (variance_chunk->getValue(ix + off_x, iy + off_y) <
m_threshold) {
91 ix - hx + off_x, iy - hy + off_y, clip_w, clip_h,
96 tile_image.setValue(ix, iy, total / conv_weight);
99 tile_image.setValue(ix, iy, 0.);