如何使用MKL FFT计算真实图像的卷积

发布于 2025-01-29 16:58:38 字数 1029 浏览 4 评论 0原文

我正在尝试使用MKL API中的FFT实现来计算两个图像的卷积。 步骤是:

  • 计算两个图像的FFT
  • 乘以频谱
  • 计算逆FFT,即卷积矩阵。

我成功地将图像从实现的图像转换为使用此描述符的复杂值:

dataSize[0] = OpRows;
dataSize[1] = OpCols;

DataStrides[0] = 0;
DataStrides[1] = OpCols;
DataStrides[2] = 1;

DftiCreateDescriptor(&_descriptor_F, DFTI_SINGLE, DFTI_COMPLEX, 2, dataSize);
DftiSetValue(_descriptor_F, DFTI_INPUT_STRIDES, DataStrides);
DftiSetValue(_descriptor_F, DFTI_OUTPUT_STRIDES, DataStrides);
DftiSetValue(_descriptor_F, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
DftiCommitDescriptor(_descriptor_F);

cv::Mat dst = cv::Mat(src.size(), CV_32FC2);
DftiComputeForward(_descriptor_F, (MKL_Complex8*)src.data, (MKL_Complex8*)dst.data);

(cv :: mat是OpenCV使用的图像格式)。 对于复杂数组的乘法,此功能:

    vcMulByConj(...);

但是,我想计算FFT,在描述符构造函数中设置FLAG DFTI_REAL。

问题在于,如果以某种格式包装不允许使用vcmulbyconj(...); 我发现了IPP的一些功能可以解开这种类型的数组,但是,我希望使用一个指定包装格式的标志类似的vcmulbyconj(...)。

就我搜索而言,我找不到任何解决此问题的东西(也有一些基本示例)。

任何帮助将受到欢迎。

I'm trying to compute the convolution of two images using the FFT implementation in mkl API.
The steps are:

  • Calculate the FFT of the two images
  • Multiply the spectra
  • Calculate the inverse FFT, that is the convolution matrix.

I succeeded converting the images from real-valued to complex-valued using this descriptor:

dataSize[0] = OpRows;
dataSize[1] = OpCols;

DataStrides[0] = 0;
DataStrides[1] = OpCols;
DataStrides[2] = 1;

DftiCreateDescriptor(&_descriptor_F, DFTI_SINGLE, DFTI_COMPLEX, 2, dataSize);
DftiSetValue(_descriptor_F, DFTI_INPUT_STRIDES, DataStrides);
DftiSetValue(_descriptor_F, DFTI_OUTPUT_STRIDES, DataStrides);
DftiSetValue(_descriptor_F, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
DftiCommitDescriptor(_descriptor_F);

cv::Mat dst = cv::Mat(src.size(), CV_32FC2);
DftiComputeForward(_descriptor_F, (MKL_Complex8*)src.data, (MKL_Complex8*)dst.data);

(cv::Mat is the image format used by Opencv).
And for the multiplication of complex arrays this function:

    vcMulByConj(...);

However, I'd like to calculate the FFT, setting the flag DFTI_REAL in the descriptor constructor.

The problem is that the resulting transformation if packed in some format that doesn't allow the usage of vcMulByConj(...);
I found some functions from IPPs that unpack this type of array, however, I'd like something similar to vcMulByConj(...) with a flag that specifies the packed format.

As far as I searched, I couldn't find anything (also with some basic examples) that solves this issue.

Any help would be welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文