-
Notifications
You must be signed in to change notification settings - Fork 6
/
pctfillholl.cxx
49 lines (39 loc) · 1.46 KB
/
pctfillholl.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
#include "pctfillholl_ggo.h"
#include <rtkMacro.h>
#include <rtkGgoFunctions.h>
#include "SmallHoleFiller.h"
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkChangeInformationImageFilter.h>
int main(int argc, char * argv[])
{
GGO(pctfillholl, args_info);
typedef float OutputPixelType;
const unsigned int Dimension = 3;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
// Reader
typedef itk::ImageFileReader< OutputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( args_info.input_arg );
TRY_AND_EXIT_ON_ITK_EXCEPTION( reader->Update() );
SmallHoleFiller< OutputImageType > filler;
filler.SetImage( reader->GetOutput() );
filler.SetHolePixel(0.);
filler.Fill();
typedef itk::ChangeInformationImageFilter< OutputImageType > CIIType;
CIIType::Pointer cii = CIIType::New();
cii->SetInput(filler.GetOutput());
cii->ChangeOriginOn();
cii->ChangeDirectionOn();
cii->ChangeSpacingOn();
cii->SetOutputDirection( reader->GetOutput()->GetDirection() );
cii->SetOutputOrigin( reader->GetOutput()->GetOrigin() );
cii->SetOutputSpacing( reader->GetOutput()->GetSpacing() );
// Write
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( args_info.output_arg );
writer->SetInput( cii->GetOutput() );
TRY_AND_EXIT_ON_ITK_EXCEPTION( writer->Update() );
return EXIT_SUCCESS;
}