Skip to content
Snippets Groups Projects
Commit 909159ce authored by Nicola Vigano's avatar Nicola Vigano
Browse files

EBSD Viewer: added grain average R-vector calculation

parent c7590c3e
No related branches found
No related tags found
No related merge requests found
function [grain_r_vecs, grain_mask, grain_bb] = gtDefEBSDSegmentGrainFromSeed(EBSD_r_map, EBSD_mask, seed, threshold) function [grain_r_vecs, grain_mask, grain_bb, grain_avg_r_vec] = gtDefEBSDSegmentGrainFromSeed(EBSD_r_map, EBSD_mask, seed, threshold)
if (~exist('threshold', 'var') || isempty(threshold)) if (~exist('threshold', 'var') || isempty(threshold))
threshold = 5; threshold = 5;
end end
...@@ -53,4 +53,7 @@ function [grain_r_vecs, grain_mask, grain_bb] = gtDefEBSDSegmentGrainFromSeed(EB ...@@ -53,4 +53,7 @@ function [grain_r_vecs, grain_mask, grain_bb] = gtDefEBSDSegmentGrainFromSeed(EB
grain_r_vecs = zeros([size(grain_mask), 3], 'single'); grain_r_vecs = zeros([size(grain_mask), 3], 'single');
grain_r_vecs(grain_inds) = EBSD_r_map(full_grain_inds); grain_r_vecs(grain_inds) = EBSD_r_map(full_grain_inds);
r_vecs = reshape(grain_r_vecs(grain_inds), [], 3);
grain_avg_r_vec = sum(r_vecs, 1) / size(r_vecs, 1);
end end
...@@ -181,6 +181,10 @@ classdef GtEBSDView < GtBaseGuiElem ...@@ -181,6 +181,10 @@ classdef GtEBSDView < GtBaseGuiElem
obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ... obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ...
'Label', 'Copy pixel 3D info', ... 'Label', 'Copy pixel 3D info', ...
'Callback', cbk); 'Callback', cbk);
cbk = @(src, evt)copyGrainAvgRvecInfoToClipboard(obj);
obj.conf.h_menu_items{end+1} = uimenu(obj.conf.h_context_menu, ...
'Label', 'Copy grain Average R-vector info', ...
'Callback', cbk);
end end
function resetUiComponents(obj) function resetUiComponents(obj)
...@@ -207,6 +211,25 @@ classdef GtEBSDView < GtBaseGuiElem ...@@ -207,6 +211,25 @@ classdef GtEBSDView < GtBaseGuiElem
clipboard('copy', clipString); clipboard('copy', clipString);
end end
function copyGrainAvgRvecInfoToClipboard(self, verbose)
if ~exist('verbose','var') || isempty(verbose)
verbose = true;
end
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] = gtDefEBSDSegmentGrainFromSeed(self.conf.ebsd_map, self.conf.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');
if (verbose)
disp(clipString)
end
clipboard('copy', clipString);
end
function doUpdateDisplay(obj) function doUpdateDisplay(obj)
% GTVOLVIEW/DOUPDATEDISPLAY Function that actually updates all the % GTVOLVIEW/DOUPDATEDISPLAY Function that actually updates all the
% visualized GUI components of the GUI element % visualized GUI components of the GUI element
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment