= np.loadtxt('example.txt')
image = np.loadtxt('example_profiles.txt') profiles
Profile
To demonstrate, we’re going to build on the data we processed in data
plt.imshow(image) plt.show()
Statistical Parameters
The following methods are statistical in nature, providing a single number as a broad description of the distribution of the height values.
Ra
Ra (im, axis=1, norm=True)
Calculates Mean Absolute Roughness (Ra) along given axis. Defined as the average deviation of absolute height values from the mean line.
Type | Default | Details | |
---|---|---|---|
im | Numpy array or arraylike | ||
axis | int | 1 | Default to Ra of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
#test_close(0.14539179526852036,Ra(cor2pgau,norm=False,axis=None),eps=1e-4)
5] Ra(image)[:
array([0.00042559, 0.00041652, 0.00040715, 0.00039409, 0.00037837])
Remember, if you just want the parameters of a certain profile, you just index into your image and be mindful of the axis.
= image[0,:]
first_row_profile = image[:,0]
first_column_profile = 0) Ra(first_column_profile, axis
0.0004406996100199229
Rms
Rms (im, axis=1, norm=True)
*Calculates Root Mean Square Roughness (Rms) along given axis. Defined as the root mean square of deviations of height from the mean line of a given profile.
Also known as Rq*
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to Rms of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
#test_close(0.195597300779425,Rms(cor2pgau,axis=None),1e-3)
5] Rms(image)[:
array([0.00053041, 0.0005153 , 0.0004984 , 0.00048217, 0.00046463])
Rsk
Rsk (im, axis=1, norm=True, **kwargs)
Calcultes the Skew (Rsk) along given axis. Thin wrapper around scipy.stats.skew with bias set to False
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to Skew of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
kwargs |
#test_close(1.094210880233907,Rsk(cor2pgau[50:-50],axis=None),1e-4)
5] Rsk(image)[:
array([-0.33567068, -0.33327936, -0.33261958, -0.32251 , -0.28183241])
Rku
Rku (im, axis=1, norm=True, **kwargs)
Calculates the Kurtosis (Rku) along given axis. This wrapper around scipy.stats.kurtosis
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to Kurtosis of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
kwargs |
#test_close(6.8550747244379355,Rku(cor2pgau,axis=None),1e-4)
5] Rku(image)[:
array([-0.65026388, -0.70209278, -0.75579608, -0.75657439, -0.73669875])
Rp
Rp (im, axis=1, norm=True, **kwargs)
Calculates the peak height of the profile.
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to peaks of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
kwargs |
#test_close(1.1930965342677724,Rp(cor2pgau,axis=None),1e-4)
Rv
Rv (im, axis=1, norm=True, **kwargs)
Calculates the absolute max valley depth of the profile.
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to peaks of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
kwargs |
#test_close(0.5760229498158181,Rv(cor2pgau,axis=None),1e-4)
Rz
Rz (im, axis=1, norm=True, **kwargs)
Calculates the maximum height (max height + absolute max depth) of the profile. Synonymous with range. Also called Rt
Type | Default | Details | |
---|---|---|---|
im | Numpy array or array like | ||
axis | int | 1 | Default to peaks of rows |
norm | bool | True | Normalize the profile by subtracting the mean |
kwargs |
#test_close(1.7691194840835909,Rz(cor2pgau,axis=None),1e-4)
## Texture Parameters
def local_max_min(im,
= 1,
axis = True,
norm **kwargs
):'''
Returns the number of local maxima and minima per unit length, also known as the density of extremes from Nayak (1971).
Assumes the surface is random, with a gaussian distribution of heights (usually pretty safe).
'''
if norm:
= im - np.mean(im, axis = axis, keepdims = True)
im
= moment(im, moment=2, axis = axis)
m2 = moment(im, moment=4, axis = axis)
m4 return (1/math.pi) * ((m4/m2)**(1/2))
def Sds(im,
= 1,
axis = True,
norm **kwargs
):'''
Density of summits, as described by Nayak (1971).
Assumes gaussian, isotropic surface.
'''
= moment(im, moment=2, axis = axis)
m2 = moment(im, moment=4, axis = axis)
m4
return (1 / (6 * math.pi * (3**(1/2)))) * (m4/m2)