MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ extract_outliers()

std::vector< std::vector< double > > MayaFlux::Yantra::extract_outliers ( const std::vector< std::span< const double > > &  channels,
double  std_dev_threshold,
uint32_t  window_size,
uint32_t  hop_size 
)

Definition at line 64 of file ExtractionHelper.cpp.

69{
70 std::vector<std::vector<double>> result;
71 result.reserve(channels.size());
72 for (const auto& ch : channels) {
73 if (ch.empty()) {
74 result.emplace_back();
75 continue;
76 }
77 const uint32_t w = std::min(window_size, static_cast<uint32_t>(ch.size()));
78 const uint32_t h = std::max(1U, std::min(hop_size, w / 2));
79 const size_t nw = D::num_windows(ch.size(), w, h);
80 const auto means = D::mean(ch, nw, h, w);
81
82 if (means.empty()) {
83 result.emplace_back();
84 continue;
85 }
86
87 double gm = 0.0;
88 for (double v : means)
89 gm += v;
90 gm /= static_cast<double>(means.size());
91
92 double var = 0.0;
93 for (double v : means)
94 var += (v - gm) * (v - gm);
95 const double gs = std::sqrt(var / static_cast<double>(means.size()));
96
97 if (gs <= 0.0) {
98 result.emplace_back();
99 continue;
100 }
101
102 std::vector<size_t> starts;
103 for (size_t i = 0; i < means.size(); ++i) {
104 if (std::abs(means[i] - gm) > std_dev_threshold * gs)
105 starts.push_back(i * h);
106 }
107
108 result.push_back(D::slice_intervals(ch,
109 D::merge_intervals(D::intervals_from_window_starts(starts, w, ch.size()))));
110 }
111
112 return result;
113}

References MayaFlux::Kinesis::Discrete::intervals_from_window_starts(), MayaFlux::Kinesis::Discrete::mean(), MayaFlux::Kinesis::Discrete::merge_intervals(), MayaFlux::Kinesis::Discrete::num_windows(), and MayaFlux::Kinesis::Discrete::slice_intervals().

Referenced by MayaFlux::Yantra::FeatureExtractor< InputType, OutputType >::extract_implementation().

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