Fourier Transform and Fourier Descriptors to extract shapes features on Java

大憨熊 提交于 2019-12-06 08:28:49

问题


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)

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?

This was what I thought :

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

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

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


回答1:


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:

  • 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.

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.




回答2:


If you are looking to match different shapes, try using different shape descriptors from MPEG-7 standard. You will probably need a classifier, take a look at SVM, Boosting, Neural Networks ...: http://docs.opencv.org/modules/ml/doc/ml.html



来源:https://stackoverflow.com/questions/10319251/fourier-transform-and-fourier-descriptors-to-extract-shapes-features-on-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!