用fft过滤图像 [英] Filtering image with fft

查看:159
本文介绍了用fft过滤图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用2D FFT将滤镜应用于图像。我有滤波器矩阵(卷积核等),但如果我想用fft我需要将滤波器和图像矩阵扩展到2平方矩阵的幂。

I am trying to apply filter to image using 2D FFT. I have filter matrix (convolution kernel etc), but if I want to use fft I need to expand filter and picture matrix to power of 2 square matrix.

首先我用零展开它(因此图像和滤波器的矩阵将位于2矩阵的大功率的左上角)我得到了这个结果

First I expand it with zeros (so matrix of picture and filter would be in top left corner of big power of 2 matrix) and I got this result

然后我尝试使用图像矩阵,当我应用没有fft的卷积时,填充图像矩阵,每边有滤波器尺寸/ 2,而不是带有简单扩展滤波器矩阵的填充矩阵,功率为2矩阵与fft卷积,我得到了这个

Then I tried what I did with picture matrix when I was applying convolution without fft, padded picture matrix with filter dimension/2 from each side, and than that padded matrix with simple expand filter matrix to power of 2 matrix to convolve with fft and i got this

这是原始图片。

关于算法:
我在两个扩展矩阵上应用2d fft,而在我做简单逆fft之后,我使用逐点乘法矩阵。此外,图像矩阵的编号从0到16M(前8位为红色,后8位为绿色,第3位为蓝色)

About algorithm: I am applying 2d fft on both expanded matrixes and than dotwise multiply matrixes after what Im doing simple inverse fft. Also picture matrix are number from 0 to 16M (first 8 bits are red, second 8 bits are green and third 8 bits are blue)

我认为问题正在进行中我如何将图片和滤波器矩阵扩展为2矩阵的平方功率,但我不确定。我测试了fft函数(fft和反fft,我有相同的图片(没有逐点乘法))

I think that problem is in way how I am expanding picture and filter matrix to square power of 2 matrix but im not sure. I tested fft functions (fft and inverse fft, i got same picture (without dotwise multiplication))

还过滤

 0 .2  0
.2 .2 .2
 0 .2  0


推荐答案

您无需一次性转换图像。
在子块上使用FFT。通过内核大小重叠转换后的子图像,并丢弃环绕瞬态(重叠保存)或添加输入和输入瞬态(重叠 - 添加)。

You don't need to transform the image all at once. Use FFTs on subblocks. Overlap the transformed subimages by the kernel size and either discard the wraparound transient (overlap-save) or add the input-on and input-off transients (overlap-add).

在尝试两个维度之前,先了解快速卷积

Understand fast convolution in one dimension before you try to do it in two.

这篇关于用fft过滤图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆