How to do Roughness calculation from wyko vision ascii file using MATLAB?

39 views (last 30 days)
Hello everyone,
I'm experiencing an issue regarding surface roughness calculation and I could use some help in troubleshooting.
Here's what I've done so far:
  1. I measured surface roughness using an optical profilometer and saved the data in .opd format, which is compatible with Wyko vision software.
  2. I opened this file in Wyko vision software and received readings of Ra=193.98 nm and Rq=301.48 nm.
  3. I then exported the data from the .opd file to ASCII format to use in Matlab. I applied the standard formulas for calculating Ra and Rq in Matlab. However, the results I got didn't match the readings I initially obtained from Wyko vision software.
This leads me to a couple of doubts:
a) Are the coordinate data provided by the Wyko vision software in ASCII format for Ra and Rq calculations the actual raw data, or has it been processed in some way by the software before the calculations are performed?
I'd appreciate any guidance on this issue, specifically on understanding the data processing done by Wyko software and how I can ensure my Matlab script is accurately calculating the roughness parameters.
I've also attached the ASCII file below for reference. The data from ASCII file has been put into XLSX file which I have provided
Thank you in advance for your help!
% Load data from xlsx file
data = readmatrix('3.7s1.xlsx');
% Extract z coordinates
z = data(:, 3);
% Calculate the average height
z_avg = mean(z);
% Calculate Ra (average roughness)
Ra = mean(abs(z - z_avg));
% Calculate Rq (root mean square roughness)
Rq = sqrt(mean((z - z_avg).^2));
% varied the formula as I dont know if data provided in ascii file is taken
% from a central plane or not
% Calculate Ra2 (average roughness)
Ra2 = mean(abs(z));
% Calculate Rq2 (root mean square roughness)
Rq2 = sqrt(mean((z).^2));
% Display the results
disp(['Average roughness (Ra): ', num2str(Ra)]);
disp(['Root mean square roughness (Rq): ', num2str(Rq)]);
disp(['Average roughness (Ra): ', num2str(Ra2)]);
disp(['Root mean square roughness (Rq): ', num2str(Rq2)]);
  10 Comments
Alan Stevens
Alan Stevens on 16 Jul 2023
Using your data I get Ra and Rq values at least an order of magnitude larger than those you quote above. What is the object that is being measured? What are typical roughness measure for this sort of object?
Praveen Patnaik
Praveen Patnaik on 18 Jul 2023
Edited: Praveen Patnaik on 18 Jul 2023
I am measuring roughness on the surface of a coating.
The presentation I referred was from a webinar by Bruker. This is what they did.
Step 1 : Apply low pass filter on data to remove noise [These filters are called spatial filters]
Step 2 : We apply polynomial fit 4th order to remove waviness by substracting the shape from the surface
Step 3 : Apply a high pass filter to select the roughness [Here they tried using Robust Gaussian filter]
Step 4 : Calc the roughness
I had not gone through this previously as I lacked knowledge. Currently I have not got my answers yet but I know the direction for explring this problem. You all may add feedbacks to make my exploring faster.
Ex: I dint get any code for Roubust Gausian filter
After going through the webinar I can be certain that the data provided in ASCII file is the raw data and not the processed data

Sign in to comment.

Answers (1)

Siraj
Siraj on 25 Aug 2023
Hii! It is my understanding that you want to measure the roughness on the surface of a coating. First, you calculated the values of “Ra” and “Rq” using the Wyko vision software and then exported and read the data into MATLAB to again calculate the values of “Ra and Rq”. The values of “Ra” and “Rq” calculated in MATLAB differ from the values calculated in the Wyko vision software.
I tried to calculate the values of “Ra and “Rq in MATLAB using the code and files attached by you, but these values differ by at least an order of magnitude from what is expected.
I believe one possible reason for this difference could be the absence of a low-pass filter, which is typically used to reduce noise and smooth out the data. Additionally, the omission of a high-pass filter, designed to capture the roughness or high-frequency components, as mentioned in the algorithm, might also have an impact on the results.
Refer to the documentation below for applying filters to the data.
To remove the waviness of the data we can leverage the curve fitting toolbox.
Hope this helps.

Community Treasure Hunt

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

Start Hunting!