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

◆ apply_per_channel()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
template<typename Func >
output_type MayaFlux::Yantra::ConvolutionTransformer< InputType, OutputType >::apply_per_channel ( input_type input,
Func &&  func 
)
inlineprivate

Extracts per-channel spans, applies func to each, and reconstructs.

Template Parameters
FuncCallable matching either void(std::span<double>) or std::vector<double>(std::span<const double>)

In-place: results are copied back into the original channel spans of input. Out-of-place: input is not mutated.

Definition at line 172 of file ConvolutionTransformer.hpp.

173 {
174 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
175 m_working_buffer.resize(channels.size());
176 for (size_t i = 0; i < channels.size(); ++i) {
177 if constexpr (std::is_void_v<std::invoke_result_t<Func, std::span<double>>>) {
178 m_working_buffer[i].assign(channels[i].begin(), channels[i].end());
179 func(std::span<double> { m_working_buffer[i] });
180 } else {
181 m_working_buffer[i] = func(std::span<const double> { channels[i] });
182 }
183 }
184 if (this->is_in_place())
185 for (size_t i = 0; i < channels.size(); ++i)
186 std::ranges::copy(m_working_buffer[i], channels[i].begin());
187 return create_output(
188 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));
189 }
std::vector< std::vector< double > > m_working_buffer
Buffer for out-of-place convolution operations.
output_type create_output(const input_type &input)
Creates output with proper type conversion.
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
virtual bool is_in_place() const
Indicates whether the transformation modifies the input data directly.