Aligning surfaces to find height difference

2 views (last 30 days)
Asma S
Asma S on 29 Jul 2023
Commented: Asma S on 7 Sep 2023
Hi
I have 3D data from a CMM of multiple similar surfaces, I'm studying the height difference in these surfaces. What is the most striaght-forward way to align these surfaces so I can then find the difference between them?
(If it is easier to look at these as 2D surfaces I can do this as it is only the height difference I'm currently looking at)
Thanks in advance!
  2 Comments
Image Analyst
Image Analyst on 29 Jul 2023
What exactly are we supposed to be seeing when you say "these surfaces"?
And if you change (shift or tilt) one surface, then you're no longer looking at the original height differences. Are you sure you want to look at the altered height differences instead?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Asma S
Asma S on 29 Jul 2023
Thank you for your reply and apologies as I've just realised my question was quite vague (You can tell I'm new to this!)
So I've attached a picture of what my 3D data looks like as a scatter plot. I have multiple scans of these for different components, these components were initially the same but some have been subject to simulated wear since and I would like to calculate the difference in Z between them to measure this wear. However, the scans do not always start at the same point so I thought I would need to align the surfaces I'm comparing to find the height difference at each point
You are right though, I have managed to align the surfaces since I posted my question but as you mentioned this has clearly altered the data so I can now see that this is probably not what I need to do.
Do you have any suggestions so that I can measure this difference accurately instead?

Sign in to comment.

Answers (1)

Yatharth
Yatharth on 29 Aug 2023
Hi , I understand that you are trying to find the height difference between multiple surfaces obtained via CMM. However aligning them or modifying their position in terms of Z axis might alter your data and you will have incoorect values for height. Instead you can select one of the surfaces as the reference surface. This surface will serve as the baseline for comparison with the other surfaces.
To find the height difference between multiple similar surfaces, you can follow these steps:
1. Define a reference surface
2. Establish corresponding points: Identify corresponding points on the reference surface and each of the other surfaces. These points should represent the same location or feature on each surface. You can use feature matching techniques or manual selection to establish correspondences.
3. Calculate the height difference between the reference surface and the other surfaces
here's an example for the same
% Generate dummy 3D data for three surfaces
surface1 = rand(10, 10); % Reference surface
surface2 = rand(10, 10); % Surface 2
surface3 = rand(10, 10); % Surface 3
% Define corresponding points
% In this example, we assume the surfaces have the same dimensions
[row, col] = size(surface1);
[X, Y] = meshgrid(1:col, 1:row); % Generate grid coordinates
% Calculate height difference
height_diff_2 = surface2 - surface1;
height_diff_3 = surface3 - surface1;
% Visualize the height differences
figure;
subplot(1, 2, 1);
imagesc(height_diff_2);
colorbar;
title('Height Difference - Surface 2');
subplot(1, 2, 2);
imagesc(height_diff_3);
colorbar;
title('Height Difference - Surface 3');
you can use the height_diff_n matrix to analyse your data statistically.
you can learn more about the imagesc and colorbar here.
  3 Comments
Yatharth
Yatharth on 7 Sep 2023
Hi, since your data has a separate Z axis you can directly find the difference between the height of the two arrays
Note: Make sure you make both the array size equal and concatenate the smaller one with zeros at the start or at the end
here's the code for your reference.
filename = 'LinerA.xlsx';
sheet = 'Sheet2';
filename2 = 'LinerB.xlsx';
% Specify the columns you want to load (e.g., columns A and B)
columns = 'A:C';
% Load the specified columns as a cell array
data1 = xlsread(filename, sheet, columns);
data2 = xlsread(filename2, sheet, columns);
z1 = data1(:,3);
z2 = data2(:,3);
temp_z = zeros(length(z2) - length(z1) , 1);
z1 = [z1 ; temp_z]
height_diff_2 = z2-z1
% Visualize the height differences
figure;
subplot(1, 2, 1);
imagesc(height_diff_2);
colorbar;
title('Height Difference - Surface 2');
I hope this helps.
Asma S
Asma S on 7 Sep 2023
Hi! Thank you for your answer
I have already tried this but my issue is this will find the difference between each two corresponding values from the matrices according to their order in each matrix (A(1,3) - B(1,3) , A(2,3) - B(2,3) , etc... )
My data points do not always start in the exact same location so the surfaces are not perfectly aligned and I need the exact difference when points are aligned
Not sure if that makes sense, I've drawn a quick diagram to show you what I mean by data not aligning perfectly

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!