File Exchange

image thumbnail

Radially averaged surface roughness power spectrum (PSD) only on top or bottom part of a topography

version (3.25 KB) by Mona Mahboob Kanafi
Calculates radially averaged 2D power spectrum for a certain part of surface topography


Updated 19 Dec 2016

View Version History

View License

In surface roughness or any topography analysis, power spectral density graph is a valuable characterisation tool. However, there are times when we are only interested in a specific part of a surface topography. For instance, if the surface topography is skewed at the bottom (which will affect the PSD results), we would like to carry out the PSD analysis only on the top topography. For further description of the technique refer to below article (and feel free to cite it, if you find the code useful):
Kanafi, Mona Mahboob, and Ari Juhani Tuononen. "Top Topography Surface Roughness Power Spectrum for Pavement Friction Evaluation." Tribology International (2016).

This code is a continuation of surface roughness PSD for the full surface topography, i.e. Radially Averaged Surface Roughness Power Spectrum:

The code calculates the 2D PSD of a surface topography either on the top topography or the bottom topography, at a certain depth or portion of the surface topography, given by the user. The surface topography is normally obtained by any 3D profilometry techniques, such as AFM (Atomic Force Microscopy), WLI (White Light Interferometry) and many other optical profilers.

You need to provide 5 inputs to the code. 1- You need to have a matrix (n by m) of your height values (z). 2- You need to know you PixelWidth (spatial resolution) which is obtained easily by dividing you image length to the number of pixels in length, i.e. :

PixelWidth = Lx / m; % in SI units

3- You will specify whether you want to carry out analysis on ‘top’ or then the ‘bottom’ profile. 4- You will specify whether you will provide the code with the ‘depth’ or then the ‘percent’ of data you are interested in. And finally 5- give the depth or percent value!

An example input would be:

[q , C , PSD] = top_bottom_2Dpsd(z , 6e-6 ,'top' ,'percent',20)

Above line calculates the 2D radially averaged PSD for 20% of data, but from the top topography. z denotes the matrix of height values and the second input is the pixel width of z profile, which was 6 micron.

Please note that when the percentage of data is set to 100, it means the whole surface topography is used for calculation!

In order to plot the output:

To generate an artificial randomly rough surface/topography to try the code, refer to:

Surface generator: artificial randomly rough surfaces

Cite As

Mona Mahboob Kanafi (2021). Radially averaged surface roughness power spectrum (PSD) only on top or bottom part of a topography (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)


Ari Tuononen

Ajay Shankar

Hi Mona,
Thanks for the code. I would appreciate if you can help me with the following:

Attempted to access qx(3); index out of bounds because numel(qx)=2. Error in top_bottom_2Dpsd (line 186) qrmin = log10(min([ qx((m/2)+2) qy((n/2)+2)]));

Thanking you in advance,

Qingqing Cao

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!