-
Notifications
You must be signed in to change notification settings - Fork 6
/
pctparkershortscanweighting.cxx
66 lines (54 loc) · 2.29 KB
/
pctparkershortscanweighting.cxx
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
#include "pctparkershortscanweighting_ggo.h"
#include "rtkGgoFunctions.h"
#include <rtkThreeDCircularProjectionGeometryXMLFile.h>
#include <rtkProjectionsReader.h>
#include "pctDDParkerShortScanImageFilter.h"
#include <itkImageFileWriter.h>
#include <itkRegularExpressionSeriesFileNames.h>
int main(int argc, char * argv[])
{
GGO(pctparkershortscanweighting, args_info);
typedef float OutputPixelType;
const unsigned int Dimension = 4;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
// Generate file names
itk::RegularExpressionSeriesFileNames::Pointer names = itk::RegularExpressionSeriesFileNames::New();
names->SetDirectory(args_info.path_arg);
names->SetNumericSort(false);
names->SetRegularExpression(args_info.regexp_arg);
names->SetSubMatch(0);
if(args_info.verbose_flag)
std::cout << "Regular expression matches "
<< names->GetFileNames().size()
<< " file(s)..."
<< std::endl;
// Projections reader
typedef rtk::ProjectionsReader< OutputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileNames( names->GetFileNames() );
TRY_AND_EXIT_ON_ITK_EXCEPTION( reader->GenerateOutputInformation() )
// Geometry
if(args_info.verbose_flag)
std::cout << "Reading geometry information from "
<< args_info.geometry_arg
<< "..."
<< std::endl;
rtk::ThreeDCircularProjectionGeometryXMLFileReader::Pointer geometryReader;
geometryReader = rtk::ThreeDCircularProjectionGeometryXMLFileReader::New();
geometryReader->SetFilename(args_info.geometry_arg);
TRY_AND_EXIT_ON_ITK_EXCEPTION( geometryReader->GenerateOutputInformation() )
// Short scan image filter
typedef pct::DDParkerShortScanImageFilter< OutputImageType > PSSFType;
PSSFType::Pointer pssf = PSSFType::New();
pssf->SetInput( reader->GetOutput() );
pssf->SetGeometry( geometryReader->GetOutputObject() );
pssf->InPlaceOff();
// Write
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( args_info.output_arg );
writer->SetInput( pssf->GetOutput() );
writer->SetNumberOfStreamDivisions( args_info.divisions_arg );
TRY_AND_EXIT_ON_ITK_EXCEPTION( writer->Update() )
return EXIT_SUCCESS;
}