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?
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
line 1
line 2
line 3 ...
line 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:
Low pass: 1x10 image
Band pass: 1x10 image
Then you can use cv::dft to convert these filters into frequency domain. Also use cv::dft to convert your image into frequency domain. 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
DFT_ROWS performs a forward or inverse transform of every individual row of the input matrix; this flag enables you to transform multiple vectors simultaneously and can be used to decrease the overhead
精彩评论