smooth sampled orientations, boundaries or harmonic functions.
Syntax
smoothed = smooth(x)
Description
For an MTEX object, smooth(x, …) calls x.smooth(…). Additional positional and keyword arguments are passed to that method unchanged. Its documentation specifies the accepted inputs, units, symmetry handling and optional outputs. Consult the corresponding method for the behaviour of a particular object type.
Example
Denoise a synthetic map containing two grains and reproducible orientation noise. Reconstruct the grains first so the filter respects their boundary.
import numpy as np
import matplotlib.pyplot as plt
from mtex import (EBSD, crystalFrame, phaseList, rotation, vector3d, degree,
calcGrains, smooth, meanFilter, KAM, plot, mtexColorbar, mtexTitle, newMtexFigure)
x, y = np.meshgrid(np.arange(20), np.arange(12))
base = np.where(x < 10, 0.0, 20.0)
noise = np.random.default_rng(7).normal(0, 0.4, x.shape)
rot = rotation.byAxisAngle(vector3d.Z, (base + noise).ravel()*degree)
cs = crystalFrame('m-3m')
ebsd = EBSD(np.c_[x.ravel(), y.ravel()], rot, np.ones(x.size, dtype=int), phaseList(cs))
grains = calcGrains(ebsd, angle=10*degree)
filtered = smooth(ebsd, meanFilter(numNeighbours=1))
for data, title in ((ebsd, 'Before smoothing'), (filtered, 'After smoothing')):
newMtexFigure()
kam = KAM(data)/degree
print(title, 'median KAM (degrees):', round(float(np.nanmedian(kam)), 3))
plot(data, kam, colorRange=(0, 1.5), micronbar=False)
mtexColorbar(title='KAM (degrees)')
mtexTitle(title)
print('Grain ids unchanged:', np.array_equal(filtered.grainId, ebsd.grainId))
plt.show()
The returned map has new orientations and retains the original segmentation. Lower KAM shows reduced local variation in this synthetic example; it is not a general measure of denoising quality. Choose a filter and length scale appropriate to the features to retain.
Before smoothing median KAM (degrees): 0.373
After smoothing median KAM (degrees): 0.141
Grain ids unchanged: True


Signature
smooth(x, *args, **kwargs)
Methods it calls
| boundaryFilter | V are the vertices (n, 2) of the network, h the spacing they are sampled at |
| curvatureFilter | the minimiser of |V - V0|^2 + alpha |L V|^2 over the free vertices, one sparse system |
| EBSD | the map with its orientations denoised, every one replaced by one computed from its neighbours, within the grains where the map knows them and within the phases otherwise |
| EBSD3 | the map with its orientations denoised, every one replaced by one computed from its neighbours, within the grains where the map knows them and within the phases otherwise |
| huberFilter | the minimiser of |V - V0|^2 plus alpha times the Huber penalty of the curvature L V, by reweighting the sparse system until nothing moves, the fixed vertices kept |
| laplaceFilter | the vertices after iter steps of local averaging at the rate lambda_ / 2, the fixed ones kept |
| S1FunHarmonic | the convolution with a de la Vallee Poussin kernel, 2.9 degree unless a kernel or a halfwidth is given |
| taubinFilter | the vertices after iter pairs of a smoothing step lambda_ and an unshrinking step mu, the fixed ones kept |
| vector3d | pcolor(sF), pcolor(v), pcolor(v, data): a coloured surface |
Used on
EBSDDenoising, EBSDFilling, EBSDGROD, EBSDKAM, EBSDSharpPlot, LowLevelParentGrainReconstruction, MaParentGrainReconstruction, GND, WBV
source
Citing this page.
This page is part of the documentation of
MTEX, a free and open
source MATLAB toolbox for analyzing and modeling crystallographic textures.
It was written by The MTEX Developers and is published at
https://mtex-toolbox.github.io/smooth_py.html.
If you use MTEX, or reuse text or figures from this page, in your research,
please cite
F. Bachmann, R. Hielscher, H. Schaeben: Texture Analysis with MTEX - Free and Open Source Software Toolbox, Solid State Phenomena 160 (2010), 63-68. 10.4028/www.scientific.net/SSP.160.63
BibTeX
@article{bachmann2010mtex,
author = {F. Bachmann and R. Hielscher and H. Schaeben},
title = {Texture Analysis with MTEX - Free and Open Source Software Toolbox},
journal = {Solid State Phenomena},
volume = {160},
pages = {63-68},
year = {2010},
doi = {10.4028/www.scientific.net/SSP.160.63},
url = {https://doi.org/10.4028/www.scientific.net/SSP.160.63}
}
Other papers describing specific MTEX methods are listed under Publications — please cite the one that best fits your application. The MTEX source code is licensed under the GNU General Public License v2.0; the text and figures of this documentation are licensed under CC BY 4.0, which permits reuse — including by automated systems — provided The MTEX Developers and this page are credited.