13 std::vector<sample> samples = orig_samples;
15 std::sort(samples.begin(), samples.end(), cmp);
17 cv::Mat_<float> out(out_.size());
24 real shadow_min_depth_diff = 100.0;
25 for(
const sample& samp : samples) {
26 int sx = samp.color_coordinates[0], sy = samp.color_coordinates[1];
27 if(sx < 0 || sx >=
texture_width || sy < 0 || sy >= texture_height)
continue;
29 real new_d = samp.color_depth;
32 int min_x = std::max(sx - shadow_width, 0), max_x = std::min(sx + shadow_width, (
int)
texture_width-1);
33 int min_y = std::max(sy - shadow_width, 0), max_y = std::min(sy + shadow_width, (
int)texture_height-1);
34 for(
int x = min_x; x <= max_x; ++x)
if(x != sx)
35 for(
int y = min_y; y <= max_y; ++y)
if(y != sy) {
36 if(! sparse_mask(y, x))
continue;
37 if(sparse(y, x) - new_d > shadow_min_depth_diff) sparse_mask(y, x) = 0;
40 sparse(sy, sx) = new_d;
41 sparse_mask(sy, sx) = 0xff;
57 #pragma omp parallel for 60 uchar& mask = out_mask(py, px);
61 float& d = out(py, px);
63 if(sparse_mask(py, px)) {
69 int min_dist = rad*rad;
70 real min_dist_d = 0.0;
74 int samples_count = 0;
78 int min_x = std::max(px - rad, 0), max_x = std::min(px + rad, (
int)texture_width-1);
79 int min_y = std::max(py - rad, 0), max_y = std::min(py + rad, (
int)texture_height-1);
80 for(
int sx = min_x; sx <= max_x; ++sx)
if(sx != px)
81 for(
int sy = min_y; sy <= max_y; ++sy)
if(sy != py) {
82 if(! sparse_mask(sy, sx))
continue;
84 real sd = sparse(sy, sx);
86 int off_x = sx - px, off_y = sy - py;
88 int dist = std::max(std::abs(off_x), std::abs(off_y));
89 int euc_sq_dist = off_x*off_x + off_y*off_y;
91 if(euc_sq_dist > rad_sq)
continue;
107 if(samples_count > 0) {
109 if(min_dist < accept_dist) d = min_dist_d;
114 cv::medianBlur(out, out, 3);
constexpr std::size_t texture_height
void densify(const std::vector< sample > &samples, cv::Mat_< real > &out, cv::Mat_< uchar > &out_mask) override
constexpr std::size_t texture_width