Debian Codegraph @

Modules/Bridge/VtkGlue/test/itkImageToVTKImageFilterRGBTest.cxx

raw
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 "itkImageToVTKImageFilter.h"
20
21 #include "itkImageFileReader.h"
22 #include "itkRGBPixel.h"
23 #include "itkTestingMacros.h"
24
25 int
26 itkImageToVTKImageFilterRGBTest(int argc, char * argv[])
27 {
28 if (argc != 2)
29 {
30 std::cerr << "Missing parameters." << std::endl;
31 std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv);
32 std::cerr << " InputFileName" << std::endl;
33 return EXIT_FAILURE;
34 }
35 const char * inputFileName = argv[1];
36
37 constexpr unsigned int Dimension = 2;
38 using PixelComponentType = unsigned char;
39 using PixelType = itk::RGBPixel<PixelComponentType>;
40 using ImageType = itk::Image<PixelType, Dimension>;
41
42 using ReaderType = itk::ImageFileReader<ImageType>;
43 auto reader = ReaderType::New();
44 reader->SetFileName(inputFileName);
45
46 using ConnectorType = itk::ImageToVTKImageFilter<ImageType>;
47 auto connector = ConnectorType::New();
48 connector->SetInput(reader->GetOutput());
49
50 connector->UpdateLargestPossibleRegion();
51
52 connector->GetOutput()->Print(std::cout);
53 connector->GetImporter()->Print(std::cout);
54 connector->GetExporter()->Print(std::cout);
55
56 connector->Print(std::cout);
57
58 connector->Update();
59
60
61 std::cout << "Test finished." << std::endl;
62 return EXIT_SUCCESS;
63 }