diff options
Diffstat (limited to 'matlab')
-rw-r--r-- | matlab/mex/astra_mex_data2d_c.cpp | 5 | ||||
-rw-r--r-- | matlab/tools/astra_create_proj_geom.m | 13 | ||||
-rw-r--r-- | matlab/tools/astra_geom_2vec.m | 26 |
3 files changed, 42 insertions, 2 deletions
diff --git a/matlab/mex/astra_mex_data2d_c.cpp b/matlab/mex/astra_mex_data2d_c.cpp index 5f79e98..62c5d80 100644 --- a/matlab/mex/astra_mex_data2d_c.cpp +++ b/matlab/mex/astra_mex_data2d_c.cpp @@ -44,6 +44,7 @@ $Id$ #include "astra/SparseMatrixProjectionGeometry2D.h" #include "astra/FanFlatProjectionGeometry2D.h" #include "astra/FanFlatVecProjectionGeometry2D.h" +#include "astra/ParallelVecProjectionGeometry2D.h" using namespace std; using namespace astra; @@ -159,6 +160,8 @@ void astra_mex_data2d_create(int& nlhs, mxArray* plhs[], int& nrhs, const mxArra pGeometry = new CFanFlatProjectionGeometry2D(); } else if (type == "fanflat_vec") { pGeometry = new CFanFlatVecProjectionGeometry2D(); + } else if (type == "parallel_vec") { + pGeometry = new CParallelVecProjectionGeometry2D(); } else { pGeometry = new CParallelProjectionGeometry2D(); } @@ -448,6 +451,8 @@ void astra_mex_data2d_change_geometry(int nlhs, mxArray* plhs[], int nrhs, const pGeometry = new CFanFlatProjectionGeometry2D(); } else if (type == "fanflat_vec") { pGeometry = new CFanFlatVecProjectionGeometry2D(); + } else if (type == "parallel_vec") { + pGeometry = new CParallelVecProjectionGeometry2D(); } else { pGeometry = new CParallelProjectionGeometry2D(); } diff --git a/matlab/tools/astra_create_proj_geom.m b/matlab/tools/astra_create_proj_geom.m index 862e410..ff7d74d 100644 --- a/matlab/tools/astra_create_proj_geom.m +++ b/matlab/tools/astra_create_proj_geom.m @@ -107,6 +107,19 @@ if strcmp(type,'parallel') 'ProjectionAngles', varargin{3} ... ); +elseif strcmp(type,'parallel_vec') + if numel(varargin) < 2 + error('not enough variables: astra_create_proj_geom(parallel_vec, det_count, V') + end + if size(varargin{2}, 2) ~= 6 + error('V should be a Nx6 matrix, with N the number of projections') + end + proj_geom = struct( ... + 'type', 'parallel_vec', ... + 'DetectorCount', varargin{1}, ... + 'Vectors', varargin{2} ... + ); + elseif strcmp(type,'fanflat') if numel(varargin) < 5 error('not enough variables: astra_create_proj_geom(fanflat, det_width, det_count, angles, source_origin, source_det)'); diff --git a/matlab/tools/astra_geom_2vec.m b/matlab/tools/astra_geom_2vec.m index 0abd07c..c6dda0d 100644 --- a/matlab/tools/astra_geom_2vec.m +++ b/matlab/tools/astra_geom_2vec.m @@ -1,7 +1,29 @@ function proj_geom_out = astra_geom_2vec(proj_geom) + % PARALLEL 2D + if strcmp(proj_geom.type,'parallel') + + vectors = zeros(numel(proj_geom.ProjectionAngles), 6); + for i = 1:numel(proj_geom.ProjectionAngles) + + % ray direction + vectors(i,1) = sin(proj_geom.ProjectionAngles(i)); + vectors(i,2) = -cos(proj_geom.ProjectionAngles(i)); + + % center of detector + vectors(i,3) = 0; + vectors(i,4) = 0; + + % vector from detector pixel 0 to 1 + vectors(i,5) = cos(proj_geom.ProjectionAngles(i)) * proj_geom.DetectorWidth; + vectors(i,6) = sin(proj_geom.ProjectionAngles(i)) * proj_geom.DetectorWidth; + + end + + proj_geom_out = astra_create_proj_geom('parallel_vec', proj_geom.DetectorCount, vectors); + % FANFLAT - if strcmp(proj_geom.type,'fanflat') + elseif strcmp(proj_geom.type,'fanflat') vectors = zeros(numel(proj_geom.ProjectionAngles), 6); for i = 1:numel(proj_geom.ProjectionAngles) @@ -50,7 +72,7 @@ function proj_geom_out = astra_geom_2vec(proj_geom) proj_geom_out = astra_create_proj_geom('cone_vec', proj_geom.DetectorRowCount, proj_geom.DetectorColCount, vectors); - % PARALLEL + % PARALLEL 3D elseif strcmp(proj_geom.type,'parallel3d') vectors = zeros(numel(proj_geom.ProjectionAngles), 12); |