-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImageCopy.cxx
executable file
·66 lines (49 loc) · 1.42 KB
/
ImageCopy.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
#include "itkWin32Header.h"
#include <iostream>
#include <fstream>
#include "itkNumericTraits.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
int main(int argc, char **argv)
{
if( argc < 2 )
{
std::cerr << "You must supply a filename to be copied" << std::endl;
return 1;
}
const unsigned int Dimension = 2;
typedef itk::Image< unsigned char, Dimension > ImageType;
typedef itk::Image< unsigned char, Dimension > OutputType;
typedef itk::Image< unsigned char, Dimension > DiffOutputType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< OutputType > WriterType;
// Read the baseline file
ReaderType::Pointer baselineReader = ReaderType::New();
baselineReader->SetFileName(argv[1]);
try
{
baselineReader->UpdateLargestPossibleRegion();
}
catch (itk::ExceptionObject& e)
{
std::cerr << "Exception detected while reading " << argv[1];
std::cerr << " : " << e.GetDescription();
return 1;
}
WriterType::Pointer writer = WriterType::New();
writer->SetInput(baselineReader->GetOutput());
::itk::OStringStream baseName;
baseName << argv[1] << ".base.png";
try
{
writer->SetFileName( baseName.str().c_str() );
writer->Update();
}
catch (...)
{
std::cerr << "Error during write of " << baseName.str() << std::endl;
return 1;
}
return 0;
}