From 6ab9a2a8d476eefc4b850dd76dbe47cc460bce30 Mon Sep 17 00:00:00 2001 From: Nick Tustison Date: Mon, 22 May 2023 17:44:19 -0700 Subject: [PATCH 1/2] ENH: Add spacing option for laplacian sharpening. --- Examples/ImageMath.cxx | 2 +- Examples/ImageMath_Templates.hxx | 7 +++++++ Examples/antsVol.cxx | 1 - Scripts/antsMultivariateTemplateConstruction.sh | 2 +- Scripts/antsMultivariateTemplateConstruction2.sh | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Examples/ImageMath.cxx b/Examples/ImageMath.cxx index 905d57b99..231637f0f 100644 --- a/Examples/ImageMath.cxx +++ b/Examples/ImageMath.cxx @@ -593,7 +593,7 @@ ImageMath(std::vector args, std::ostream * itkNotUsed(out_stream)) std::cout << " Usage : SigmoidImage ImageIn [alpha=1.0] [beta=0.0]" << std::endl; std::cout << "\n Sharpen : Apply a Laplacian sharpening filter" << std::endl; - std::cout << " Usage : Sharpen ImageIn" << std::endl; + std::cout << " Usage : Sharpen ImageIn [useImageSpacing=(1)/0]" << std::endl; std::cout << "\n UnsharpMask Apply an Unsharp Mask filter" << std::endl; std::cout diff --git a/Examples/ImageMath_Templates.hxx b/Examples/ImageMath_Templates.hxx index 068033e77..09460e07d 100644 --- a/Examples/ImageMath_Templates.hxx +++ b/Examples/ImageMath_Templates.hxx @@ -2164,12 +2164,19 @@ SharpenImage(int argc, char * argv[]) const std::string outputFilename = std::string(argv[2]); const std::string inputFilename = std::string(argv[4]); + bool useImageSpacing = true; + if(argc > 3) + { + useImageSpacing = static_cast(std::stoi(argv[5])); + } + typename ImageType::Pointer inputImage = nullptr; ReadImage(inputImage, inputFilename.c_str()); typedef itk::LaplacianSharpeningImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput(inputImage); + filter->SetUseImageSpacing(useImageSpacing); filter->Update(); ANTs::WriteImage(filter->GetOutput(), outputFilename.c_str()); diff --git a/Examples/antsVol.cxx b/Examples/antsVol.cxx index 0e48da6bd..dc83bbd27 100644 --- a/Examples/antsVol.cxx +++ b/Examples/antsVol.cxx @@ -19,7 +19,6 @@ #include "vtkRenderer.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" -#include "vtkSampleFunction.h" #include "vtkSmartPointer.h" #include "vtkSmartVolumeMapper.h" #include "vtkSphere.h" diff --git a/Scripts/antsMultivariateTemplateConstruction.sh b/Scripts/antsMultivariateTemplateConstruction.sh index 36458d9ea..78bf63f79 100755 --- a/Scripts/antsMultivariateTemplateConstruction.sh +++ b/Scripts/antsMultivariateTemplateConstruction.sh @@ -305,7 +305,7 @@ function summarizeimageset() { ;; 1) echo "Laplacian sharpening" - ${ANTSPATH}/ImageMath $dim $output Sharpen $output + ${ANTSPATH}/ImageMath $dim $output Sharpen $output 0 ;; 2) echo "Unsharp mask sharpening" diff --git a/Scripts/antsMultivariateTemplateConstruction2.sh b/Scripts/antsMultivariateTemplateConstruction2.sh index e50e9a5ca..4ca832bcc 100755 --- a/Scripts/antsMultivariateTemplateConstruction2.sh +++ b/Scripts/antsMultivariateTemplateConstruction2.sh @@ -369,7 +369,7 @@ function summarizeimageset() { ;; 1) echo "Laplacian sharpening" - ${ANTSPATH}/ImageMath $dim $output Sharpen $output + ${ANTSPATH}/ImageMath $dim $output Sharpen $output 0 ;; 2) echo "Unsharp mask sharpening" From 10b08c285414613afd411c165f2a5ba12c525785 Mon Sep 17 00:00:00 2001 From: Nick Tustison Date: Mon, 22 May 2023 17:44:19 -0700 Subject: [PATCH 2/2] ENH: Add spacing option for laplacian sharpening. BUG: wrong arg count. --- Examples/ImageMath.cxx | 2 +- Examples/ImageMath_Templates.hxx | 7 +++++++ Examples/antsVol.cxx | 1 - Scripts/antsMultivariateTemplateConstruction.sh | 2 +- Scripts/antsMultivariateTemplateConstruction2.sh | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Examples/ImageMath.cxx b/Examples/ImageMath.cxx index 905d57b99..231637f0f 100644 --- a/Examples/ImageMath.cxx +++ b/Examples/ImageMath.cxx @@ -593,7 +593,7 @@ ImageMath(std::vector args, std::ostream * itkNotUsed(out_stream)) std::cout << " Usage : SigmoidImage ImageIn [alpha=1.0] [beta=0.0]" << std::endl; std::cout << "\n Sharpen : Apply a Laplacian sharpening filter" << std::endl; - std::cout << " Usage : Sharpen ImageIn" << std::endl; + std::cout << " Usage : Sharpen ImageIn [useImageSpacing=(1)/0]" << std::endl; std::cout << "\n UnsharpMask Apply an Unsharp Mask filter" << std::endl; std::cout diff --git a/Examples/ImageMath_Templates.hxx b/Examples/ImageMath_Templates.hxx index 068033e77..ca8763ecc 100644 --- a/Examples/ImageMath_Templates.hxx +++ b/Examples/ImageMath_Templates.hxx @@ -2164,12 +2164,19 @@ SharpenImage(int argc, char * argv[]) const std::string outputFilename = std::string(argv[2]); const std::string inputFilename = std::string(argv[4]); + bool useImageSpacing = true; + if(argc > 5) + { + useImageSpacing = static_cast(std::stoi(argv[5])); + } + typename ImageType::Pointer inputImage = nullptr; ReadImage(inputImage, inputFilename.c_str()); typedef itk::LaplacianSharpeningImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput(inputImage); + filter->SetUseImageSpacing(useImageSpacing); filter->Update(); ANTs::WriteImage(filter->GetOutput(), outputFilename.c_str()); diff --git a/Examples/antsVol.cxx b/Examples/antsVol.cxx index 0e48da6bd..dc83bbd27 100644 --- a/Examples/antsVol.cxx +++ b/Examples/antsVol.cxx @@ -19,7 +19,6 @@ #include "vtkRenderer.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" -#include "vtkSampleFunction.h" #include "vtkSmartPointer.h" #include "vtkSmartVolumeMapper.h" #include "vtkSphere.h" diff --git a/Scripts/antsMultivariateTemplateConstruction.sh b/Scripts/antsMultivariateTemplateConstruction.sh index 36458d9ea..78bf63f79 100755 --- a/Scripts/antsMultivariateTemplateConstruction.sh +++ b/Scripts/antsMultivariateTemplateConstruction.sh @@ -305,7 +305,7 @@ function summarizeimageset() { ;; 1) echo "Laplacian sharpening" - ${ANTSPATH}/ImageMath $dim $output Sharpen $output + ${ANTSPATH}/ImageMath $dim $output Sharpen $output 0 ;; 2) echo "Unsharp mask sharpening" diff --git a/Scripts/antsMultivariateTemplateConstruction2.sh b/Scripts/antsMultivariateTemplateConstruction2.sh index e50e9a5ca..4ca832bcc 100755 --- a/Scripts/antsMultivariateTemplateConstruction2.sh +++ b/Scripts/antsMultivariateTemplateConstruction2.sh @@ -369,7 +369,7 @@ function summarizeimageset() { ;; 1) echo "Laplacian sharpening" - ${ANTSPATH}/ImageMath $dim $output Sharpen $output + ${ANTSPATH}/ImageMath $dim $output Sharpen $output 0 ;; 2) echo "Unsharp mask sharpening"