From ff543b21e175d49b95ea6da9c03f21a1789f6833 Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Thu, 19 Oct 2017 13:08:13 +0100 Subject: OS loop now fixed --- demos/Demo_Phantom3D_Cone.m | 4 ++-- demos/Demo_Phantom3D_Parallel.m | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'demos') diff --git a/demos/Demo_Phantom3D_Cone.m b/demos/Demo_Phantom3D_Cone.m index 6419386..3a9178b 100644 --- a/demos/Demo_Phantom3D_Cone.m +++ b/demos/Demo_Phantom3D_Cone.m @@ -17,8 +17,8 @@ angles = 0:1.5:360; % angles vector in degrees angles_rad = angles*(pi/180); % conversion to radians det_size = round(sqrt(2)*N); % detector size % in order to run functions you have to go to the directory: -cd /home/algol/Documents/MATLAB/TomoPhantom/functions/ -TomoPhantom = buildPhantom3D(modelNo,N); % generate 3D phantom +pathTP = '/home/algol/Documents/MATLAB/TomoPhantom/functions/models/Phantom3DLibrary.dat'; % path to TomoPhantom parameters file +TomoPhantom = buildPhantom3D(modelNo,N,pathTP); % generate 3D phantom %% % using ASTRA-toolbox to set the projection geometry (cone beam) % eg: astra.create_proj_geom('cone', 1.0 (resol), 1.0 (resol), detectorRowCount, detectorColCount, angles, originToSource, originToDetector) diff --git a/demos/Demo_Phantom3D_Parallel.m b/demos/Demo_Phantom3D_Parallel.m index ac9827c..6a54450 100644 --- a/demos/Demo_Phantom3D_Parallel.m +++ b/demos/Demo_Phantom3D_Parallel.m @@ -10,19 +10,35 @@ addpath('../supp/'); %% % build 3D phantom using TomoPhantom and generate projection data -modelNo = 3; % see Phantom3DLibrary.dat file in TomoPhantom +modelNo = 2; % see Phantom3DLibrary.dat file in TomoPhantom N = 256; % x-y-z size (cubic image) angles = 1:0.5:180; % angles vector in degrees angles_rad = angles*(pi/180); % conversion to radians det_size = round(sqrt(2)*N); % detector size % in order to run functions you have to go to the directory: -cd /home/algol/Documents/MATLAB/TomoPhantom/functions/ -TomoPhantom = buildPhantom3D(modelNo,N); % generate 3D phantom -sino_tomophan3D = buildSino3D(modelNo, N, det_size, single(angles)); % generate data +pathTP = '/home/algol/Documents/MATLAB/TomoPhantom/functions/models/Phantom3DLibrary.dat'; % path to TomoPhantom parameters file +TomoPhantom = buildPhantom3D(modelNo,N,pathTP); % generate 3D phantom +sino_tomophan3D = buildSino3D(modelNo, N, det_size, single(angles),pathTP); % generate ideal data +% Adding noise and distortions if required +sino_artifacts = sino_add_artifacts(sino_tomophan3D,'rings'); +% %% % using ASTRA-toolbox to set the projection geometry (parallel beam) proj_geom = astra_create_proj_geom('parallel', 1, det_size, angles_rad); vol_geom = astra_create_vol_geom(N,N); +%% +fprintf('%s\n', 'Reconstructing with FBP using ASTRA-toolbox ...'); +for i = 1:k +vol_id = astra_mex_data2d('create', '-vol', vol_geom, 0); +proj_id = astra_mex_data2d('create', '-proj3d', proj_geom, sino_artifacts(:,:,k)); +cfg = astra_struct('FBP_CUDA'); +cfg.ProjectionDataId = proj_id; +cfg.ReconstructionDataId = vol_id; +cfg.option.MinConstraint = 0; +alg_id = astra_mex_algorithm('create', cfg); +astra_mex_algorithm('iterate', alg_id, 15); +reconASTRA_3D = astra_mex_data2d('get', vol_id); +end %% fprintf('%s\n', 'Reconstruction using FISTA-LS without regularization...'); clear params -- cgit v1.2.3