mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
285 stars 185 forks source link

added option for minPixel #2089

Closed vedadb closed 3 weeks ago

vedadb commented 6 months ago

Added option "minPixel" not to need to do Option 1. Option 2. just skips the generation of grains object so slight speed up. (performs the same tesselation first run as second) Option 3 and 4 perform first modified tesselation/graincalculation first run - either as scalar ebsd map (spatialDecomposition.m) or unit cell, and they produce the same grain map. - "major speed up". Please try

e = ebsd; e= e.gridify; e1 = e;

Option 1: tic [g,e.grainId] = calcGrains(e); e(g(g.grainSize<5)) = []; e=e.gridify; g=calcGrains(e); toc

Option 2: tic g1 = calcGrains(e1,'minPixel',5); toc

Option 3: tic g2 = calcGrains(e1,'minPixel',5,'byScalar'); toc

Option 4: tic g3 = calcGrains(e1,'minPixel',5,'byUnitCell'); toc

% Elapsed time is 29.616039 seconds. % Elapsed time is 28.059836 seconds. % Elapsed time is 19.381225 seconds. % Elapsed time is 17.654077 seconds.

%
% Phase Grains Pixels Mineral Symmetry Crystal reference frame % 1 3401 635157 Copper m-3m

% g1 = grain2d %
% Phase Grains Pixels Mineral Symmetry Crystal reference frame % 1 3401 635157 Copper m-3m
%

% g2 = grain2d %
% Phase Grains Pixels Mineral Symmetry Crystal reference frame % 1 3347 634138 Copper m-3m

% g3 = grain2d %
% Phase Grains Pixels Mineral Symmetry Crystal reference frame % 1 3347 634138 Copper m-3m

vedadb commented 6 months ago

Note: As the ebsd map is changed (pixels removed), the returned grainId size is different from the input ebsd-map size, thus the ebsd-map needs to be returned as well.

e.g.

[grains,ebsd] = calcGrains(ebsd,'minPixel',5);

A quick-fix I implemented for myself was to return the ebsd map instead of grainId if minPixel was specified