Discussion:
[Gwyddion-users] ISO fft calculation
Casey LaMarche
2014-05-06 20:48:56 UTC
Permalink
Hi All,

I guess last time I posted this question the image file did not attach correctly. I apologize for re-posting so late. I have not see a response, so I am re-posting the question. I am working on reproducing the waviness calculated in the ISO function of Gwyddion. I am looking to calculate the wavelength parameters for the entire surface via matlab. However, I am hitting a wall correctly reproducing the waviness calculated in Gwyddion. I have spent several
days looking at the source code and am still missing something. Anyone have any luck doing this? I am wondering if perhaps Matlab and C++ have different libraries for calculating the FFT? The texture line is 512 elements long so their shouldn't be any interpolation.

The bulk of the source code related to the waviness calculation is in the roughness.c file (modules/tools/roughness.c) and runs from approximately lines 1449 - 1576, however there are a few functions called from other files. I don't know how much detail to get into here, but some help would be great. Of course I will share the matlab code to calculate the wavelength features for the entire surface with the list once this problem is solved.

Below is a comparison of the waviness calculated from Matlab and Gwyddion for a texture line with cutoff 0.004. The cut-off value was set so only the FFT of the first and second frequencies are not set to zero. The first frequency corresponds to the mean and therefore after inverting the fft back, only the second frequency should result in the waviness. What is interesting is that Gwyddion is showing a smaller frequency than matlab, but I don't understand how this is possible. Any suggestions? Maybe the x trace used to calculate the fft for the texture line is different internally than what can be exported through the gwyddion gui?
--
Casey LaMarche
Postdoctoral Researcher
Hrenya and Weimer Research Groups
UCB 596
D1B28/D1B50
David Nečas (Yeti)
2014-05-07 08:03:32 UTC
Permalink
Post by Casey LaMarche
What is interesting is that Gwyddion is showing a smaller frequency
than matlab, but I don't understand how this is possible.
Because Gwyddion cheats. More precisely, it avoids the artifacts caused
in FFT filtering by value and derivative discontinuities at data edges
(as the profile is not really a periodic function) by extending the data
slightly to make it smoothly periodic before FFT filtering and then
cutting off the extension again after the filtering. The net effect is
that you get nice splitting into wavines and roughness also close to the
data edges, matching well the human perception/expectation in this area.
Taking it to the extreme, if you take profile like the one attached,
Gwyddion can essentially put the straight line to wavines and the jumps
to roughness – something that is impossible with naïve FFT filtering due
to edge artifacts. Unless you require precise counting of waves (as you
do in your example), this is what you want. If you need the exact
algorithm, I am afraid there is no substitute for reading the code...

Regards,

Yeti

Loading...