From d12f8106195a44e2cc9a22354c18c2827e3be100 Mon Sep 17 00:00:00 2001 From: Nicola Vigano <nicola.vigano@esrf.fr> Date: Wed, 21 Jan 2015 15:35:11 +0100 Subject: [PATCH] Added forgotten Upsampling function Signed-off-by: Nicola Vigano <nicola.vigano@esrf.fr> --- zUtil_Maths/gtMathsUpsampleVolume.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 zUtil_Maths/gtMathsUpsampleVolume.m diff --git a/zUtil_Maths/gtMathsUpsampleVolume.m b/zUtil_Maths/gtMathsUpsampleVolume.m new file mode 100644 index 00000000..25abeeae --- /dev/null +++ b/zUtil_Maths/gtMathsUpsampleVolume.m @@ -0,0 +1,21 @@ +function vol = gtMathsUpsampleVolume(vol, scale) +% FUNCTION vol = gtMathsUpsampleVolume(vol, scale) + + if (iscell(vol)) + for ii = 1:numel(vol) + vol{ii} = gtMathsUpsampleVolume(vol{ii}, scale); + end + else + vol = upsample(vol, scale); + end +end + +function vol = upsample(vol, scale) + vol_in_size = size(vol); + for ii_dim = numel(vol_in_size):-1:1 + indx{ii_dim} = 1:vol_in_size(ii_dim); + indx{ii_dim} = indx{ii_dim}(ones(scale, 1), :); + indx{ii_dim} = reshape(indx{ii_dim}, [], 1); + end + vol = vol(indx{:}); +end -- GitLab