summaryrefslogtreecommitdiffstats
path: root/matlab/algorithms/DART/examples/example1.m
blob: 01aa17b337775e8e51fd165712f4565cb6e0cb92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%--------------------------------------------------------------------------
% This file is part of the ASTRA Toolbox
%
% Copyright: 2010-2021, imec Vision Lab, University of Antwerp
%            2014-2021, CWI, Amsterdam
% License: Open Source under GPLv3
% Contact: astra@astra-toolbox.com
% Website: http://www.astra-toolbox.com/
%--------------------------------------------------------------------------

addpath('../');

%% Example 1: 2D parallel beam, cuda

% configuration
proj_count		= 20;
dart_iterations = 20;
filename		= 'cylinders.png';
outdir			= './';
prefix			= 'example1';
rho				= [0, 255];
tau				= 128;
gpu_core		= 0;

% load phantom
I = imreadgs(filename);

% create projection and volume geometries
det_count = size(I, 1);
angles = linspace2(0, pi, proj_count);
proj_geom = astra_create_proj_geom('parallel', 1, det_count, angles);
vol_geom = astra_create_vol_geom(det_count, det_count);

% create sinogram
[sinogram_id, sinogram] = astra_create_sino_cuda(I, proj_geom, vol_geom);
astra_mex_data2d('delete', sinogram_id);

	% DART
	D						= DARTalgorithm(sinogram, proj_geom);
	D.t0					= 100;
	D.t						= 10;

	D.tomography.method		= 'SIRT';
	D.tomography.gpu_core	= gpu_core;
	D.tomography.use_minc	= 'yes';
	D.tomography.gpu        = 'no';

	D.segmentation          = SegmentationPDM();
	D.segmentation.rho		= rho*1.8;
	D.segmentation.tau		= tau*1.5;
	D.segmentation.interval = 5;

	D.smoothing.b			= 0.1;
	D.smoothing.gpu_core	= gpu_core;
	D.smoothing.gpu        = 'no';
	
	D.masking.random		= 0.1;
	D.masking.gpu_core		= gpu_core;
	D.masking.gpu        = 'no';
	
	D.output.directory		= outdir;
	D.output.pre			= [prefix '_'];
	D.output.save_images	= 'no';
	D.output.save_results	= {'stats', 'settings', 'S', 'V'};
	D.output.save_interval	= dart_iterations;
	D.output.verbose		= 'yes';

	D.statistics.proj_diff	= 'no';

	D.initialize();

	D.iterate(dart_iterations);

% save the reconstruction and the segmentation to file
imwritesc(D.S, [outdir '/' prefix '_S.png']);
imwritesc(D.V, [outdir '/' prefix '_V.png']);