MayaFlux 0.3.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 35 of file MatrixHelper.hpp.

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

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

+ Here is the call graph for this function: