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

◆ transform_normalize() [1/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_normalize ( DataType &  input,
const std::pair< double, double > &  target_range,
std::vector< std::vector< double > > &  working_buffer 
)

Normalize transformation using existing infrastructure (OUT-OF-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - will NOT be modified
target_rangeTarget range [min, max]
working_bufferBuffer for operations (will be resized if needed)
Returns
Normalized data

Definition at line 577 of file MathematicalHelper.hpp.

578{
579 auto [target_data, structure_info] = OperationHelper::setup_operation_buffer(input, working_buffer);
580
581 for (auto& span : target_data) {
582 auto [min_it, max_it] = std::ranges::minmax_element(span);
583 double current_min = *min_it;
584 double current_max = *max_it;
585
586 if (current_max == current_min)
587 return input;
588
589 double current_range = current_max - current_min;
590 double target_min = target_range.first;
591 double target_max = target_range.second;
592 double target_span = target_max - target_min;
593
594 std::ranges::transform(span, span.begin(),
595 [current_min, current_range, target_span, target_min](double x) {
596 return ((x - current_min) / current_range) * target_span + target_min;
597 });
598 }
599
600 return OperationHelper::reconstruct_from_double<DataType>(working_buffer, structure_info);
601}

References transform_normalize().

+ Here is the call graph for this function: