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

Assembling: Fixed R-vector assembling

parent e5a5c014
No related branches found
No related tags found
No related merge requests found
......@@ -547,10 +547,8 @@ classdef GtAssembleVol3D < handle
single_dim_dmvol = gtCrop(single_dim_dmvol, segbb);
single_dim_dmvol(~seg_vol) = 0;
% Turning the C functions off is way slower, but
% for some reason they don't work in this case
dmvol = gtPlaceSubVolume( dmvol, single_dim_dmvol, ...
[volBBox(1:3), ii_dim-1], [], obj.localPar.overlaps, false);
[volBBox(1:3), ii_dim-1], [], 'assign');
end
catch mexc
gtPrintException(mexc, sprintf('\nGrain %d failed!!\n', ii));
......
......@@ -14,6 +14,11 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
% shift=[2 -2 0] means that voxel (a, b, c) will be at (a+2, b-2, c) in
% output.
%
% if the output volume has more than 3 dimensions, the shifts have to
% be extended in order to select the position in the next dimensions.
% Otherwhise ones will be placed
% However, the placing will still happen in the first 3 dimensions
%
% Note - this is used to add on volume to another one, rather than
% placing one image in the other.
% I have modified so it no longer adds it. I hope this doesn't break
......@@ -32,6 +37,10 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
assign_op = 'assign';
end
if (index ~= 0)
input = index .* input;
end
inputSize = size(input);
outputSize = size(output);
num_input_dims = numel(inputSize);
......@@ -49,28 +58,17 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
inputSize((num_input_dims+1):3) = 1;
outputSize((num_output_dims+1):3) = 1;
shift((numel(shift)+1):max(num_output_dims, 3)) = 0;
% We add one because the shifting is done in matlab code!
extra_dims_shift = arrayfun(@(x){x+1}, shift(4:num_output_dims));
full_output = output;
if (~isempty(extra_dims_shift))
output = full_output(:, :, :, extra_dims_shift{:});
end
shift((numel(shift)+1):num_output_dims) = 0;
% output and input volume limits
[outLims, inLims] = gtGetVolsIntersectLimits(outputSize(1:3), inputSize, shift(1:3));
input = input( inLims(1, 1):inLims(2, 1), ...
inLims(1, 2):inLims(2, 2), ...
inLims(1, 3):inLims(2, 3) );
lims = [ outLims(1, 1) outLims(2, 1) ...
outLims(1, 2) outLims(2, 2) ...
outLims(1, 3) outLims(2, 3) ];
if (use_c_functions)
% Logicals are not handled in he C++ classes
shifts_op = [outLims(1, :) - 1, shift(4:end)];
shifts_ip = inLims(1, :) - 1;
dims = outLims(2, :) - outLims(1, :) + 1;
% Logicals are not handled in the C++ function
is_out_logical = islogical(output);
if (is_out_logical)
output = uint8(output);
......@@ -90,11 +88,11 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
switch (assign_op)
case {'zero', 'conflict', 'adaptive'} % Mark overlapping...
output = internal_gtAssignGrainToVol_interf( output, input, index, lims );
gtCxxPlaceSubVolumeInterf(output, input, shifts_op, shifts_ip, dims);
case 'summed'
output = internal_gtAssignGrainToVol_sum( output, input, index, lims );
gtCxxPlaceSubVolumeSum(output, input, shifts_op, shifts_ip, dims);
case {'assign', 'parent'}
output = internal_gtAssignGrainToVol( output, input, index, lims );
gtCxxPlaceSubVolumeAssign(output, input, shifts_op, shifts_ip, dims);
otherwise
error('PLACE:wrong_argument', 'No option for "%s"', assign_op);
end
......@@ -103,6 +101,23 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
output = logical(output);
end
else
input = input( ...
inLims(1, 1):inLims(2, 1), ...
inLims(1, 2):inLims(2, 2), ...
inLims(1, 3):inLims(2, 3) );
lims = [ ...
outLims(1, 1), outLims(2, 1), ...
outLims(1, 2), outLims(2, 2), ...
outLims(1, 3), outLims(2, 3) ];
% We add one because the shifting is done in matlab code!
extra_dims_shift = arrayfun(@(x){x+1}, shift(4:num_output_dims));
full_output = output;
if (~isempty(extra_dims_shift))
output = full_output(:, :, :, extra_dims_shift{:});
end
switch (assign_op)
case {'zero', 'conflict', 'adaptive'}
% Matlab sugars to do the same that 'internal_gtAssignGrainToVol_interf'
......@@ -128,10 +143,10 @@ function output = gtPlaceSubVolume(output, input, shift, index, assign_op, use_c
otherwise
error('PLACE:wrong_argument', 'No option for "%s"', assign_op);
end
end
if (~isempty(extra_dims_shift))
full_output(:, :, :, extra_dims_shift{:}) = output;
output = full_output;
if (~isempty(extra_dims_shift))
full_output(:, :, :, extra_dims_shift{:}) = output;
output = full_output;
end
end
end
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