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

◆ transform_regions() [1/2]

template<OperationReadyData DataType, typename TransformFunc >
requires std::invocable<TransformFunc, DataType>
DataType MayaFlux::Yantra::transform_regions ( DataType &  input,
const std::shared_ptr< Kakshya::SignalSourceContainer > &  container,
const std::vector< Kakshya::Region > &  regions,
TransformFunc  transform_func 
)

Region-selective transformation using container-based extraction (IN-PLACE)

Template Parameters
DataTypeOperationReadyData type
TransformFuncFunction type for transformation
Parameters
inputInput data - WILL BE MODIFIED (serves as the target)
containerSignal source container
regionsRegions to transform and place back into input
transform_funcTransformation function
Returns
Transformed data

Definition at line 33 of file MatrixHelper.hpp.

37{
38 if (!container) {
39 throw std::invalid_argument("Container is required for region-based transformations");
40 }
41
42 auto [target_data, structure_info] = OperationHelper::extract_structured_double(input);
43
44 for (const auto& region : regions) {
45 auto region_data = container->get_region_data(region);
46 auto transformed_region = transform_func(region_data);
47 auto transformed_doubles = OperationHelper::extract_numeric_data(transformed_region);
48
49 auto start_sample = static_cast<uint64_t>(region.start_coordinates[0]);
50 auto end_sample = static_cast<uint64_t>(region.end_coordinates[0]);
51
52 for (size_t channel_idx = 0; channel_idx < target_data.size() && channel_idx < transformed_doubles.size(); ++channel_idx) {
53 auto& target_channel = target_data[channel_idx];
54 const auto& transformed_channel = transformed_doubles[channel_idx];
55
56 if (start_sample < target_channel.size() && end_sample <= target_channel.size()) {
57 auto target_span = target_channel.subspan(start_sample, end_sample - start_sample);
58 auto copy_size = std::min(transformed_channel.size(), target_span.size());
59
60 std::ranges::copy(transformed_channel | std::views::take(copy_size),
61 target_span.begin());
62 }
63 }
64 }
65
66 auto reconstructed_data = target_data
67 | std::views::transform([](const auto& span) {
68 return std::vector<double>(span.begin(), span.end());
69 })
70 | std::ranges::to<std::vector>();
71
72 return OperationHelper::reconstruct_from_double<DataType>(reconstructed_data, structure_info);
73}

References MayaFlux::Yantra::OperationHelper::extract_numeric_data(), and MayaFlux::Yantra::OperationHelper::extract_structured_double().

+ Here is the call graph for this function: