Reputation: 1025
Is there a function in OpenCV which takes a complex matrix as a kernel to convolve/filter an image?
Upvotes: 1
Views: 2257
Reputation: 101
It may be of use to someone.
There is no need to split real and imaginary parts. It suffices instead to use this advice of setting ddepth = -1
.
Then an example in c++ is:
//2D complex signal
std::complex< double> *sgl_data = ...
int cols = ...
int rows = ...
cv::Mat sgl = cv::Mat_< std::complex< double>>( rows, cols, sgl_data);
//2D complex kernel
std::complex< double> *knl_data = ...
int knl_cols = ...
int knl_rows = ...
cv::Mat knl = cv::Mat_<std::complex< double>>( knl_rows, knl_cols, knl_data);
//2D complex filtering on original cv::Mat's without splitting anything
cv::filter2D( sgl, sgl, -1, knl);
Upvotes: 0
Reputation: 497
This function filter2D() meets your requirement. Pay attention to the int ddepth
paratmer, when you apply floating-point kernels on uchar
image.
Upvotes: 1