35 : m_weight_type(weight_type) {
36 assert(cell_size.
size() > 0 && cell_size.
size() < 3);
37 assert(smoothing_box.
size() > 0 && smoothing_box.
size() < 3);
47 ratios.
reserve(variance->getWidth() * variance->getHeight());
49 for (
int y = 0;
y < variance->getHeight(); ++
y) {
50 for (
int x = 0;
x < variance->getWidth(); ++
x) {
51 auto w = weight->getValue(
x,
y);
53 auto v = variance->getValue(
x,
y);
54 auto ratio = (v * v) / w;
63 if (ratios.
size() % 2 == 1) {
64 return ratios[ratios.
size() / 2];
66 return (ratios[ratios.
size() / 2] + ratios[ratios.
size() / 2 - 1]) / 2;
72 auto nitems = v.size();
73 if (nitems % 2 == 1) {
76 return (v[nitems / 2] + v[nitems / 2 - 1]) / 2;
85 if (mask !=
nullptr) {
86 bck_model_logger.
debug() <<
"\tMask image with size: (" << mask->getWidth() <<
"," << mask->getHeight() <<
")";
89 if (image->getWidth() != mask->getWidth())
90 throw Elements::Exception() <<
"X-dims do not match: image=" << image->getWidth() <<
" mask=" << mask->getWidth();
91 if (image->getHeight() != mask->getHeight())
92 throw Elements::Exception() <<
"Y-dims do not match: image=" << image->getHeight() <<
" mask="
98 if (variance_map !=
nullptr) {
100 << variance_map->getHeight() <<
")";
102 if (image->getWidth() != variance_map->getWidth())
103 throw Elements::Exception() <<
"X-dims do not match: image=" << image->getWidth() <<
" variance="
104 << variance_map->getWidth();
105 if (image->getHeight() != variance_map->getHeight())
106 throw Elements::Exception() <<
"Y-dims do not match: image=" << image->getHeight() <<
" variance="
107 << variance_map->getHeight();
111 image, variance_map, mask_value, variance_threshold);
113 variance_map, variance_map, mask_value, variance_threshold);
152 final_var, image->getWidth(), image->getHeight(),
159 median_sigma * median_sigma);
162 bck_model_logger.
info() <<
"Background for image: " << image->getRepr() <<
" median: " << median
163 <<
" rms: " << median_sigma <<
"!";
167 mode, image->getWidth(), image->getHeight(),