convolve namespace
#include <include/spice-lib/convolution.hpp>
Groups various convolution methods together.
Contents
- Reference
Functions
-
template<typename T, size_t Channels, size_t Filter_Channels = Channels>auto spatial(image<T, Channels> img, image<T, Filter_Channels> filter) -> image<T, Channels>
- Convolves
imgwithfilter -
template<typename T, size_t Channels, size_t Filter_Channels = Channels>auto separable(image<T, Channels> img, image<T, Filter_Channels> filter_h, image<T, Filter_Channels> filter_v) -> image<T, Channels>
- Convolves
imghorizontally withfilter_hand vertically withfilter_v -
template<typename T, size_t Channels, size_t Filter_Channels = Channels>auto separable(image<T, Channels> img, image<T, Filter_Channels> filter) -> image<T, Channels>
- Convolves
imgwithfilterby separatingfilterinto two vectorsFvandFhsuch thatfilter == mul(Fv, Fh) -
template<typename T, size_t Channels, size_t Filter_Channels = Channels>auto frequency_space(image<T, Channels> img, image<T, Filter_Channels> filter, size_t n_threads = 1) -> image<T, Channels>
- Convolves
imgwithfilterby multiplying the two in frequency space.
Function documentation
template<typename T, size_t Channels, size_t Filter_Channels = Channels>
image<T, Channels> spice:: convolve:: spatial(image<T, Channels> img,
image<T, Filter_Channels> filter)
Convolves img with filter
| Template parameters | |
|---|---|
| T | |
| Channels | |
| Filter_Channels | |
| Parameters | |
| img | |
| filter | |
| Returns | image<T, Channels> |
Keep in mind that straight up spatial convolution is expensive. If the filter is separable, i.e. the kernel matrix has a rank of 1, consider using convolution::separable instead.
This function exists mainly as a generalised implementation to be used in the imlpementations of convolution::separable.
template<typename T, size_t Channels, size_t Filter_Channels = Channels>
image<T, Channels> spice:: convolve:: separable(image<T, Channels> img,
image<T, Filter_Channels> filter_h,
image<T, Filter_Channels> filter_v)
Convolves img horizontally with filter_h and vertically with filter_v
| Template parameters | |
|---|---|
| T | |
| Channels | |
| Filter_Channels | |
| Parameters | |
| img | |
| filter_h | |
| filter_v | |
| Returns | image<T, Channels> |
filter_h is assumed to be of height 1 and filter_v is assumed to be of width 1.
template<typename T, size_t Channels, size_t Filter_Channels = Channels>
image<T, Channels> spice:: convolve:: separable(image<T, Channels> img,
image<T, Filter_Channels> filter)
Convolves img with filter by separating filter into two vectors Fv and Fh such that filter == mul(Fv, Fh)
| Template parameters | |
|---|---|
| T | |
| Channels | |
| Filter_Channels | |
| Parameters | |
| img | |
| filter | |
| Returns | image<T, Channels> |
This function assumes that the passed kernel is separable, i.e. has rank 1
template<typename T, size_t Channels, size_t Filter_Channels = Channels>
image<T, Channels> spice:: convolve:: frequency_space(image<T, Channels> img,
image<T, Filter_Channels> filter,
size_t n_threads = 1)
Convolves img with filter by multiplying the two in frequency space.
| Template parameters | |
|---|---|
| T | |
| Channels | |
| Filter_Channels | |
| Parameters | |
| img | |
| filter | |
| n_threads | |
| Returns | image<T, Channels> |