[英]How to implement 1D FFT filter for each horizontal line data from image
I wish to apply a frequency-domain filter, such as a Low Pass or Band Pass, to each horizontal line of an image. 我希望对图像的每个水平线应用频域滤波器,例如低通或带通。 Is this possible using opencv? 使用opencv可以做到吗?
I think that you will need to elaborate more on your questions. 我认为您将需要详细说明您的问题。 Perhaps, giving some concrete examples. 也许,举一些具体的例子。
If I interpret your question as: 如果我将您的问题解释为:
You have an image with say 10 x 10 您的图片说10 x 10
line 1 1行
line 2 2号线
line 3 ... 第3行...
line 10 第10行
You want to apply some filter (Low Pass/Band Pass) on these lines independently. 您想在这些线上分别应用一些过滤器(低通/带通)。
Then, first you need to design your horizontal filters (in whatever tool you want). 然后,首先需要设计水平滤波器(使用所需的任何工具)。
Let's assume (without loss of generality) that you have 2 filters: 让我们假设(不失一般性)您有2个过滤器:
Low pass: 1x10 image 低通:1x10图像
Band pass: 1x10 image 带通:1x10图像
Then you can use cv::dft to convert these filters into frequency domain. 然后,您可以使用cv :: dft将这些滤波器转换为频域。 Also use cv::dft to convert your image into frequency domain. 还可以使用cv :: dft将图像转换为频域。 Of course, you should convert individual rows separately. 当然,您应该分别转换单个行。 One way to do this is: 一种方法是:
cv::Mat im = cv::imread('myimage.jpg', 1);
cv::Mat one_row_in_frequency_domain;
for (int i=0; i<im.rows; i++){
cv::Mat one_row = im.row(i);
cv::dft(one_row, one_row_in_frequency_domain);
// Apply your filter by multiplying
}
actually it looks like openCV can do that out of the box: see here in the manual 实际上,看起来openCV可以立即使用: 参见手册中的此处
DFT_ROWS performs a forward or inverse transform of every individual row of the input matrix; DFT_ROWS对输入矩阵的每一行执行正向或逆向转换; this flag enables you to transform multiple vectors simultaneously and can be used to decrease the overhead 此标志使您可以同时变换多个向量,并可用于减少开销
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.