本文介绍了傅里叶变换和傅立叶描述符在Java上提取形状特征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用傅里叶描述符构建一个简单的系统来识别简单的形状:
我在我的程序中使用快速傅立叶变换的实现:(链接如下)

I am trying to build a simple system to recognize simple shapes using Fourier descriptors:I am using this implementation of Fast fourier transform on my program: (link below)
http://www.wikijava.org/wiki/The_Fast_Fourier_Transform_in_Java_%28part_1%29

fft(double[] inputReal, double[] inputImag, boolean direction)

输入是:真实和图像部分(它本质上是边界参数的x,y坐标)
和输出是转换后的实数和图像数。

inputs are: real and imag part (which are essentially x,y coordinates of boundary parameter I have)and outputs are the transformed real and imag numbers.

问题:我如何使用输出(变换后的真实,图像)作为我简单形状的不变描述符?

question: How can i use the output (transformed real,imag ) as a invariant descriptors of my simple shapes?

这就是我的想法:


  • 计算对于每N个步骤,R = sqrt(real ^ 2 + imag ^ 2)

  • 将每个 R 除以 R [1] =归一化因子到让它不变。

  • calculate R = sqrt( real^2 + imag^2 ) for each N steps.
  • divide each R by R[1] = the normalization factor to make it invariant.

问题是我的R值略有不同,略有不同的图像(例如应用轻微旋转等)

The problem is I get very different R values for slightly different images (such as slight rotations applied, etc)

换句话说

我的描述符不是不变的...我认为我在获取R值时出错了。

In other words :
My descriptors are not invariant... I think I am doing something wrong with getting the R value.

推荐答案

首先需要了解傅立叶描述符的一些理论:这是一种非常有趣的技术,但应该正确设计。你想要的是不变性;旋转,平移,甚至仿射变换的不变性。为了与其他傅立叶描述符集进行良好比较,您应该考虑以下事项:

There is some theory you need to know first about Fourier Descriptors: it's an extremely interesting technique, but should be devised correctly. What you want is invariance; invariance for rotation, translation, maybe even affine transforms. To allow good comparison with other sets of Fourier descriptors you should take following things in consideration:


  • 如果您想要不变换,请不要使用DC项,即你得到的傅立叶系数数组中的第一个元素

  • 如果你想要不变缩放,可以做比较比例,例如将每个傅里叶系数除以直流系数。 f * [1] = f [1] / f [0],f * [2] / f [0],依此类推。

  • 如果你想要起点的不变性轮廓的轮廓,只使用得到的傅里叶系数的绝对值。

  • 比较两个不同对象的系数时,只有前5到8个傅里叶系数是有用的。较高的系数只会进入轮廓的细节,而这些细节大多不是非常有用的信息。 (这是重要的全局形式)

  • 假设您有2个对象及其傅里叶描述符。得到的傅里叶系数阵列可以具有不同的大小,这意味着所得到的频率内容的频率间隔对于两种形状都是不同的。你无法将苹果与梨进行比较。对最短轮廓进行零填充以匹配最长轮廓的大小,然后计算傅里叶描述符。现在你可以比较系数和一个很好的比较。

  • if you want invariance to translation, do not use the DC-term, that is the first element in your resulting array of Fourier coefficients
  • if you want invariance to scaling, make the comparison ratio-like, for example by dividing every Fourier coefficient by the DC-coefficient. f*[1] = f[1]/f[0], f*[2]/f[0], and so on.
  • if you want invariance to the start point of your contour, only use absolute values of the resulting Fourier coefficients.
  • Only the first 5 to 8 Fourier coefficients are useful when comparing the coefficients of two different objects; higher coefficients only go into the details of your contour which mostly isn't very useful information. (it's the global form that matters)
  • Let's say you have 2 objects, and their Fourier descriptors. The resulting array of Fourier coefficients can be of a different size, meaning that the 'frequency interval' of the resulting frequency content is different for both shapes. You can't compare apples with pears. Zero-pad your shortest contour to match the size of the longest contour, and then calculate the Fourier descriptors. Now you have analogy between coefficients and a good comparison.

希望这会有所帮助。顺便说一句,用户自己的FFT解决方案在我看来并不值得信任。寻找解决方案库。如果使用图像,OpenCV提供傅立叶变换实用程序。

Hope this helps. Btw, user-made FFT solutions are not to be trusted in my opinion. Go for the solutions libraries reach out. If working with images, OpenCV provides Fourier transform utilities.

这篇关于傅里叶变换和傅立叶描述符在Java上提取形状特征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 02:07