Debian Codegraph @

Modules/IO/DCMTK/test/itkDCMTKRGBImageIOTest.cxx

raw symbols SCIP
1 /*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19 #include "itkImageFileReader.h"
20 #include "itkImageFileWriter.h"
21 #include "itkDCMTKImageIO.h"
22 #include "itkRescaleIntensityImageFilter.h"
23 #include "itkRGBPixel.h"
24 #include "itkTestingMacros.h"
25
26 #include <fstream>
27
28 // Specific ImageIO test
29
30 int
31 itkDCMTKRGBImageIOTest(int argc, char * argv[])
32 {
33
34 if (argc < 3)
35 {
36 std::cerr << "Missing Parameters" << std::endl;
37 std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " DicomImage OutputImage" << std::endl;
38 return EXIT_FAILURE;
39 }
40
41 using PixelType = itk::RGBPixel<unsigned char>;
42 using InputImageType = itk::Image<PixelType, 2>;
43 using ReaderType = itk::ImageFileReader<InputImageType>;
44
45 using ImageIOType = itk::DCMTKImageIO;
46 auto dcmtkImageIO = ImageIOType::New();
47
48 auto reader = ReaderType::New();
49 reader->SetFileName(argv[1]);
50 reader->SetImageIO(dcmtkImageIO);
51
52 ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());
53
54
55 using WriteImageType = itk::Image<PixelType, 2>;
56 using Writer2Type = itk::ImageFileWriter<WriteImageType>;
57 auto writer2 = Writer2Type::New();
58 writer2->SetFileName(argv[2]);
59 writer2->SetInput(reader->GetOutput());
60
61 ITK_TRY_EXPECT_NO_EXCEPTION(writer2->Update());
62
63
64 dcmtkImageIO->Print(std::cout);
65
66
67 std::cout << "Test finished" << std::endl;
68 return EXIT_SUCCESS;
69 }