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

6D-Phantom/Cluster: fixed bug with std included blob output

parent f1874db5
No related branches found
No related tags found
No related merge requests found
......@@ -204,7 +204,7 @@ function [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_
img_sizes = img_sizes(~inconvenient_etas, :);
fprintf('Loading raw images: ')
num_blobs = size(img_bboxes, 1);
num_blobs = numel(ref_included);
blobs(1:num_blobs) = struct( ...
'intm', [], ... % The normalized blob
......@@ -225,8 +225,11 @@ function [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_
sel_reflections = find(ref_selected);
sel_reflections = sel_reflections(~inconvenient_etas);
for ii_i = 1:num_blobs
num_chars = fprintf('%02d/%02d', ii_i, num_blobs);
num_sel_refl = numel(sel_reflections);
for ii_i = 1:num_sel_refl
num_chars = fprintf('%02d/%02d', ii_i, num_sel_refl);
ii_b = sel_reflections(ii_i);
bb = [img_bboxes(ii_i, 1:2), img_sizes(ii_i, 1:2)];
blob_vol = gtGetRawRoi(img_bboxes(ii_i, 3), img_bboxes(ii_i, 6), p.acq, bb);
......@@ -235,59 +238,59 @@ function [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_
% Transposing to keep the same convention as spots
blob_vol = permute(blob_vol, [2 1 3]);
blobs(ii_i).mbbsize = blob_bb(4:6);
blobs(ii_i).mbbu = [blob_bb(1), blob_bb(1) + blob_bb(4) + 1];
blobs(ii_i).mbbv = [blob_bb(2), blob_bb(2) + blob_bb(5) + 1];
blobs(ii_i).mbbw = [blob_bb(3), blob_bb(3) + blob_bb(6) + 1];
blobs(ii_b).mbbsize = blob_bb(4:6);
blobs(ii_b).mbbu = [blob_bb(1), blob_bb(1) + blob_bb(4) + 1];
blobs(ii_b).mbbv = [blob_bb(2), blob_bb(2) + blob_bb(5) + 1];
blobs(ii_b).mbbw = [blob_bb(3), blob_bb(3) + blob_bb(6) + 1];
blob_size_im = [stackUSize, stackVSize, blob_bb(6)+2];
shifts_blob = gtFwdSimGetStackShifts(stackUSize, stackVSize, blob_bb, false);
shifts_blob = [shifts_blob.u, shifts_blob.v, 1];
blobs(ii_i).intm = gtPlaceSubVolume( ...
blobs(ii_b).intm = gtPlaceSubVolume( ...
zeros(blob_size_im, 'single'), blob_vol, shifts_blob);
blobs(ii_i).bbsize = blob_size_im;
blobs(ii_b).bbsize = blob_size_im;
blob_bb_im = [blob_bb(1:3) - shifts_blob, blob_size_im];
blobs(ii_i).bbuim = [blob_bb_im(1), blob_bb_im(1) + blob_bb_im(4) - 1];
blobs(ii_i).bbvim = [blob_bb_im(2), blob_bb_im(2) + blob_bb_im(5) - 1];
blobs(ii_i).bbwim = [blob_bb_im(3), blob_bb_im(3) + blob_bb_im(6) - 1];
blobs(ii_b).bbuim = [blob_bb_im(1), blob_bb_im(1) + blob_bb_im(4) - 1];
blobs(ii_b).bbvim = [blob_bb_im(2), blob_bb_im(2) + blob_bb_im(5) - 1];
blobs(ii_b).bbwim = [blob_bb_im(3), blob_bb_im(3) + blob_bb_im(6) - 1];
% We should build the mask from the segmented reflections of the
% grains
% for the moment we only use one (the reference one), to
% renormalize the different reflections
blobs(ii_i).mask = false(blob_size_im);
blobs(ii_b).mask = false(blob_size_im);
for ii_g = 1
gbl = refgr.proj.bl(sel_reflections(ii_i));
% gbl = grs(ii_g).proj.bl(sel_reflections(ii_i));
gbl = refgr.proj.bl(ii_b);
% gbl = grs(ii_g).proj.bl(ii_b);
grain_mask = gbl.mask;
gbl_shifts_im = [gbl.bbuim(1), gbl.bbvim(1), gbl.bbwim(1)];
blob_shifts_im = [ ...
blobs(ii_i).bbuim(1), blobs(ii_i).bbvim(1), blobs(ii_i).bbwim(1)];
blobs(ii_b).bbuim(1), blobs(ii_b).bbvim(1), blobs(ii_b).bbwim(1)];
mask_shifts = gbl_shifts_im - blob_shifts_im;
blobs(ii_i).mask = gtPlaceSubVolume(blobs(ii_i).mask, ...
blobs(ii_b).mask = gtPlaceSubVolume(blobs(ii_b).mask, ...
grain_mask, mask_shifts);
end
blob_int = sum(blobs(ii_i).intm(blobs(ii_i).mask));
blobs(ii_i).intm = blobs(ii_i).intm / blob_int;
blob_int = sum(blobs(ii_b).intm(blobs(ii_b).mask));
blobs(ii_b).intm = blobs(ii_b).intm / blob_int;
% Since we need to build the mask from the reflections of the
% grains, and we might not have them all, we in the end reset the
% mask to 1 but we used it for renormalization purpouses
if (true)
blobs(ii_i).mask = gtPlaceSubVolume( ...
blobs(ii_b).mask = gtPlaceSubVolume( ...
false(blob_size_im), true(size(blob_vol)), shifts_blob);
end
blobs(ii_i).intensity = blob_int;
blobs(ii_b).intensity = blob_int;
fprintf(repmat('\b', [1 num_chars]));
fprintf(repmat(' ', [1 num_chars]));
......@@ -295,6 +298,20 @@ function [proj, refor, or] = gt6DCreateProjDataFromGrainCluster(grs_list, phase_
end
fprintf('Done.\n')
% Now filling the remaining blobs with the blobs from refgr
% (even if they won't be used)
% ! this might change in the future ! to maybe include fwd projected
% regions on the detector
not_sel_reflections = true(size(ref_included));
not_sel_reflections(sel_reflections) = false;
not_sel_reflections = find(not_sel_reflections);
blobs(not_sel_reflections) = refgr.proj.bl(not_sel_reflections);
for ii_i = 1:numel(not_sel_reflections)
ii_b = not_sel_reflections(ii_i);
blobs(ii_b).intm = [];
blobs(ii_b).mask = [];
end
spots = arrayfun(@(x){sum(x.intm, 3)}, blobs);
spots = permute(cat(3, spots{:}), [1 3 2]);
......
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