diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..399e250 --- /dev/null +++ b/.clang-format @@ -0,0 +1,151 @@ +## This config file is only relevant for clang-format version 8.0.0 +## +## Examples of each format style can be found on the in the clang-format documentation +## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option +## +## The clang-format binaries can be downloaded as part of the clang binary distributions +## from http://releases.llvm.org/download.html +## +## Use the script Utilities/Maintenance/clang-format.bash to faciliate +## maintaining a consistent code style. +## +## EXAMPLE apply code style enforcement before commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified +## EXAMPLE apply code style enforcement after commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last +--- +# This configuration requires clang-format version 8.0.0 exactly. +BasedOnStyle: Mozilla +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: true +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +# clang 9.0 AllowAllArgumentsOnNextLine: true +# clang 9.0 AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +# clang 9.0 AllowShortLambdasOnASingleLine: All +# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: All +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BraceWrapping: + # clang 9.0 feature AfterCaseLabel: false + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true +## This is the big change from historical ITK formatting! +# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style +# with indented braces, and not indented code. This style is very difficult to automatically +# maintain with code beautification tools. Not indenting braces is more common among +# formatting tools. + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +#clang 6.0 BreakBeforeInheritanceComma: true +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +#clang 6.0 BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +## The following line allows larger lines in non-documentation code +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +IndentPPDirectives: AfterHash +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +## The following line allows larger lines in non-documentation code +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Middle +ReflowComments: true +# We may want to sort the includes as a separate pass +SortIncludes: false +# We may want to revisit this later +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +# SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 2 +UseTab: Never +... diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c598f42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# Custom attribute to mark sources as using our C++/C code style. +[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat + +*.c our-c-style +*.h our-c-style +*.cxx our-c-style +*.hxx our-c-style +*.txx our-c-style +*.txt whitespace=tab-in-indent,no-lf-at-eof +*.cmake whitespace=tab-in-indent,no-lf-at-eof + +# ExternalData content links must have LF newlines +*.md5 crlf=input +*.sha512 crlf=input diff --git a/examples/runProxTVImageFilter.cxx b/examples/runProxTVImageFilter.cxx index 9bfc8fa..c3468f2 100644 --- a/examples/runProxTVImageFilter.cxx +++ b/examples/runProxTVImageFilter.cxx @@ -22,27 +22,28 @@ #include "itkImageFileWriter.h" #include "itkImageIOBase.h" -template -int run( const std::string & inputImageFileName, - const std::string & outputImageFileName, - const double weight, - const unsigned int maxIterations) +template +int +run(const std::string & inputImageFileName, + const std::string & outputImageFileName, + const double weight, + const unsigned int maxIterations) { - using TVImageType = itk::Image< double, ImageType::ImageDimension >; - using ReaderType = itk::ImageFileReader< TVImageType >; + using TVImageType = itk::Image; + using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); reader->SetFileName(inputImageFileName); - using FilterType = itk::ProxTVImageFilter< TVImageType, TVImageType >; + using FilterType = itk::ProxTVImageFilter; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput(reader->GetOutput()); filter->SetWeights(weight); filter->SetMaximumNumberOfIterations(maxIterations); filter->Update(); - using CastFilterType = itk::CastImageFilter< TVImageType, ImageType >; + using CastFilterType = itk::CastImageFilter; typename CastFilterType::Pointer castFilter = CastFilterType::New(); - castFilter->SetInput( filter->GetOutput() ); + castFilter->SetInput(filter->GetOutput()); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); @@ -53,39 +54,39 @@ int run( const std::string & inputImageFileName, return EXIT_SUCCESS; } -template -int runWithDimension( const std::string & inputImageFileName, - const std::string & outputImageFileName, - const double weight, - const unsigned int maxIterations, - const unsigned int dimension ) +template +int +runWithDimension(const std::string & inputImageFileName, + const std::string & outputImageFileName, + const double weight, + const unsigned int maxIterations, + const unsigned int dimension) { using PixelType = TPixel; - switch( dimension ) + switch (dimension) + { + case 2: { - case 2: - { using ImageType = itk::Image; - return run(inputImageFileName, outputImageFileName, - weight, maxIterations); - } - case 3: - { + return run(inputImageFileName, outputImageFileName, weight, maxIterations); + } + case 3: + { using ImageType = itk::Image; - return run(inputImageFileName, outputImageFileName, - weight, maxIterations); - } - default: - std::cerr << "Unsupported dimension: " << dimension << std::endl; - return EXIT_FAILURE; + return run(inputImageFileName, outputImageFileName, weight, maxIterations); } + default: + std::cerr << "Unsupported dimension: " << dimension << std::endl; + return EXIT_FAILURE; + } return EXIT_FAILURE; } -int main(int argc, char *argv[]) +int +main(int argc, char * argv[]) { - if( argc < 3 ) - { + if (argc < 3) + { std::cerr << "Usage: " << argv[0]; std::cerr << " inputImage"; std::cerr << " outputImage"; @@ -93,27 +94,25 @@ int main(int argc, char *argv[]) std::cerr << " [maxIterations]"; std::cerr << std::endl; return EXIT_FAILURE; - } + } - const std::string inputImageFileName = argv[1]; - const std::string outputImageFileName = argv[2]; - double weight = 1.0; - if( argc > 3 ) - { + const std::string inputImageFileName = argv[1]; + const std::string outputImageFileName = argv[2]; + double weight = 1.0; + if (argc > 3) + { weight = std::atof(argv[3]); - } + } unsigned int maxIterations = 10; - if( argc > 4 ) - { + if (argc > 4) + { maxIterations = std::atoi(argv[4]); - } + } itk::ImageIOBase::Pointer imageIO = - itk::ImageIOFactory::CreateImageIO( - inputImageFileName.c_str(), - itk::ImageIOFactory::ReadMode ); + itk::ImageIOFactory::CreateImageIO(inputImageFileName.c_str(), itk::ImageIOFactory::ReadMode); - imageIO->SetFileName( inputImageFileName ); + imageIO->SetFileName(inputImageFileName); imageIO->ReadImageInformation(); using IOComponentType = itk::ImageIOBase::IOComponentType; @@ -121,83 +120,82 @@ int main(int argc, char *argv[]) const unsigned int imageDimension = imageIO->GetNumberOfDimensions(); - switch( componentType ) - { + switch (componentType) + { case itk::ImageIOBase::UCHAR: - { + { using PixelType = unsigned char; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::CHAR: - { + { using PixelType = signed char; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::USHORT: - { + { using PixelType = unsigned short; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::SHORT: - { + { using PixelType = short; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::UINT: - { + { using PixelType = unsigned int; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::INT: - { + { using PixelType = int; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::ULONG: - { + { using PixelType = unsigned long; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::LONG: - { + { using PixelType = long; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::FLOAT: - { + { using PixelType = float; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } case itk::ImageIOBase::DOUBLE: - { + { using PixelType = double; - return runWithDimension(inputImageFileName, outputImageFileName, - weight, maxIterations, imageDimension); - } + return runWithDimension( + inputImageFileName, outputImageFileName, weight, maxIterations, imageDimension); + } default: case itk::ImageIOBase::UNKNOWNCOMPONENTTYPE: std::cerr << "Unknown and unsupported component type!" << std::endl; return EXIT_FAILURE; - - } + } return EXIT_FAILURE; } diff --git a/include/itkProxTVImageFilter.h b/include/itkProxTVImageFilter.h index 5bbda1a..f060786 100644 --- a/include/itkProxTVImageFilter.h +++ b/include/itkProxTVImageFilter.h @@ -34,8 +34,8 @@ namespace itk * \ingroup TotalVariation * */ -template< typename TInputImage, typename TOutputImage > -class ProxTVImageFilter: public ImageToImageFilter< TInputImage, TOutputImage > +template +class ProxTVImageFilter : public ImageToImageFilter { public: ITK_DISALLOW_COPY_AND_ASSIGN(ProxTVImageFilter); @@ -50,16 +50,16 @@ class ProxTVImageFilter: public ImageToImageFilter< TInputImage, TOutputImage > using ArrayType = itk::FixedArray; /** Standard class typedefs. */ - using Self = ProxTVImageFilter< InputImageType, OutputImageType >; - using Superclass = ImageToImageFilter< InputImageType, OutputImageType >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Self = ProxTVImageFilter; + using Superclass = ImageToImageFilter; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; /** Run-time type information. */ - itkTypeMacro( ProxTVImageFilter, ImageToImageFilter ); + itkTypeMacro(ProxTVImageFilter, ImageToImageFilter); /** Standard New macro. */ - itkNewMacro( Self ); + itkNewMacro(Self); /** Set/Get the MaximumNumberOfIterations */ itkSetMacro(MaximumNumberOfIterations, unsigned int); @@ -77,11 +77,13 @@ class ProxTVImageFilter: public ImageToImageFilter< TInputImage, TOutputImage > ProxTVImageFilter(); virtual ~ProxTVImageFilter() override {} - void PrintSelf( std::ostream& os, Indent indent ) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; typedef typename OutputImageType::RegionType OutputRegionType; - virtual void GenerateData() override; + virtual void + GenerateData() override; private: unsigned int m_MaximumNumberOfIterations; @@ -93,14 +95,13 @@ class ProxTVImageFilter: public ImageToImageFilter< TInputImage, TOutputImage > /** ImageDimension enumeration */ static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension; static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension; - itkConceptMacro( SameDimensionCheck, - ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) ); + itkConceptMacro(SameDimensionCheck, (Concept::SameDimension)); #endif }; -} +} // namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkProxTVImageFilter.hxx" +# include "itkProxTVImageFilter.hxx" #endif #endif // itkProxTVImageFilter diff --git a/include/itkProxTVImageFilter.hxx b/include/itkProxTVImageFilter.hxx index 1153575..15be7f8 100644 --- a/include/itkProxTVImageFilter.hxx +++ b/include/itkProxTVImageFilter.hxx @@ -27,35 +27,31 @@ namespace itk { -template< typename TInputImage, typename TOutputImage > -ProxTVImageFilter< TInputImage, TOutputImage > -::ProxTVImageFilter() -:m_MaximumNumberOfIterations(10), - m_Weights(1.0), - m_Norms(1.0) -{ -} +template +ProxTVImageFilter::ProxTVImageFilter() + : m_MaximumNumberOfIterations(10) + , m_Weights(1.0) + , m_Norms(1.0) +{} -template< typename TInputImage, typename TOutputImage > +template void -ProxTVImageFilter< TInputImage, TOutputImage > -::PrintSelf( std::ostream& os, Indent indent ) const +ProxTVImageFilter::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); os << indent << "MaximumNumberOfIterations: " << m_MaximumNumberOfIterations << std::endl; os << indent << "Weights: " << m_Weights << std::endl; os << indent << "Norms: " << m_Norms << std::endl; } -template< typename TInputImage, typename TOutputImage > +template void -ProxTVImageFilter< TInputImage, TOutputImage > -::GenerateData() +ProxTVImageFilter::GenerateData() { this->AllocateOutputs(); - OutputImageType * output = this->GetOutput(); + OutputImageType * output = this->GetOutput(); const InputImageType * input = this->GetInput(); using InputRegionType = typename InputImageType::RegionType; auto regionSize = output->GetLargestPossibleRegion().GetSize(); @@ -70,52 +66,59 @@ ProxTVImageFilter< TInputImage, TOutputImage > auto resultImage = DoubleImageType::New(); resultImage->SetRegions(output->GetLargestPossibleRegion()); resultImage->Allocate(); - resultImage->CopyInformation( input ); + resultImage->CopyInformation(input); /************ proxTV *************/ - const double* inputProxTV = inputCastFilter->GetOutput()->GetBufferPointer(); - double* resultProxTV = resultImage->GetBufferPointer(); - int nThreads = itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); - int maxIters = m_MaximumNumberOfIterations; - double* info = nullptr; - if(ImageDimension == 2) - { + const double * inputProxTV = inputCastFilter->GetOutput()->GetBufferPointer(); + double * resultProxTV = resultImage->GetBufferPointer(); + int nThreads = itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); + int maxIters = m_MaximumNumberOfIterations; + double * info = nullptr; + if (ImageDimension == 2) + { // int DR2_TV(size_t M (rows), size_t N (cols), double*inputProxTV (image), // double W1, double W2, double norm1, double norm2, double*s, int nThreads, // int maxit, double* info); - int r = DR2_TV(regionSize[0], regionSize[1], const_cast(inputProxTV), - m_Weights[0], m_Weights[1], m_Norms[0], m_Norms[1], resultProxTV, nThreads, - maxIters, info); - } + int r = DR2_TV(regionSize[0], + regionSize[1], + const_cast(inputProxTV), + m_Weights[0], + m_Weights[1], + m_Norms[0], + m_Norms[1], + resultProxTV, + nThreads, + maxIters, + info); + } else - { + { // int PD_TV(double *y,double *lambdas,double *norms,double *dims,double *x, // double *info,int *ns,int nds,int npen,int ncores,int maxIters){ double norms[ImageDimension]; double weights[ImageDimension]; - int elements[ImageDimension]; + int elements[ImageDimension]; double dims[ImageDimension]; // [1, 2, ..., N] for (unsigned int i = 0; i < ImageDimension; ++i) - { + { weights[i] = m_Weights[i]; norms[i] = m_Norms[i]; elements[i] = regionSize[i]; dims[i] = i + 1; - } - int r = PD_TV( - const_cast(inputProxTV), - weights, - norms, - dims /* Apply weights in these dims */, - resultProxTV, - info, - elements, - ImageDimension /* Number of penalty terms */, - ImageDimension /* Number of dimensions */, - nThreads, - maxIters); } + int r = PD_TV(const_cast(inputProxTV), + weights, + norms, + dims /* Apply weights in these dims */, + resultProxTV, + info, + elements, + ImageDimension /* Number of penalty terms */, + ImageDimension /* Number of dimensions */, + nThreads, + maxIters); + } using CastDoubleToOutputImageFilter = itk::CastImageFilter; auto outputCastFilter = CastDoubleToOutputImageFilter::New(); diff --git a/test/itkProxTVImageFilterTest.cxx b/test/itkProxTVImageFilterTest.cxx index 04104cf..1c7b253 100644 --- a/test/itkProxTVImageFilterTest.cxx +++ b/test/itkProxTVImageFilterTest.cxx @@ -23,129 +23,132 @@ #include "itkImageScanlineIterator.h" template -typename TImageType::Pointer Create2DImage() +typename TImageType::Pointer +Create2DImage() { using ImageType = TImageType; typename ImageType::SizeType size; - size.Fill( 64 ); + size.Fill(64); size[1] = 50; typename ImageType::Pointer image = ImageType::New(); - image->SetRegions( size ); + image->SetRegions(size); image->Allocate(); image->FillBuffer(1); // Set a band using ImageIterator = itk::ImageScanlineIterator; typename ImageType::RegionType bandRegion; - bandRegion.SetIndex({0,22}); - bandRegion.SetSize({64, 6}); + bandRegion.SetIndex({ 0, 22 }); + bandRegion.SetSize({ 64, 6 }); ImageIterator iter(image, bandRegion); - while ( !iter.IsAtEnd() ) + while (!iter.IsAtEnd()) + { + while (!iter.IsAtEndOfLine()) { - while ( !iter.IsAtEndOfLine() ) - { iter.Set(255); ++iter; - } - iter.NextLine(); } + iter.NextLine(); + } return image; } template -typename TImageType::Pointer Create3DImage() +typename TImageType::Pointer +Create3DImage() { using ImageType = TImageType; typename ImageType::SizeType size; - size.Fill( 32 ); + size.Fill(32); size[1] = 16; size[2] = 8; typename ImageType::Pointer image = ImageType::New(); - image->SetRegions( size ); + image->SetRegions(size); image->Allocate(); image->FillBuffer(1); // Set a band using ImageIterator = itk::ImageScanlineIterator; typename ImageType::RegionType bandRegion; - bandRegion.SetIndex({14, 0, 0}); - bandRegion.SetSize({6, 16, 8}); + bandRegion.SetIndex({ 14, 0, 0 }); + bandRegion.SetSize({ 6, 16, 8 }); ImageIterator iter(image, bandRegion); - while ( !iter.IsAtEnd() ) + while (!iter.IsAtEnd()) + { + while (!iter.IsAtEndOfLine()) { - while ( !iter.IsAtEndOfLine() ) - { iter.Set(255); ++iter; - } - iter.NextLine(); } + iter.NextLine(); + } return image; } -int itkProxTVImageFilterTest( int argc, char * argv[] ) +int +itkProxTVImageFilterTest(int argc, char * argv[]) { - if( argc < 3 ) - { + if (argc < 3) + { std::cerr << "Usage: " << argv[0]; std::cerr << " outputImage2D"; std::cerr << " outputImage3D"; std::cerr << std::endl; return EXIT_FAILURE; - } - const char * outputImageFileName = argv[1]; - const char * outputImage3DFileName = argv[2]; + } + const char * outputImageFileName = argv[1]; + const char * outputImage3DFileName = argv[2]; const unsigned int Dimension = 2; using PixelType = float; - using ImageType = itk::Image< PixelType, Dimension >; + using ImageType = itk::Image; - using FilterType = itk::ProxTVImageFilter< ImageType, ImageType >; + using FilterType = itk::ProxTVImageFilter; FilterType::Pointer filter = FilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( filter, ProxTVImageFilter, ImageToImageFilter ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ProxTVImageFilter, ImageToImageFilter); auto image = Create2DImage(); filter->SetInput(image); filter->Update(); - using WriterType = itk::ImageFileWriter< ImageType >; + using WriterType = itk::ImageFileWriter; WriterType::Pointer writer = WriterType::New(); - writer->SetFileName( outputImageFileName ); - writer->SetInput( filter->GetOutput() ); + writer->SetFileName(outputImageFileName); + writer->SetInput(filter->GetOutput()); writer->SetUseCompression(true); try - { + { writer->Update(); - } - catch( itk::ExceptionObject & error ) - { + } + catch (itk::ExceptionObject & error) + { std::cerr << "Error: " << error << std::endl; return EXIT_FAILURE; - } + } /************ 3D *************/ - using Image3DType = itk::Image< PixelType, 3 >; - using Filter3DType = itk::ProxTVImageFilter< Image3DType, Image3DType >; + using Image3DType = itk::Image; + using Filter3DType = itk::ProxTVImageFilter; Filter3DType::Pointer filter3D = Filter3DType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( filter3D, ProxTVImageFilter, ImageToImageFilter ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(filter3D, ProxTVImageFilter, ImageToImageFilter); auto image3D = Create3DImage(); filter3D->SetInput(image3D); filter3D->Update(); - using Writer3DType = itk::ImageFileWriter< Image3DType >; + using Writer3DType = itk::ImageFileWriter; Writer3DType::Pointer writer3d = Writer3DType::New(); - writer3d->SetFileName( outputImage3DFileName ); - writer3d->SetInput( filter3D->GetOutput() ); + writer3d->SetFileName(outputImage3DFileName); + writer3d->SetInput(filter3D->GetOutput()); writer3d->SetUseCompression(true); try - { + { writer3d->Update(); - } - catch( itk::ExceptionObject & error ) - { + } + catch (itk::ExceptionObject & error) + { std::cerr << "Error: " << error << std::endl; return EXIT_FAILURE; - } + } return EXIT_SUCCESS; }