|
| 1 | +/*========================================================================= |
| 2 | + * |
| 3 | + * Copyright RTK Consortium |
| 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 | + * http://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 "rtkhilbertonkappalines_ggo.h" |
| 20 | +#include "rtkGgoFunctions.h" |
| 21 | +#include "rtkConfiguration.h" |
| 22 | + |
| 23 | +#include "rtkThreeDHelicalProjectionGeometryXMLFileReader.h" |
| 24 | +#include "rtkHilbertTransformOnKappaLinesImageFilter.h" |
| 25 | +#include "rtkProgressCommands.h" |
| 26 | + |
| 27 | +#include <itkStreamingImageFilter.h> |
| 28 | +#include <itkImageRegionSplitterDirection.h> |
| 29 | +#include <itkImageFileWriter.h> |
| 30 | + |
| 31 | +int |
| 32 | +main(int argc, char * argv[]) |
| 33 | +{ |
| 34 | + GGO(rtkhilbertonkappalines, args_info); |
| 35 | + |
| 36 | + using OutputPixelType = float; |
| 37 | + constexpr unsigned int Dimension = 3; |
| 38 | + |
| 39 | + using CPUOutputImageType = itk::Image<OutputPixelType, Dimension>; |
| 40 | +#ifdef RTK_USE_CUDA |
| 41 | + using OutputImageType = itk::CudaImage<OutputPixelType, Dimension>; |
| 42 | +#else |
| 43 | + using OutputImageType = CPUOutputImageType; |
| 44 | +#endif |
| 45 | + |
| 46 | + // Projections reader |
| 47 | + using ReaderType = rtk::ProjectionsReader<OutputImageType>; |
| 48 | + ReaderType::Pointer reader = ReaderType::New(); |
| 49 | + rtk::SetProjectionsReaderFromGgo<ReaderType, args_info_rtkhilbertonkappalines>(reader, args_info); |
| 50 | + |
| 51 | + if (args_info.verbose_flag) |
| 52 | + std::cout << "Reading... " << std::endl; |
| 53 | + TRY_AND_EXIT_ON_ITK_EXCEPTION(reader->Update()) |
| 54 | + |
| 55 | + // Geometry |
| 56 | + if (args_info.verbose_flag) |
| 57 | + std::cout << "Reading geometry information from " << args_info.geometry_arg << "..." << std::endl; |
| 58 | + rtk::ThreeDHelicalProjectionGeometryXMLFileReader::Pointer geometryReader; |
| 59 | + geometryReader = rtk::ThreeDHelicalProjectionGeometryXMLFileReader::New(); |
| 60 | + geometryReader->SetFilename(args_info.geometry_arg); |
| 61 | + TRY_AND_EXIT_ON_ITK_EXCEPTION(geometryReader->GenerateOutputInformation()) |
| 62 | + rtk::ThreeDHelicalProjectionGeometry::Pointer geometry; |
| 63 | + geometry = geometryReader->GetOutputObject(); |
| 64 | + geometry->VerifyHelixParameters(); |
| 65 | + |
| 66 | + // Check on hardware parameter |
| 67 | +#ifndef RTK_USE_CUDA |
| 68 | + if (!strcmp(args_info.hardware_arg, "cuda")) |
| 69 | + { |
| 70 | + std::cerr << "The program has not been compiled with cuda option" << std::endl; |
| 71 | + return EXIT_FAILURE; |
| 72 | + } |
| 73 | +#endif |
| 74 | + |
| 75 | + using HilbertTransformOnKappaLinesType = |
| 76 | + rtk::HilbertTransformOnKappaLinesImageFilter<OutputImageType, OutputImageType>; |
| 77 | + HilbertTransformOnKappaLinesType::Pointer fwd = HilbertTransformOnKappaLinesType::New(); |
| 78 | + fwd->SetGeometry(geometry); |
| 79 | + fwd->SetInput(reader->GetOutput()); |
| 80 | + |
| 81 | + // Write |
| 82 | + using WriterType = itk::ImageFileWriter<CPUOutputImageType>; |
| 83 | + WriterType::Pointer writer = WriterType::New(); |
| 84 | + writer->SetFileName(args_info.output_arg); |
| 85 | + writer->SetInput(fwd->GetOutput()); |
| 86 | + |
| 87 | + if (args_info.verbose_flag) |
| 88 | + std::cout << "Reconstructing and writing... " << std::endl; |
| 89 | + |
| 90 | + TRY_AND_EXIT_ON_ITK_EXCEPTION(writer->Update()) |
| 91 | + |
| 92 | + return EXIT_SUCCESS; |
| 93 | +} |
0 commit comments