1 #include "clitkCommon.h"
2 #include "clitkPadImage_ggo.h"
3 #include "clitkPadImageGenericFilter.h"
5 // template <class ImageType, class PadBoundType, unsigned int dim>
6 // int pad_like(typename ImageType::Pointer input, const std::string& likeFile, PadBoundType* padLower, PadBoundType* padUpper)
8 // typedef typename ImageType::SpacingType SpacingType;
9 // typedef typename ImageType::RegionType RegionType;
10 // typedef typename ImageType::SizeType SizeType;
11 // typedef typename ImageType::IndexType IndexType;
12 // typedef typename ImageType::PointType PointType;
13 // typedef typename ImageType::PointValueType PointValueType;
15 // typedef itk::ImageFileReader<ImageType> ImageReaderType;
16 // typename ImageReaderType::Pointer reader = ImageReaderType::New();
17 // reader->SetFileName(likeFile);
20 // typename ImageType::Pointer like_image = reader->GetOutput();
22 // SpacingType spacing = input->GetSpacing(), like_spacing = like_image->GetSpacing();
23 // if (spacing != like_spacing) {
24 // std::cerr << "Like-image must have same spacing as input: " << spacing << " " << like_spacing << std::endl;
25 // return ERR_NOT_SAME_SPACING;
28 // SizeType size = input->GetLargestPossibleRegion().GetSize(), like_size = like_image->GetLargestPossibleRegion().GetSize();
29 // PointType origin = input->GetOrigin(), like_origin = like_image->GetOrigin();
31 // PointType lower_bound, like_lower_bound;
32 // PointType upper_bound, like_upper_bound;
33 // PointValueType auxl = 0, auxu = 0;
34 // for (unsigned int i = 0; i < dim; i++) {
35 // lower_bound[i] = origin[i];
36 // like_lower_bound[i] = like_origin[i];
37 // auxl = itk::Math::Round<PointValueType>(((lower_bound[i] - like_lower_bound[i])/spacing[i]));
39 // upper_bound[i] = (lower_bound[i] + size[i]*spacing[i]);
40 // like_upper_bound[i] = (like_lower_bound[i] + like_size[i]*spacing[i]);
41 // auxu = itk::Math::Round<PointValueType>(((like_upper_bound[i] - upper_bound[i])/spacing[i]));
43 // if (auxl < 0 || auxu < 0) {
44 // std::cerr << "Like-image's bounding box must be larger than input's" << std::endl;
45 // return ERR_NOT_LIKE_LARGER;
48 // padLower[i] = (PadBoundType)auxl;
49 // padUpper[i] = (PadBoundType)auxu;
52 // return ERR_SUCCESS;
55 int main(int argc, char** argv)
57 /* const DimType dim = 3;
58 typedef short PixelType;
59 typedef itk::Image<PixelType, dim> ImageType;
60 typedef itk::ImageFileReader<ImageType> ImageReaderType;
61 typedef itk::ImageFileWriter<ImageType> ImageWriterType;
62 typedef itk::ConstantPadImageFilter<ImageType, ImageType> PadFilterType;
63 typedef PadFilterType::SizeValueType PadBoundType;*/
65 GGO(clitkPadImage, args_info);
68 typedef clitk::PadImageGenericFilter FilterType;
69 FilterType::Pointer filter = FilterType::New();
71 filter->SetArgsInfo(args_info);
75 } catch(std::runtime_error e) {
76 std::cout << e.what() << std::endl;
79 // ImageReaderType::Pointer reader = ImageReaderType::New();
80 // reader->SetFileName(args_info.input_arg);
83 // PadBoundType pad_lower[dim], pad_upper[dim];
84 // ImageType::Pointer input = reader->GetOutput();
85 // if (args_info.like_given) {
86 // int err = pad_like<ImageType, PadBoundType, dim>(input, args_info.like_arg, pad_lower, pad_upper);
88 // std::cerr << "Error processing like image." << std::endl;
93 // for (DimType i = 0; i < dim; i++) {
94 // pad_lower[i] = args_info.lower_arg[i];
95 // pad_upper[i] = args_info.upper_arg[i];
99 // PadFilterType::Pointer filter = PadFilterType::New();
100 // filter->SetPadLowerBound(pad_lower);
101 // filter->SetPadUpperBound(pad_upper);
102 // filter->SetInput(input);
103 // filter->SetConstant(args_info.value_arg);
106 // ImageType::Pointer output = filter->GetOutput();
107 // ImageWriterType::Pointer writer = ImageWriterType::New();
108 // writer->SetInput(output);
109 // writer->SetFileName(args_info.output_arg);