Clustering allows to separate data, like orientations, directions, grain shapes, ... into groups by proximity. While MTEX supports several clustering algorithms, the currently best one is classix.
Lets start by clustering some directional data which we sample from our smiley function
plottingConvention.default('y↑→x');
S2F = S2Fun.smiley.^2;
v = S2F.discreteSample(10000);
scatter(v,'MarkerAlpha',0.2,'MarkerSize',2)
[cInd,center] = calcCluster(v);
plot(v,ind2color(cInd),'MarkerAlpha',0.2,'MarkerSize',2)
annotate(center)
The output cInd is a list of integers that associates each data point with its cluster. For fine tuning the classix clustering algorithm has the options 'radius' and 'minPoints'.
Note that MTEX automatically adapts the algorithm in presence of antipodals symmetry, i.e., the symmetrically equivalent points at the top and the bottom of the smiley are assigned to the same cluster.
v.antipodal = true;
[cInd,center] = calcCluster(v);
plot(v,ind2color(cInd),'MarkerAlpha',0.2,'MarkerSize',2)
annotate(center)
Analogously to directions, we may also cluster orientations. In order to demonstrate this we first draw a random sample from a model ODF consisting of a fibre and a unimodal component.
% define a cubic crystal symmetry
cs = crystalSymmetry('432');
% define an ODF with two radial peaks
odf = 0.7*fibreODF(fibre.gamma(cs),'halfwidth',10*degree) + ...
0.3*unimodalODF(orientation.byEuler(30*degree,10*degree,60*degree,cs))
% simulate 10k orientations from the ODF
ori = odf.discreteSample(10000);odf = SO3FunComposition (432 → y↑→x)
fibre component
kernel: de la Vallee Poussin, halfwidth 10°
fibre : (111) || 0,0,1
weight: 0.7
unimodal component
kernel: de la Vallee Poussin, halfwidth 10°
center: 1 orientations
Bunge Euler angles in degree
phi1 Phi phi2 weight
30 10 60 0.3Lets visualize the ODF and the random sampling
% view the ODF
plotSection(odf,'contourf')
mtexColorMap white2black
% together with the random sample
plot(ori,'add2all','MarkerSize',3,'MarkerAlpha',0.25,'all')
We again use the classix method for for clustering the orientations. Note that the algorithm separates the fibre from the unimodal portion. In particular, it correctly assigns all symmetrically equivalent orientations to the same cluster.
[cId,center] = calcCluster(ori,'method','classix');
plotSection(ori,ind2color(cId),'markerSize',3,'MarkerAlpha',0.25,'all')
annotate(center)
function plotCluster(r,cId,varargin)
scatter(r(cId==1),'MarkerFaceColor',ind2color(1),varargin{:})
hold on
for i = 2:max(cId)
scatter(r(cId==i),'add2all','MarkerFaceColor',ind2color(i),varargin{:})
end
hold off
end
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/ClusterDemo.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.