FFT 应用图像的带通滤波器。 (类似ImageJ带通滤波器算法)
我需要一个很好的功能,它是在Java程序中实现的:ImageJ。 我需要了解那里使用的算法。 该函数有几个参数: 链接文本
在使用 FFT 之前,它将图像转换为一个特别的: 带通滤波器使用特殊的算法来减少边缘伪影(在傅里叶变换之前,通过在原始图像之外附加图像部分的镜像副本来扩展图像的尺寸,因此边缘不会发生跳跃)
你能告诉我更多关于这一点的信息吗?特殊变换? 实际上是平铺镜像。
我正在用 C++ 编写程序,并希望用 C++ 重写该部分程序。
编辑1: 我需要了解它是如何进行平铺镜像操作的,可能它是一种特殊的操作。实际上,首先它将图像转换为新尺寸的图像,所以对于我的图像来说它将是: 从 600X480 转换为 1024X1024 尺寸的图像。 这里的瓷砖是如何使用的?
编辑2: 另外,很难理解tileMirrored函数的描述:
将ImageProcessor(ROI)放入位置(x,y)处尺寸为宽x高y的新ImageProcessor中。图像围绕其边缘进行镜像,以避免 FFT 的环绕效应。 “...位置 (x,y) 处的尺寸为宽度 x 高度 y”是什么意思?
编辑3: 我实现了带通滤波器,它给出了与原始程序相同的结果。 但是,原始程序(也在我的程序中)的算法本身非常慢 我不想在程序中使用该过滤器一次,但每次调用它都会计算大约 0.5 到 2 秒(取决于参数值)。 使用了FHT变换(不是FFT),它比FFT更快吗? 我觉得filter本身没有优化,请看filterLargeSmall函数实现: 源代码
There is a good function that I need, which is implemented in the Java program: ImageJ.
I need to understand the algorithm used there.
The function has several parameters:
link text
And before using FFT it converts image to a special one:
The Bandpass Filter uses a special algorithm to reduce edge artifacts (before the Fourier transform, the image is extended in size by attaching mirrored copies of image parts outside the original image, thus no jumps occur at the edges)
Can you tell me more about this special transform?
Actually tiling mirrored image.
I am writing on C++ and wish to rewrite that part of the program on C++.
EDIT1:
I need to understand how it does that tiling mirrored image operation, may be it is special one. Actually at first it converts image to a new sized image, so for my images it will be:
convertion from 600X480 to 1024X1024 sized image.
How the tiling is used here?
EDIT2:
Also it is hard to understand this description of tileMirrored function:
Puts ImageProcessor (ROI) into a new ImageProcessor of size width x height y at position (x,y). The image is mirrored around its edges to avoid wrap around effects of the FFT.
What is meant by "...of size width x height y at position (x,y). "?
EDIT3:
I implemented that bandpass filter, and it gives the same results as the original program.
But, the algorithm itself in original program (also in my program) is very slow
I want to use that filter not once in my program, but it calculates approximately 0.5 to 2 seconds each call (depending on parameter value).
There is used an FHT transform (not FFT), is it more quickly than FFT?
I think the filter itself is not optimized, please see filterLargeSmall function implementation:
source code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道该函数到底是如何工作的,但这是类似函数的基本算法:
确定大于图像二维中较大尺寸的最小二元幂(称为 newSize)(称为 newSize) 。
创建一个大小为 newSize by newSize 的新方形图像,并将图像的内容复制到新图像的中心(即图像的左上角应从
(newSize / 2 - xSize / 2、newSize / 2 - ySize / 2)
)。按如下方式填充剩余像素,对于 (x, y) 处的每个像素:
x < (newSize / 2 - xSize / 2)
,复制(newSize / 2 - xSize / 2) + (newSize / 2 - xSize / 2) - x
列和 y 行的像素.y < (newSize / 2 - ySize / 2)
,复制行(newSize / 2 - ySize / 2) + (newSize / 2 - ySize / 2) - y
和列 x 的像素.(newSize / 2 - xSize / 2) + (newSize / 2 - xSize / 2) - x
行( newSize / 2 - ySize / 2) + (newSize / 2 - ySize / 2) - y
。x > (newSize / 2 + xSize / 2)
,复制(newSize / 2 + xSize / 2) + (newSize / 2 + xSize / 2) - x 列和 y 行的像素.
y > (newSize / 2 + ySize / 2)
,复制行(newSize / 2 + ySize / 2) + (newSize / 2 + ySize / 2) - y
和列 x 的像素.(newSize / 2 + xSize / 2) + (newSize / 2 + xSize / 2) - x
和行( newSize / 2 + ySize / 2) + (newSize / 2 + ySize / 2) - y
。可能有一些库可以使这变得更容易(即翻转和复制图像数据),但我不熟悉 C++,只要性能不是一个大问题,这应该很容易自己编写代码。请注意奇数尺寸图像的舍入问题:确保它们一致。
I don't know exactly how that function works, but here's the basic algorithm for a similar function:
Determine the smallest power of two (call it newSize) that is larger than the larger of the two dimensions of the image (call them xSize & ySize).
Create a new square image of size newSize by newSize and copy the contents of the image to the center of the new image (ie. the top-left of the image should start at
(newSize / 2 - xSize / 2, newSize / 2 - ySize / 2)
).Fill in the remaining pixels as follows, for each pixel at (x, y):
x < (newSize / 2 - xSize / 2)
, copy the pixel at column(newSize / 2 - xSize / 2) + (newSize / 2 - xSize / 2) - x
and row y.y < (newSize / 2 - ySize / 2)
, copy the pixel at row(newSize / 2 - ySize / 2) + (newSize / 2 - ySize / 2) - y
and column x.(newSize / 2 - xSize / 2) + (newSize / 2 - xSize / 2) - x
, row(newSize / 2 - ySize / 2) + (newSize / 2 - ySize / 2) - y
.x > (newSize / 2 + xSize / 2)
, copy the pixel at column(newSize / 2 + xSize / 2) + (newSize / 2 + xSize / 2) - x
and row y.y > (newSize / 2 + ySize / 2)
, copy the pixel at row(newSize / 2 + ySize / 2) + (newSize / 2 + ySize / 2) - y
and column x.(newSize / 2 + xSize / 2) + (newSize / 2 + xSize / 2) - x
and row(newSize / 2 + ySize / 2) + (newSize / 2 + ySize / 2) - y
.There are probably libraries that will make this easier (ie. flipping and copying image data), but I am not familiar with C++, and this should be pretty easy to code yourself as long as performance isn't a huge issue. Be careful of rounding issues for images with odd dimensions: make sure they're consistent.