How to do Roughness calculation from wyko vision ascii file using MATLAB?
Show older comments
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:
- I measured surface roughness using an optical profilometer and saved the data in .opd format, which is compatible with Wyko vision software.
- I opened this file in Wyko vision software and received readings of Ra=193.98 nm and Rq=301.48 nm.
- 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
on 13 Jul 2023
"I've also attached the ASCII file below for reference." No file attached!
Praveen Patnaik
on 13 Jul 2023
Alan Stevens
on 13 Jul 2023
I assume the data is represented by the three columns from row 131 onwards. What does each column represent and what are their units?
Praveen Patnaik
on 13 Jul 2023
Image Analyst
on 14 Jul 2023
Edited: Image Analyst
on 14 Jul 2023
Please give us the code to read the matrix part of the ASC file into a MATLAB variable. Make it easy for us to help you.
By the way, I took a class from the "WY" of WYKO - Jim Wyant.
I got my Ph.D. from the Wyant College of Optical Sciences at the University of Arizona (the largest optics college outside of China). He left the college for a bit with Chris Koliopolis to form WYKO but then it was bought out by Zygo and Wyant returned to the college.
Usually Ra and Rq are computed on linear profiles while Sa and Sq are metrology metrics computed when the data is a 2-D array/image.
Praveen Patnaik
on 15 Jul 2023
Praveen Patnaik
on 15 Jul 2023
Image Analyst
on 15 Jul 2023
When I try your code I get.
Error using readmatrix
Unable to find or open '3.7s1.xlsx'. Check the path and filename or file permissions.
Error in test1 (line 10)
data = readmatrix('3.7s1.xlsx');
Please attach the XLSX workbook with the paperclip icon. Please be more careful about what files you're trying to use and upload. Attaching the wrong files only delays your answer. I'll check back later but I will be traveling the whole weekend.
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
on 18 Jul 2023
Edited: Praveen Patnaik
on 18 Jul 2023
Answers (1)
Siraj
on 25 Aug 2023
0 votes
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.
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!