Open nburrus opened 12 years ago
According to Cristobal Belles:
//=============47 ms en un i7
for_all_rc(m_image->depthMaskRef()) { float d = m_image->depth()(r,c); if (d < 1e-5 || ntk::math::isnan(d)) m_image->depthMaskRef()(r,c) = 0; else m_image->depthMaskRef()(r,c) = 255; }
//=============
Equivalent code, faster in debug mode:
//=============3 ms
cv::Mat1b& depth_mask = m_image->depthMaskRef(); const cv::Mat1f& depth = m_image->depth(); for (int r = 0; r < depth_mask.rows; ++r) { unsigned char* f_depth_mask = depth_mask.ptr<unsigned char>(r); const float* f_depth = depth.ptr<float>(r); for (int c = 0; c < depth_mask.cols; ++c) { float d = f_depth[c]; if (d < 1e-5 || ntk::math::isnan(d)) f_depth_mask[c] = 0; else f_depth_mask[c] = 255; } }
According to Cristobal Belles:
//=============47 ms en un i7
//=============
Equivalent code, faster in debug mode:
//=============3 ms