2

How to design a simple code to automatically quantify a 2D rough surface based on given scatter points geometrically? For example, to use a number, r=0 for a smooth surface, r=1 for a very rough surface and the surface is in between smooth and rough when 0 < r < 1.

To more explicitly illustrate this question, the attached figure below is used to show several sketches of 2D rough surfaces. The dots are the scattered points with given coordinates. Accordingly, every two adjacent dots can be connected and a normal vector of each segment can be computed (marked with arrow). I would like to design a function like

def roughness(x, y):

   ...   

   return r

where x and y are sequences of coordinates of each scatter point. For example, in case (a), x=[0,1,2,3,4,5,6], y=[0,1,0,1,0,1,0]; in case (b), x=[0,1,2,3,4,5], y=[0,0,0,0,0,0]. When we call the function roughness(x, y), we will get r=1 (very rough) for case (a) and r=0 (smooth) for case (b). Maybe r=0.5 (medium) for case (d). The question is refined to what appropriate components do we need to put inside the function roughness?

Some initial thoughts:

Roughness of a surface is a local concept, which we only consider within a specific range of area, i.e. only with several local points around the location of interest. To use mean of local normal vectors? This may fail: (a) and (b) are with the same mean, (0,1), but (a) is rough surface and (b) is smooth surface. To use variance of local normal vectors? This may also fail: (c) and (d) are with the same variance, but (c) is rougher than (d).

Sketches of 2D rough surfaces

Yongxin
  • 173
  • 2
  • 9
  • what's the actual question? this might be more suited to https://stats.stackexchange.com? maybe you are asking about the correlation between adjacent vertices? – Sam Mason Sep 18 '19 at 12:45
  • @SamMason I made the question more explicit. It is to design a function to automatically determine or quantify how rough a surface is by returning a value. The input arguments are x and y coordinate information. – Yongxin Sep 18 '19 at 13:06

3 Answers3

1

maybe something like this:

import numpy as np

def roughness(x, y):
    # angles between successive points
    t = np.arctan2(np.diff(y), np.diff(x))

    # differences between angles
    ts = np.sin(t)
    tc = np.cos(t)
    dt = ts[1:] * tc[:-1] - tc[1:] * ts[:-1]

    # sum of squares
    return np.sum(dt**2) / len(dt)

would give you something like you're asking?

Sam Mason
  • 15,216
  • 1
  • 41
  • 60
0

Maybe you should consider a protocol definition:

1) geometric definition of the surface first

2) grant unto that geometric surface intrinsic properties.

2.a) step function can be based on quadratic curve between two peaks or two troughs with their concatenated point as the focus of the 'roughness quadratic' using the slope to define roughness in analogy to the science behind road speed-bumps.
2.b) elliptical objects can be defined by a combination of deformation analysis with centered circles on the incongruity within the body.  This can be solved in many ways analogous to step functions.
2.c) flat lines: select points that deviate from the mean and do a Newtonian around with a window of 5-20 concatenated points or what ever is clever.

3) define a proper threshold that fits what ever intuition you are defining as "roughness" or apply conventions of any professional field to your liking.

This branched approach might be quicker to program, but I am certain this solution can be refactored into a Euclidean construct of 3-point ellipticals, if someone is up for a geometry problem.

0

The mathematical definitions of many surface parameters can be found here, which can be easily put into numpy:

https://www.keyence.com/ss/products/microscope/roughness/surface/parameters.jsp

Image (d) shows a challenge: basically you want to flatten the shape before doing the calculation. This requires prior knowledge of the type of geometry you want to fit. I found an app Gwyddion that can do this in 3D, but it can only interface with Python 2.7, not 3.

If you know which base shape lies underneath:

  1. fit the known shape
  2. calculate the arc distance between each two points
  3. remap the numbers by subtracting 1) from the original data and assigning new coordinates according to 2)
  4. perform normal 2D/3D roughness calculations
Dharman
  • 30,962
  • 25
  • 85
  • 135
StephanT
  • 649
  • 5
  • 12