抗锯齿:确定最大频率的首选方法?

发布于 2024-07-14 09:43:39 字数 817 浏览 6 评论 0原文

我已经阅读了一些有关抗锯齿的内容,这似乎很有道理,但有一件事我不太确定。 如何准确地找到信号的最大频率(在图形的背景下)。

我意识到有不止一种情况,所以我假设有不止一种答案。 但首先让我陈述一个我认为代表最大频率的简单算法,以便有人可以告诉我我是否以错误的方式概念化它。

假设它是一维、有限、灰度图像(以像素为单位)。 我是否正确地假设您可以简单地扫描整个像素线(在空间域中)寻找最小振荡,并且该最小振荡的倒数将是最大频率?

Ex 值 {23,26,28,22,48,49,51,49}

频率:与集合相关 {}

(1/2) = .5 : {28,22}

(1/4) = .25 : { 22,48,49,51}

那么 0.5 是最大频率吗?

对于与上述类似的像素线,计算此值的理想方法是什么?

从更理论的角度来看,如果您的采样输入是无限的(更像现实世界)怎么办? 一个有效的过程会有点像:

Predetermine a decent interval for point sampling
Determine max frequency from point sampling
while(2*maxFrequency >  pointSamplingInterval)
{
pointSamplingInterval*=2
Redetermine maxFrequency from point sampling (with new interval)
}

我知道这些算法效率低下,那么首选的方法是什么? (不是寻找疯狂优化的东西,只是从根本上更好的概念)

I've been reading up a bit on anti-aliasing and it seems to make sense, but there is one thing I'm not too sure of. How exactly do you find the maximum frequency of a signal (in the context of graphics).

I realize there's more than one case so I assume there is more than one answer. But first let me state a simple algorithm that I think would represent maximum frequency so someone can tell me if I'm conceptualizing it the wrong way.

Let's say it's for a 1 dimensional,finite, and greyscale image (in pixels). Am I correct in assuming you could simply scan the entire pixel line (in the spatial domain) looking for a for the minimum oscillation and the inverse of that smallest oscillation would be the maximum frequency?

Ex values {23,26,28,22,48,49,51,49}

Frequency:Pertaining to Set {}

(1/2) = .5 : {28,22}

(1/4) = .25 : {22,48,49,51}

So would .5 be the maximum frequency?

And what would be the ideal way to calculate this for a similar pixel line as the one above?

And on a more theoretical note, what if your sampling input was infinite (more like the real world)? Would a valid process be sort of like:

Predetermine a decent interval for point sampling
Determine max frequency from point sampling
while(2*maxFrequency >  pointSamplingInterval)
{
pointSamplingInterval*=2
Redetermine maxFrequency from point sampling (with new interval)
}

I know these algorithms are fraught with inefficiencies, so what are some of the preferred ways? (Not looking for something crazy-optimized, just fundamentally better concepts)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

め七分饶幸 2024-07-21 09:43:39

解决此问题的正确方法是使用傅里叶变换(实际上是 FFT,或快速傅里叶变换)。

理论工作原理如下:如果您有一组具有颜色/灰度的像素,那么我们可以说图像是由“空间域”中的像素表示的; 也就是说,每个单独的数字指定特定空间位置的图像。

然而,我们真正想要的是“频域”中的图像表示。 每个数字代表整个图像中特定频率的幅度,而不是每个单独的数字指定每个像素。

从“空间域”转换到“频率域”的工具就是傅里叶变换。 FT 的输出将是一系列数字,指定不同频率的相对贡献。

为了找到最大频率,您需要执行 FT,并查看获得的高频幅度 - 然后只需从最高频率向下搜索,直到达到“最小有效幅度”阈值。

您可以编写自己的 FFT 代码,但在实践中使用预打包的库要容易得多,例如 FFTW

The proper way to approach this is using a Fourier Transform (in practice, an FFT,or fast fourier transform)

The theory works as follows: if you have an set of pixels with color/grayscale, then we can say that the image is represented by pixels in the "spatial domain"; that is, each individual number specifies the image at a particular spatial location.

However, what we really want is a representation of the image in the "frequency domain". Instead of each individual number specifying each pixel, each number represents the amplitude of a particular frequency in the image as a whole.

The tool which converts from the "spatial domain" to the "frequency domain" is the Fourier Transform. The output of the FT will be a sequence of numbers specifying the relative contribution of different frequencies.

In order to find the maximum frequency, you perform the FT, and look at the amplitudes that you get for the high frequencies - then it is just a matter of searching from the highest frequency down until you hit your "minimum significant amplitude" threshold.

You can code your own FFT, but it is much easier in practice to use a pre-packaged library such as FFTW

花桑 2024-07-21 09:43:39

您不会扫描信号的最高频率,然后选择采样频率:您选择一个足够高的采样频率来捕获您想要捕获的内容,然后将信号过滤以< em>删除高频。 在采样之前,您将丢弃高于采样率一半的所有内容。

我的假设正确吗?
只需扫描整个像素线(在
空间域)寻找一个
最小振荡和
最小振荡的倒数
最大频率是多少?

如果有一行像素,则采样已经完成。 应用抗混叠滤波器为时已晚。 可能出现的最高频率是采样频率的一半(我猜是“1/2px”)。

从更理论的角度来看,什么
如果你的采样输入是无限的
(更像现实世界)?

是的,这就是您使用过滤器的时候。 首先,您有一个连续函数,就像现实生活中的图像(无限采样率)。 然后对其进行过滤以删除 fs/2 以上的所有内容,然后在 fs 处对其进行采样(将图像数字化为像素)。 相机实际上并不进行任何过滤,这就是为什么您会得到莫尔图案当您拍摄砖块等时

alt text

如果您正在使用抗锯齿计算机图形,您必须首先考虑理想的连续数学函数,并考虑如何对其进行过滤和数字化以在屏幕上产生输出。

例如,如果您想用计算机生成方波,则不能只是天真地在最大值和最小值之间交替。 这就像在不先过滤的情况下对现实生活中的信号进行采样一样。 高次谐波回绕到基带中,并在频谱中产生大量杂散尖峰。 您需要生成点,就好像它们是从过滤的连续数学函数中采样的一样:

替代文字

You don't scan a signal for the highest frequency and then choose your sampling frequency: You choose a sampling frequency that's high enough to capture the things you want to capture, and then you filter the signal to remove high frequencies. You throw away everything higher than half the sampling rate before you sample it.

Am I correct in assuming you could
simply scan the entire pixel line (in
the spatial domain) looking for a for
the minimum oscillation and the
inverse of that smallest oscillation
would be the maximum frequency?

If you have a line of pixels, then the sampling is already done. It's too late to apply an antialiasing filter. The highest frequency that could be present is half the sampling frequency ("1/2px", I guess).

And on a more theoretical note, what
if your sampling input was infinite
(more like the real world)?

Yes, that's when you use the filter. First, you have a continuous function, like a real-life image (infinite sampling rate). Then you filter it to remove everything above fs/2, then you sample it at fs (digitize the image into pixels). Cameras don't actually do any filtering, which is why you get Moire patterns when you photograph bricks, etc.

alt text

If you're anti-aliasing computer graphics, you have to think of the ideal continuous mathematical function first, and think through how you would filter it and digitize it to produce the output on the screen.

For instance, if you want to generate a square wave with a computer, you can't just naively alternate between maximum and minimum values. That would be just like sampling a real life signal without filtering first. The higher harmonics wrap back into the baseband and cause lots of spurious spikes in the spectrum. You need to generate points as if they were sampled from a filtered continuous mathematical function:

alt text

梦过后 2024-07-21 09:43:39

我认为 O'Reilly 网站上的这篇文章可能对您也有用... http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html ...在那里他们指的是声音的频率分析文件,但你它给了你这个想法。

I think this article from the O'Reilly site might also be useful to you ... http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html ... in there they're referring to frequency analysis of sound files but you it gives you the idea.

緦唸λ蓇 2024-07-21 09:43:39

我认为你需要的是傅立叶分析的应用程序(http://en.wikipedia.org/wiki/傅立叶分析)。 我研究过这个,但从未使用过它,所以请持保留态度,但我相信,如果你正确地将它应用到你的一组数字上,你将得到一组频率,它们是该系列的组成部分,然后你可以挑选出最高的一个。

我无法向您指出执行此操作的一段代码,但我确信它会在某个地方。

I think what you need is an application of Fourier Analysis (http://en.wikipedia.org/wiki/Fourier_analysis). I've studied this but never used it so take it with a pinch of salt but I believe if you apply it correctly to your set of numbers you will get a set of frequencies which are components of the series and then you can pick off the highest one.

I can't point you at a piece of code that does this but I'm sure it would be out there somewhere .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文