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

6D-Reconstruction/Twins: fixed raw_images loading

parent 34c8abc8
No related branches found
No related tags found
No related merge requests found
......@@ -157,6 +157,7 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
max_img_sizes = zeros(num_grains, 2);
extended_projs = get6DExtendedProjDefinition(num_grains);
inconvenient_etas = cell(num_grains, 1);
samp_ors = cell(num_grains, 1);
......@@ -201,6 +202,13 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
extended_projs(ii_g).included = ref_included;
extended_projs(ii_g).selected = ref_selected;
end
local_ondet = extended_projs(ii_g).ondet;
local_included = extended_projs(ii_g).included;
refor_ns = refor.allblobs.eta(local_ondet(local_included));
% We avoid the vertical spots for convenience
inconvenient_etas{ii_g} = acosd(abs(cosd(refor_ns))) < conf.min_eta;
end
samp_ors = [samp_ors{:}];
......@@ -214,26 +222,35 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
img_sizes = cell(num_grains, 1);
for ii_g = 1:num_grains
local_sel_refl = extended_projs(ii_g).ondet(extended_projs(ii_g).included(extended_projs(ii_g).selected));
local_ondet = extended_projs(ii_g).ondet;
local_included = extended_projs(ii_g).included;
local_inc_refl = local_ondet(local_included);
uvw_tab{ii_g} = zeros(numel(local_sel_refl), numel(samp_ors(ii_g).bb_ors), 3);
uvw_tab{ii_g} = zeros(numel(local_inc_refl), numel(samp_ors(ii_g).bb_ors), 3);
for ii_o = 1:numel(samp_ors(ii_g).bb_ors)
uvw_tab{ii_g}(:, ii_o, :) = samp_ors(ii_g).bb_ors(ii_o).detector(conf.det_index).uvw(local_sel_refl, :);
uvw_tab{ii_g}(:, ii_o, :) = samp_ors(ii_g).bb_ors(ii_o).allblobs.detector(conf.det_index).uvw(local_inc_refl, :);
end
% Let's treat those blobs at the w edge 360->0
% (from the sampled orientations perspective)
refor_ws = refor.allblobs.omega(local_sel_refl) / gtGetOmegaStepDeg(p, conf.det_index);
refor_ws = refor.allblobs.omega(local_inc_refl) / gtGetOmegaStepDeg(p, conf.det_index);
uvw_tab{ii_g}(:, :, 3) = gtGrainAnglesTabularFix360deg(uvw_tab{ii_g}(:, :, 3), refor_ws, p);
img_bboxes{ii_g} = [ ...
min(uvw_tab{ii_g}(:, :, 1:2), [], 2), ...
max(uvw_tab{ii_g}(:, :, 1:2), [], 2) ];
reshape(floor(min(uvw_tab{ii_g}, [], 2)), [], 3), ...
reshape(ceil(max(uvw_tab{ii_g}, [], 2)), [], 3) ];
img_sizes{ii_g} = img_bboxes{ii_g}(:, 4:6) - img_bboxes{ii_g}(:, 1:3) + 1;
max_img_sizes(ii_g, :) = max(img_sizes{ii_g}(:, 1:2), [], 1);
img_sizes{ii_g} = img_bboxes{ii_g}(:, 4:5) - img_bboxes{ii_g}(:, 1:2) + 1;
img_sizes{ii_g} = reshape(img_sizes{ii_g}, [], 2);
if (conf.verbose)
refor_ns = refor.allblobs.eta(local_inc_refl);
max_img_sizes(ii_g, :) = max(img_sizes{ii_g}, [], 1);
fprintf('\nImages for orientation %d:\n', ii_g)
fprintf('%02d)du %8d, dv %8d, dw %8d, eta: %7.3f <- used: %d, u: [%4d %4d], v: [%4d %4d], w: [%4d %4d]\n', ...
[(1:numel(refor_ns))', img_sizes{ii_g}, refor_ns, ~inconvenient_etas{ii_g}, img_bboxes{ii_g}(:, [1 4 2 5 3 6]) ]');
end
end
else
for ii_g = 1:num_grains
......@@ -260,10 +277,7 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
for ii_b = 1:num_blobs
num_chars = fprintf('%03d/%03d', ii_b, num_blobs);
if (ii_g > 1 && extended_projs(ii_g).shared_refl(ii_b))
blobs(ii_b) = samp_ors(1).proj.bl( ...
extended_projs(ii_g).shared_refl_pos_in_parent(ii_b));
else
if (ii_g == 1 || ~extended_projs(ii_g).shared_refl(ii_b))
blobs(ii_b) = load_blob( ...
img_bboxes{ii_g}(ii_b, :), img_sizes{ii_g}(ii_b, :), ...
stackUSize, stackVSize, p, conf);
......@@ -271,6 +285,10 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
fprintf(repmat('\b', [1, num_chars]));
end
% Using the same because it gives the same size/uvw-limits
if (ii_g > 1)
blobs(extended_projs(ii_g).shared_refl) = samp_ors(1).proj(conf.det_index).bl(extended_projs(ii_g).shared_refl_pos_in_parent);
end
else
fprintf(' - Loading segmented blobs..')
......@@ -278,9 +296,9 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
blobs = grs(ii_g).proj.bl;
else
blobs = gtFwdSimBlobDefinition('blob', num_blobs);
blobs(~extended_projs(ii_g).shared_refl) = grs(ii_g).proj.bl(~extended_projs(ii_g).shared_refl_included_pos);
blobs(~extended_projs(ii_g).shared_refl) = grs(ii_g).proj(conf.det_index).bl(~extended_projs(ii_g).shared_refl_included_pos);
% Using the same because it gives the same size/uvw-limits
blobs(extended_projs(ii_g).shared_refl) = samp_ors(1).proj.bl(extended_projs(ii_g).shared_refl_pos_in_parent);
blobs(extended_projs(ii_g).shared_refl) = samp_ors(1).proj(conf.det_index).bl(extended_projs(ii_g).shared_refl_pos_in_parent);
if (conf.verbose)
parent_ids = grs(1).fwd_sim(conf.det_index).spotid(ref_included(extended_projs(ii_g).shared_refl_pos_in_parent))';
......@@ -293,6 +311,7 @@ function [samp_ors, estim_space_bbox_pix, estim_orient_bbox] = gt6DCreateProjDat
end
fprintf('\b\b: Done in %g seconds.\n - Equalizing blob sizes..', toc(c))
c = tic();
for ii_b = 1:num_blobs
num_chars = fprintf('%02d/%02d', ii_b, num_blobs);
......@@ -643,6 +662,8 @@ function blob = load_blob(img_bboxes, img_sizes, stackUSize, stackVSize, p, conf
blob.intm = gtPlaceSubVolume( ...
zeros(blob_size_im, 'single'), single(blob_vol), shifts_blob);
blob.mask = true(blob_size_im);
blob.bbsize = blob_size_im;
blob_bb_im = [blob_bb(1, 1:3) - shifts_blob, blob_size_im];
......
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