|
6 | 6 |
|
7 | 7 |
|
8 | 8 | int |
9 | | -main( int argc, char* argv[] ) |
| 9 | +main(int argc, char * argv[]) |
10 | 10 | { |
11 | | - if ( argc < 3 ) |
12 | | - { |
13 | | - std::cout << "Syntax: " << argv[0] << " sliceImage interpolatedImage [smoothingRadius=2]" << std::endl; |
14 | | - return EXIT_FAILURE; |
15 | | - } |
| 11 | + if (argc < 3) |
| 12 | + { |
| 13 | + std::cout << "Syntax: " << argv[0] << " sliceImage interpolatedImage [smoothingRadius=2]" << std::endl; |
| 14 | + return EXIT_FAILURE; |
| 15 | + } |
16 | 16 |
|
17 | 17 | try |
18 | | - { |
19 | | - using ImageType = itk::Image< unsigned char, 3 >; |
20 | | - using ReaderType = itk::ImageFileReader< ImageType >; |
21 | | - ReaderType::Pointer imageReader = ReaderType::New(); |
22 | | - imageReader->SetFileName( argv[1] ); |
23 | | - |
24 | | - using mciType = itk::MorphologicalContourInterpolator< ImageType >; |
25 | | - mciType::Pointer mci = mciType::New(); |
26 | | - mci->SetInput( imageReader->GetOutput() ); |
27 | | - mci->Update(); |
| 18 | + { |
| 19 | + using ImageType = itk::Image<unsigned char, 3>; |
| 20 | + using ReaderType = itk::ImageFileReader<ImageType>; |
| 21 | + ReaderType::Pointer imageReader = ReaderType::New(); |
| 22 | + imageReader->SetFileName(argv[1]); |
28 | 23 |
|
29 | | - int smoothingRadius = 2; |
30 | | - if ( argc >= 4 ) |
31 | | - { |
32 | | - smoothingRadius = std::stoi( argv[3] ); |
33 | | - } |
| 24 | + using mciType = itk::MorphologicalContourInterpolator<ImageType>; |
| 25 | + mciType::Pointer mci = mciType::New(); |
| 26 | + mci->SetInput(imageReader->GetOutput()); |
| 27 | + mci->Update(); |
34 | 28 |
|
35 | | - using MedianType = itk::MedianImageFilter< ImageType, ImageType >; |
36 | | - MedianType::Pointer medF = MedianType::New(); |
37 | | - medF->SetInput( mci->GetOutput() ); |
38 | | - medF->SetRadius( smoothingRadius ); |
39 | | - medF->Update(); |
40 | | - |
41 | | - using WriterType = itk::ImageFileWriter< ImageType >; |
42 | | - WriterType::Pointer writer = WriterType::New(); |
43 | | - writer->SetFileName( argv[2] ); |
44 | | - writer->SetInput( medF->GetOutput() ); |
45 | | - writer->SetUseCompression( true ); |
46 | | - writer->Update(); |
47 | | - } |
48 | | - catch ( itk::ExceptionObject& exc ) |
| 29 | + int smoothingRadius = 2; |
| 30 | + if (argc >= 4) |
49 | 31 | { |
50 | | - std::cerr << exc << std::endl; |
51 | | - return EXIT_FAILURE; |
| 32 | + smoothingRadius = std::stoi(argv[3]); |
52 | 33 | } |
| 34 | + |
| 35 | + using MedianType = itk::MedianImageFilter<ImageType, ImageType>; |
| 36 | + MedianType::Pointer medF = MedianType::New(); |
| 37 | + medF->SetInput(mci->GetOutput()); |
| 38 | + medF->SetRadius(smoothingRadius); |
| 39 | + medF->Update(); |
| 40 | + |
| 41 | + using WriterType = itk::ImageFileWriter<ImageType>; |
| 42 | + WriterType::Pointer writer = WriterType::New(); |
| 43 | + writer->SetFileName(argv[2]); |
| 44 | + writer->SetInput(medF->GetOutput()); |
| 45 | + writer->SetUseCompression(true); |
| 46 | + writer->Update(); |
| 47 | + } |
| 48 | + catch (itk::ExceptionObject & exc) |
| 49 | + { |
| 50 | + std::cerr << exc << std::endl; |
| 51 | + return EXIT_FAILURE; |
| 52 | + } |
53 | 53 | return EXIT_SUCCESS; |
54 | 54 | } |
0 commit comments