Clarify use of cross-correlation for FIR filters #1768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The underlying implementation of the
FirFilter
operator uses thefilter2D
function from OpenCV to efficiently apply the filter.Although the documentation of
filter2D
itself states that it "convolves an image with a kernel", in fact the implementation actually computes the cross-correlation. This is a surprisingly common, if misleading, assumption in the computer vision and image processing field, likely coming from the use of either symmetric kernels (in which case correlation is equal to convolution), or learned kernels (in which case the learning process can easily deal with reversed kernel weights).Nevertheless, the current reference documentation of the operator can be misleading if one is attempting to use
FirFilter
with externally computed asymmetric kernels for temporal convolution. This PR adds a new remarks section clarifying the relationship between correlation and convolution, and how the kernel must be processed to obtain the correct result in case of an asymmetric kernel.Fixes #1761