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

◆ transform_outliers() [2/2]

template<OperationReadyData DataType, typename TransformFunc >
requires std::invocable<TransformFunc, double>
DataType MayaFlux::Yantra::transform_outliers ( DataType &  input,
double  std_dev_threshold,
TransformFunc  transform_func,
std::vector< std::vector< double > > &  working_buffer 
)

Statistical outlier transformation using existing StatisticalAnalyzer (OUT-OF-PLACE)

Template Parameters
DataTypeOperationReadyData type
TransformFuncFunction type for transformation
Parameters
inputInput data - will NOT be modified
std_dev_thresholdStandard deviation threshold for outliers
transform_funcTransformation function
working_bufferBuffer for operations (will be resized if needed)
Returns
Transformed data

Definition at line 276 of file MatrixHelper.hpp.

280{
281 auto [target_data, structure_info] = OperationHelper::setup_operation_buffer(input, working_buffer);
282
283 auto stat_analyzer = std::make_shared<StandardStatisticalAnalyzer>();
284 auto stats = stat_analyzer->analyze_statistics(input);
285
286 if (stats.channel_statistics.empty()) {
287 throw std::runtime_error("No channel statistics available for outlier detection");
288 }
289 const auto& first_channel_stats = stats.channel_statistics[0];
290 double threshold_low = first_channel_stats.mean_stat - std_dev_threshold * first_channel_stats.stat_std_dev;
291 double threshold_high = first_channel_stats.mean_stat + std_dev_threshold * first_channel_stats.stat_std_dev;
292
293 for (auto& channel_span : target_data) {
294 std::ranges::transform(channel_span, channel_span.begin(),
295 [&](double x) {
296 return (x < threshold_low || x > threshold_high) ? transform_func(x) : x;
297 });
298 }
299
300 return OperationHelper::reconstruct_from_double<DataType>(working_buffer, structure_info);
301}

References MayaFlux::Yantra::OperationHelper::setup_operation_buffer().

+ Here is the call graph for this function: