Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
8f304318
Commit
8f304318
authored
9 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
GtEBSDView: improved to accept and use the EBSD data structure
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
51bf0dc0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zUtil_TomoUtils/GtEBSDView.m
+76
-26
76 additions, 26 deletions
zUtil_TomoUtils/GtEBSDView.m
with
76 additions
and
26 deletions
zUtil_TomoUtils/GtEBSDView.m
+
76
−
26
View file @
8f304318
classdef
GtEBSDView
<
GtBaseGuiElem
properties
ebsd
=
[]
;
end
methods
function
self
=
GtEBSDView
(
ebsd_
map
,
varargin
)
function
self
=
GtEBSDView
(
ebsd
_
str
,
varargin
)
%
GTVOLVIEW
/
GTVOLVIEW
Constructor
self
=
self
@
GtBaseGuiElem
()
;
...
...
@@ -11,24 +12,16 @@ classdef GtEBSDView < GtBaseGuiElem
self
.
conf
.
cmap
=
'
gray
';
if
(
isstruct
(
ebsd_map
))
ebsd
=
ebsd_map
;
ebsd_map
=
ebsd
.
map_r
;
ebsd_mask
=
ebsd
.
mask
;
phase_id
=
ebsd
.
phase_id
;
else
ebsd_mask
=
[];
phase_id
=
1
;
if
(
~
isstruct
(
ebsd
_
str
))
error
(
'
GtEBSDView
:
wrong
_
argument
',
...
'
Only
an
EBSD
data
structure
is
accepted
'
)
end
self
.
conf
.
ebsd_map
=
ebsd_map
;
self
.
conf
.
mask
=
ebsd_mask
;
self
.
ebsd
=
ebsd
_
str
;
self
.
conf
.
ipf
_
axis
=
[]
;
self
.
conf
.
phase_id
=
phase_id
;
self
.
conf
.
horDim
=
1
;
self
.
conf
.
verDim
=
2
;
[
dim
(
1
),
dim
(
2
),
dim
(
3
)]
=
size
(
self
.
conf
.
ebsd
_
map
);
[
dim
(
1
)
,
dim
(
2
)
,
dim
(
3
)]
=
size
(
self
.
ebsd
.
map
_
r
)
;
self
.
conf
.
dim
=
dim
(
1
:
2
)
;
self
.
conf
.
hordisplay
=
[
1
self
.
conf
.
dim
(
1
)]
;
self
.
conf
.
verdisplay
=
[
1
self
.
conf
.
dim
(
2
)]
;
...
...
@@ -59,7 +52,7 @@ classdef GtEBSDView < GtBaseGuiElem
%
GTVOLVIEW
/
GETVOLVALUE
Returns
the
value
for
the
given
point
,
from
the
%
volume
stored
in
the
object
roundedPoint
=
round
(
point
)
;
r_vec
=
obj
.
conf
.
ebsd
_
map
(
roundedPoint
(
1
),
roundedPoint
(
2
),
:);
r
_
vec
=
obj
.
ebsd
.
map
_
r
(
roundedPoint
(
1
)
,
roundedPoint
(
2
)
,
:
)
;
r
_
vec
=
reshape
(
r
_
vec
,
1
,
3
)
;
end
...
...
@@ -84,11 +77,11 @@ classdef GtEBSDView < GtBaseGuiElem
function
initParams
(
self
,
arguments
)
initParams
@
GtBaseGuiElem
(
self
,
arguments
)
bad_voxels_mask
=
any
(
abs
(
self
.
conf
.
ebsd
_
map
)
>
eps
(
'single'
),
3
);
if
(
isempty
(
self
.
conf
.
mask
))
self
.
conf
.
mask
=
bad_voxels_mask
;
bad
_
voxels
_
mask
=
any
(
abs
(
self
.
ebsd
.
map
_
r
)
>
eps
(
'
single
'
)
,
3
)
;
if
(
isempty
(
self
.
ebsd
.
mask
))
self
.
ebsd
.
mask
=
bad
_
voxels
_
mask
;
else
self
.
conf
.
mask
=
self
.
conf
.
mask
&
bad_voxels_mask
;
self
.
ebsd
.
mask
=
self
.
ebsd
.
mask
&
bad
_
voxels
_
mask
;
end
end
...
...
@@ -186,8 +179,8 @@ classdef GtEBSDView < GtBaseGuiElem
set
(
obj
.
conf
.
h
_
im
,
'
UIContextMenu
',
obj
.
conf
.
h
_
context
_
menu
)
;
%
Copy
pixel
info
in
context
menu
cbk
=
@
(
src
,
evt
)
copy3DPixInfoToClipboard
(
obj
);
obj
.
conf
.
h
_
menu
_
items
=
{}
;
cbk
=
@
(
src
,
evt
)
copy3DPixInfoToClipboard
(
obj
)
;
obj
.
conf
.
h
_
menu
_
items
{
end
+
1
}
=
uimenu
(
obj
.
conf
.
h
_
context
_
menu
,
...
'
Label
',
'
Copy
pixel
3
D
info
',
...
'
Callback
',
cbk
)
;
...
...
@@ -195,6 +188,14 @@ classdef GtEBSDView < GtBaseGuiElem
obj
.
conf
.
h
_
menu
_
items
{
end
+
1
}
=
uimenu
(
obj
.
conf
.
h
_
context
_
menu
,
...
'
Label
',
'
Copy
grain
Average
R
-
vector
info
',
...
'
Callback
',
cbk
)
;
cbk
=
@
(
src
,
evt
)
segmentGrain
(
obj
)
;
obj
.
conf
.
h
_
menu
_
items
{
end
+
1
}
=
uimenu
(
obj
.
conf
.
h
_
context
_
menu
,
...
'
Label
',
'
Segment
grain
to
file
...',
...
'
Callback
',
cbk
)
;
cbk
=
@
(
src
,
evt
)
extractBandContrastOfGrain
(
obj
)
;
obj
.
conf
.
h
_
menu
_
items
{
end
+
1
}
=
uimenu
(
obj
.
conf
.
h
_
context
_
menu
,
...
'
Label
',
'
Extract
grain
Band
Contrast
to
file
...',
...
'
Callback
',
cbk
)
;
end
function
resetUiComponents
(
obj
)
...
...
@@ -230,7 +231,7 @@ classdef GtEBSDView < GtBaseGuiElem
else
point
=
round
(
self
.
getPixel
())
;
end
[
grain_r_vecs
,
grain_mask
]
=
gtDefEBSDSegmentGrainFromSeed
(
self
.
conf
.
ebsd
_
map
,
self
.
conf
.
mask
,
point
);
[
grain
_
r
_
vecs
,
grain
_
mask
]
=
gtDefEBSDSegmentGrainFromSeed
(
self
.
ebsd
.
map
_
r
,
self
.
ebsd
.
mask
,
point
)
;
grain
_
r
_
vecs
=
gtDefDmvol2Gvdm
(
permute
(
grain
_
r
_
vecs
,
[
1
2
4
3
]))
;
avg
_
r
_
vec
=
sum
(
grain
_
r
_
vecs
(
:,
grain
_
mask
(
:
))
,
2
)
./
sum
(
grain
_
mask
(
:
))
;
clipString
=
sprintf
(
'
(
%
d
,
%
d
)
[
%
g
,
%
g
,
%
g
]
',
point
,
avg
_
r
_
vec
'
)
;
...
...
@@ -240,6 +241,55 @@ classdef GtEBSDView < GtBaseGuiElem
clipboard
(
'
copy
',
clipString
)
;
end
function
segmentGrain
(
self
)
if
(
isfield
(
self
.
conf
,
'
clicked
_
point
'
)
&&
~
isempty
(
self
.
conf
.
clicked
_
point
))
point
=
round
(
self
.
conf
.
clicked
_
point
)
;
else
point
=
round
(
self
.
getPixel
())
;
end
[
grain
_
r
_
vecs
,
grain
_
mask
,
grain
_
bb
]
=
gtDefEBSDSegmentGrainFromSeed
(
self
.
ebsd
.
map
_
r
,
self
.
ebsd
.
mask
,
point
)
;
filter
=
{
'*.
mat
',
'
MATLAB
Files
(*.mat)'};
[filename, pathname] = uiputfile( ...
filter, 'Select file...', ...
fullfile('EBSD', 'grain_seg.mat'));
grain_struct = struct( ...
'R_vectors', grain_r_vecs, ...
'mask', grain_mask, ...
'bb', grain_bb); %#ok<NASGU>
if (filename)
save(fullfile(pathname, filename), '-struct', 'grain_struct', '-v7.3');
end
end
function extractBandContrastOfGrain(self)
if (isfield(self.conf, 'clicked_point') && ~isempty(self.conf.clicked_point))
point = round(self.conf.clicked_point);
else
point = round(self.getPixel());
end
[~, grain_mask, grain_bb] = gtDefEBSDSegmentGrainFromSeed(self.ebsd.map_r, self.ebsd.mask, point);
grain_lims = grain_bb([1 2 1 2]) + [1 1 grain_bb(3:4)];
grain_bc = self.ebsd.bc(grain_lims(1):grain_lims(3), grain_lims(2):grain_lims(4));
grain_struct = struct( ...
'band_contrast', grain_bc, ...
'mask', grain_mask, ...
'bb', grain_bb); %#ok<NASGU>
filter = {'*.mat', 'MATLAB Files (*.mat)'};
[filename, pathname] = uiputfile( ...
filter, 'Select file...', ...
fullfile('EBSD', 'grain_bc.mat'));
if (filename)
save(fullfile(pathname, filename), '-struct', 'grain_struct', '-v7.3');
end
end
function doUpdateDisplay(obj)
% GTVOLVIEW/DOUPDATEDISPLAY Function that actually updates all the
% visualized GUI components of the GUI element
...
...
@@ -288,17 +338,17 @@ classdef GtEBSDView < GtBaseGuiElem
% transformations on them, to adapt to the requested visualization needs
p = gtLoadParameters();
cryst_system
=
p
.
cryst
(
self
.
conf
.
phase_id
)
.
crystal_system
;
cryst_spacegroup
=
p
.
cryst
(
self
.
conf
.
phase_id
)
.
spacegroup
;
cryst_system = p.cryst(self.
ebsd
.phase_id).crystal_system;
cryst_spacegroup = p.cryst(self.
ebsd
.phase_id).spacegroup;
symm = gtCrystGetSymmetryOperators(cryst_system, cryst_spacegroup);
indx
=
find
(
self
.
conf
.
mask
);
indx = find(self.
ebsd
.mask);
r_vecs
=
reshape
(
self
.
conf
.
ebsd
_
map
,
[],
3
);
r_vecs = reshape(self.ebsd
.
map
_r
, [], 3);
r_vecs = r_vecs(indx, :);
[cmap, ~, ~] = gtIPFCmap( ...
self
.
conf
.
phase_id
,
self
.
conf
.
ipf_axis
,
...
self.
ebsd
.phase_id, self.conf.ipf_axis, ...
'r_vectors', r_vecs, ...
'crystal_system', cryst_system, ...
'background', false, ...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment