-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
112 lines (89 loc) · 3.71 KB
/
main.cpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
#include <boost/program_options.hpp>
#include <itkImage.h>
#include <itkImportImageFilter.h>
#include <itkImageFileWriter.h>
#include "ImageDumpDeserializer.h"
#include "ImageDumpSerializer.h"
#include "ItkImageFilter.h"
#include "Filters/FilterDecision.h"
#include "DicomImport.h"
int main(int argc, char * argv[])
{
// Declare the supported options.
boost::program_options::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("input", boost::program_options::value<std::string>(), "input filename")
("output", boost::program_options::value<std::string>(), "output filename")
("secondary", boost::program_options::value<std::string>(), "secondary dataset filename (used for storing and loading eigenvalues)")
("loadDicom", boost::program_options::value<std::string>(), "load DICOM series and store it in a file; no filters applied")
;
boost::program_options::variables_map vm;
boost::program_options::positional_options_description p;
p.add("input", 1);
p.add("output", 1);
p.add("secondary", 1);
p.add("loadDicom", 1);
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
boost::program_options::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
std::string secondaryFilename = vm.count("secondary") ? vm["secondary"].as<std::string>() : std::string("secondary.dump");
if (vm.count("input") && vm.count("output"))
{
if ((vm.count("loadDicom") == 0))
{
typedef unsigned short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image<PixelType, Dimension> ImageType;
typedef itk::ImportImageFilter< PixelType, Dimension > ImportFilterType;
ImageDumpDeserializer<PixelType, Dimension> *deserializer = new ImageDumpDeserializer<PixelType, Dimension>(vm["input"].as<std::string>());
ImageType::Pointer image = deserializer->DeserializeImage();
ImageDumpSerializer<PixelType, Dimension> *serializer = new ImageDumpSerializer<PixelType, Dimension>(vm["output"].as<std::string>());
serializer->SetMinimums(deserializer->GetMinimums());
serializer->SetMaximums(deserializer->GetMaximums());
serializer->SetElementExtents(deserializer->GetElementExtents());
serializer->SetDatasetType(deserializer->GetDatasetType());
serializer->SetElementTypeID(deserializer->GetElementTypeID());
ItkImageFilter<PixelType, Dimension>* filter = nullptr;
std::string read;
do
{
std::cout << "enter filter name or type \"exit\"" << std::endl;
std::getline(std::cin, read);
if (read != "exit")
{
filter = FilterDecision<PixelType, Dimension>::GetFilter(read, image, serializer, secondaryFilename);
if (filter != nullptr)
{
std::cout << "using " << filter->GetFilterName() << " filter" << std::endl;
image = filter->GetFilterImage();
}
else
{
std::cout << "given wrong filter name; possible values are:" << std::endl;
FilterDecision<PixelType, Dimension>::PrintFilterNames();
}
}
//serializer->WriteImageAsSlices(image);
} while (read != "exit");
delete filter;
serializer->SerializeImage(image);
delete deserializer;
delete serializer;
}
else
{
DicomImport<> importer(vm["input"].as<std::string>(), vm["output"].as<std::string>());
importer.Convert();
}
return EXIT_SUCCESS;
}
else
{
return EXIT_FAILURE;
}
}