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
275 stars 182 forks source link

@EBSD/cat: Remove overlapping data? #362

Open filippeof opened 5 years ago

filippeof commented 5 years ago

When concatenating EBSD data containing slight orientation/spatial deviation at the edges (due to acquisition issues such as distortion, pattern centre shift, etc. ) some pixels indexed differently might partially overlap and cause problems for grain calculations( See grain boundaries overlapping at the center of Fig. 1). Should these overlapping EBSD pixels be removed?

Example: Concatenate 2 EBSD files (files attached) along X and remove overlapping pixels of right map.

% Import data
fname_l='ebsd_l.ang'; % ebsd left
fname_r='ebsd_r.ang';% ebsd right

ebsd_l = loadEBSD(fname_l,'interface','ang',...
  'convertEuler2SpatialReferenceFrame');

ebsd_r = loadEBSD(fname_r,'interface','ang',...
  'convertEuler2SpatialReferenceFrame');

% Shift EBSD right
xtd_l=ebsd_l.extend;
ebsd_r2=shift(ebsd_r,[xtd_l(2)-11,-12]);
ebsd_all=[ebsd_l, ebsd_r2];
% Calc grains
[grains_all,ebsd_all.grainId,~] = calcGrains(ebsd_all,'threshold', 15*degree);

%Remove small grains
grains_all=grains_all(grains_all.grainSize>20);

%Plot
figure; plot(ebsd_all('ol'),ebsd_all('ol').orientations)
hold on;plot(grains_all('ol').boundary);hold off

%% Remove overlapping EBSD data
xtd_l=ebsd_l.extend;
ebsd_r2=shift(ebsd_r,[xtd_l(2)-11,-12]);
ebsd_r2_new=ebsd_r2(ebsd_r2.prop.x>=xtd_l(2));
ebsd_new=[ebsd_l, ebsd_r2_new];

% And plot:
[grains_new,ebsd_new.grainId,~] = calcGrains(ebsd_new,'threshold', 15*degree);
grains_new=grains_new(grains_new.grainSize>20);
figure; plot(ebsd_new('ol'),ebsd_new('ol').orientations)
hold on;plot(grains_new('ol').boundary);hold off
Fig 1. Stitched maps Fig 2. After remove overlapping EBSD data
image1 image2

In this case creating a subset based on the overlapping X property was enough but something more robust such as checking for repetition of individual pixels (X and Y) within a given tolerance and allow user to decide to which EBSD data to keep: e.g. by order of arguments or EBSD quality ( e.g keep pixels with higher ci, iq | bs, bc) might be necessary.

Best, Filippe

EBSD files: ebsd_L_and_R.zip

filippeof commented 5 years ago

Removing overlapping data checking individual pixels:

XY_l=[ebsd_l.prop.x,ebsd_l.prop.y];
XY_r=[ebsd_r2.prop.x,ebsd_r2.prop.y];

% Set Tolerance = half the stepSize
area_shape=polyarea(ebsd_r.unitCell(:,1),ebsd_r.unitCell(:,2));
stepSize=sqrt(area_shape/sind(60)); % For hexagonal grid
tol=stepSize/2;

% Find overlapping points
[overlapID,~] = ismembertol(XY_r,XY_l,tol,'ByRows',true,'DataScale',1);

% Remove them:
ebsd_r2_new=ebsd_r2(~overlapID);
ebsd_new=[ebsd_l, ebsd_r2_new];

% And plot:
[grains_new,ebsd_new.grainId,~] = calcGrains(ebsd_new,'threshold', 15*degree);
grains_new=grains_new(grains_new.grainSize>20);
figure; plot(ebsd_new('ol'),ebsd_new('ol').orientations)
hold on;plot(grains_new('ol').boundary);hold off