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

6G-Reconstruction/VolumeDownscaling: moved to linear interpolation for the upscaling

parent 21013ec7
No related branches found
No related tags found
No related merge requests found
......@@ -214,7 +214,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
end
if (self.volume_downscaling > 1)
volume_size = round(volume_size / self.volume_downscaling);
volume_size = ceil(volume_size / self.volume_downscaling);
for ii = 1:num_geoms
geometries{ii}(:, 4:12) = geometries{ii}(:, 4:12) / self.volume_downscaling;
end
......
......@@ -6,11 +6,12 @@ function vol = gtMathsUpsampleVolume(vol, scale)
vol{ii} = gtMathsUpsampleVolume(vol{ii}, scale);
end
else
vol = upsample(vol, scale);
vol = upsample_interp_interleaving(vol, scale);
end
end
function vol = upsample(vol, scale)
% The fastest!
vol_in_size = size(vol);
for ii_dim = numel(vol_in_size):-1:1
indx{ii_dim} = 1:vol_in_size(ii_dim);
......@@ -19,3 +20,21 @@ function vol = upsample(vol, scale)
end
vol = vol(indx{:});
end
function vol = upsample_interp_interleaving(vol, scale)
% Faster than the custom made, bu still way slower than the simple one
vol = interpn(vol, scale-1, 'linear', 0);
end
function vol = upsample_interp(vol, scale)
% It does exactly what the interleaving does, but it is here as a tutorial
% for future reerence
vol_in_size = size(vol);
num_dims = numel(vol_in_size);
for ii_dim = num_dims:-1:1
indx_out{ii_dim} = 1:(1/scale):vol_in_size(ii_dim);
end
grid_out = cell(1, num_dims);
[grid_out{:}] = ndgrid(indx_out{:});
vol = interpn(vol, grid_out{:}, 'linear');
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