SMACC2
Loading...
Searching...
No Matches
cl_rgb::anonymous_namespace{table_survey.cpp} Namespace Reference

Functions

void robustStats (const cv::Mat &channel, const cv::Mat &mask, double &median, double &spread)
 

Function Documentation

◆ robustStats()

void cl_rgb::anonymous_namespace{table_survey.cpp}::robustStats ( const cv::Mat & channel,
const cv::Mat & mask,
double & median,
double & spread )

Definition at line 29 of file table_survey.cpp.

30{
31 std::vector<float> values;
32 values.reserve(static_cast<size_t>(cv::countNonZero(mask)));
33 for (int r = 0; r < channel.rows; ++r)
34 {
35 const float * c = channel.ptr<float>(r);
36 const uchar * m = mask.ptr<uchar>(r);
37 for (int col = 0; col < channel.cols; ++col)
38 {
39 if (m[col])
40 {
41 values.push_back(c[col]);
42 }
43 }
44 }
45 if (values.empty())
46 {
47 median = 0.0;
48 spread = 1.0;
49 return;
50 }
51 const auto mid = values.begin() + static_cast<long>(values.size() / 2);
52 std::nth_element(values.begin(), mid, values.end());
53 median = *mid;
54 for (auto & v : values)
55 {
56 v = std::abs(v - static_cast<float>(median));
57 }
58 std::nth_element(values.begin(), mid, values.end());
59 spread = 1.4826 * *mid;
60}

References robustStats().

Referenced by robustStats().

Here is the call graph for this function:
Here is the caller graph for this function: