summaryrefslogtreecommitdiffstats
path: root/matlab/tools
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-11-22 16:41:34 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2017-11-22 16:41:34 +0100
commita527cc9e29cae256bd095b032f34c80957e84907 (patch)
treee68dd547d6a88c188eca4798423adf084ba58124 /matlab/tools
parent6a7b605102f1c22224b516906cb4a848cda50a3b (diff)
parentbd2798bed2fddfe00dac006013a9fb1363417f20 (diff)
downloadastra-a527cc9e29cae256bd095b032f34c80957e84907.tar.gz
astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.bz2
astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.xz
astra-a527cc9e29cae256bd095b032f34c80957e84907.zip
Merge branch 'master' into parallel_vec
Diffstat (limited to 'matlab/tools')
-rw-r--r--matlab/tools/astra_create_vol_geom.m31
-rw-r--r--matlab/tools/astra_get_gpu_info.m20
-rw-r--r--matlab/tools/astra_test_CUDA.m59
-rw-r--r--matlab/tools/astra_test_noCUDA.m32
4 files changed, 123 insertions, 19 deletions
diff --git a/matlab/tools/astra_create_vol_geom.m b/matlab/tools/astra_create_vol_geom.m
index bf24609..24fa957 100644
--- a/matlab/tools/astra_create_vol_geom.m
+++ b/matlab/tools/astra_create_vol_geom.m
@@ -38,21 +38,12 @@ if numel(varargin) == 1 && numel(varargin{1}) == 1
vol_geom = struct();
vol_geom.GridRowCount = varargin{1}(1);
vol_geom.GridColCount = varargin{1}(1);
- vol_geom.option.WindowMinX = -varargin{1}(1) / 2;
- vol_geom.option.WindowMaxX = varargin{1}(1) / 2;
- vol_geom.option.WindowMinY = -varargin{1}(1) / 2;
- vol_geom.option.WindowMaxY = varargin{1}(1) / 2;
-
% astra_create_vol_geom([row_count col_count])
elseif numel(varargin) == 1 && numel(varargin{1}) == 2
vol_geom = struct();
vol_geom.GridRowCount = varargin{1}(1);
vol_geom.GridColCount = varargin{1}(2);
- vol_geom.option.WindowMinX = -varargin{1}(2) / 2;
- vol_geom.option.WindowMaxX = varargin{1}(2) / 2;
- vol_geom.option.WindowMinY = -varargin{1}(1) / 2;
- vol_geom.option.WindowMaxY = varargin{1}(1) / 2;
% astra_create_vol_geom([row_count col_count slice_count])
elseif numel(varargin) == 1 && numel(varargin{1}) == 3
@@ -60,22 +51,12 @@ elseif numel(varargin) == 1 && numel(varargin{1}) == 3
vol_geom.GridRowCount = varargin{1}(1);
vol_geom.GridColCount = varargin{1}(2);
vol_geom.GridSliceCount = varargin{1}(3);
- vol_geom.option.WindowMinX = -varargin{1}(2) / 2;
- vol_geom.option.WindowMaxX = varargin{1}(2) / 2;
- vol_geom.option.WindowMinY = -varargin{1}(1) / 2;
- vol_geom.option.WindowMaxY = varargin{1}(1) / 2;
- vol_geom.option.WindowMinZ = -varargin{1}(3) / 2;
- vol_geom.option.WindowMaxZ = varargin{1}(3) / 2;
% astra_create_vol_geom(row_count, col_count)
elseif numel(varargin) == 2
vol_geom = struct();
vol_geom.GridRowCount = varargin{1};
vol_geom.GridColCount = varargin{2};
- vol_geom.option.WindowMinX = -varargin{2} / 2;
- vol_geom.option.WindowMaxX = varargin{2} / 2;
- vol_geom.option.WindowMinY = -varargin{1} / 2;
- vol_geom.option.WindowMaxY = varargin{1} / 2;
% astra_create_vol_geom(row_count, col_count, min_x, max_x, min_y, max_y)
elseif numel(varargin) == 6
@@ -108,3 +89,15 @@ elseif numel(varargin) == 9
vol_geom.option.WindowMaxZ = varargin{9};
end
+
+% set the window options, if not set already.
+if ~isfield(vol_geom, 'option') || ~isfield(vol_geom.option, 'WindowMinX')
+ vol_geom.option.WindowMinX = -vol_geom.GridColCount / 2;
+ vol_geom.option.WindowMaxX = vol_geom.GridColCount / 2;
+ vol_geom.option.WindowMinY = -vol_geom.GridRowCount / 2;
+ vol_geom.option.WindowMaxY = vol_geom.GridRowCount / 2;
+ if isfield(vol_geom, 'GridSliceCount')
+ vol_geom.option.WindowMinZ = -vol_geom.GridSliceCount / 2;
+ vol_geom.option.WindowMaxZ = vol_geom.GridSliceCount / 2;
+ end
+end
diff --git a/matlab/tools/astra_get_gpu_info.m b/matlab/tools/astra_get_gpu_info.m
new file mode 100644
index 0000000..c220371
--- /dev/null
+++ b/matlab/tools/astra_get_gpu_info.m
@@ -0,0 +1,20 @@
+function astra_set_gpu_index(index)
+
+%--------------------------------------------------------------------------
+% Set the index of the GPU to use
+%--------------------------------------------------------------------------
+%--------------------------------------------------------------------------
+% This file is part of the ASTRA Toolbox
+%
+% Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp
+% 2014-2016, CWI, Amsterdam
+% License: Open Source under GPLv3
+% Contact: astra@uantwerpen.be
+% Website: http://www.astra-toolbox.com/
+%--------------------------------------------------------------------------
+
+if nargin < 1
+ astra_mex('get_gpu_info');
+else
+ astra_mex('get_gpu_info', index);
+end
diff --git a/matlab/tools/astra_test_CUDA.m b/matlab/tools/astra_test_CUDA.m
new file mode 100644
index 0000000..4171f20
--- /dev/null
+++ b/matlab/tools/astra_test_CUDA.m
@@ -0,0 +1,59 @@
+%--------------------------------------------------------------------------
+% Clears and frees memory of all objects (data, projectors, algorithms)
+% currently in the astra-library.
+%--------------------------------------------------------------------------
+%--------------------------------------------------------------------------
+% This file is part of the ASTRA Toolbox
+%
+% Copyright: 2010-2017, iMinds-Vision Lab, University of Antwerp
+% 2014-2017, CWI, Amsterdam
+% License: Open Source under GPLv3
+% Contact: astra@uantwerpen.be
+% Website: http://www.astra-toolbox.com/
+%--------------------------------------------------------------------------
+
+%%
+fprintf('Getting GPU info...')
+astra_get_gpu_info()
+
+%%
+astra_test_noCUDA()
+
+%%
+fprintf('Testing basic CUDA 2D functionality...')
+
+vg = astra_create_vol_geom(2, 32);
+pg = astra_create_proj_geom('parallel', 1, 32, [0]);
+proj_id = astra_create_projector('cuda', pg, vg);
+
+vol = rand(2, 32);
+[sino_id, sino] = astra_create_sino(vol, proj_id);
+astra_mex_data2d('delete', sino_id);
+astra_mex_projector('delete', proj_id);
+
+err = max(abs(sino - sum(vol)));
+
+if err < 1e-6
+ disp('Ok')
+else
+ disp('Error')
+end
+
+%%
+fprintf('Testing basic CUDA 3D functionality...')
+
+vg = astra_create_vol_geom(2, 32, 32);
+pg = astra_create_proj_geom('parallel3d', 1, 1, 32, 32, [0]);
+
+vol = rand(32, 2, 32);
+[sino_id, sino] = astra_create_sino3d_cuda(vol, pg, vg);
+astra_mex_data3d('delete', sino_id);
+
+err = max(max(abs(sino - sum(vol,2))));
+
+if err < 1e-6
+ disp('Ok')
+else
+ disp('Error')
+end
+
diff --git a/matlab/tools/astra_test_noCUDA.m b/matlab/tools/astra_test_noCUDA.m
new file mode 100644
index 0000000..6437661
--- /dev/null
+++ b/matlab/tools/astra_test_noCUDA.m
@@ -0,0 +1,32 @@
+%--------------------------------------------------------------------------
+% Clears and frees memory of all objects (data, projectors, algorithms)
+% currently in the astra-library.
+%--------------------------------------------------------------------------
+%--------------------------------------------------------------------------
+% This file is part of the ASTRA Toolbox
+%
+% Copyright: 2010-2017, iMinds-Vision Lab, University of Antwerp
+% 2014-2017, CWI, Amsterdam
+% License: Open Source under GPLv3
+% Contact: astra@uantwerpen.be
+% Website: http://www.astra-toolbox.com/
+%--------------------------------------------------------------------------
+
+fprintf('Testing basic CPU 2D functionality...')
+
+vg = astra_create_vol_geom(2, 32);
+pg = astra_create_proj_geom('parallel', 1, 32, [0]);
+proj_id = astra_create_projector('line', pg, vg);
+
+vol = rand(2, 32);
+[sino_id, sino] = astra_create_sino(vol, proj_id);
+astra_mex_data2d('delete', sino_id);
+astra_mex_projector('delete', proj_id);
+
+err = max(abs(sino - sum(vol)));
+
+if err < 1e-6
+ disp('Ok')
+else
+ disp('Error')
+end