Skip to content

Commit

Permalink
ENH: Add itk::LaplacianSharpeningImageFilter unit test
Browse files Browse the repository at this point in the history
Add `itk::LaplacianSharpeningImageFilter` unit test.
  • Loading branch information
jhlegarreta committed Mar 13, 2022
1 parent aa2354e commit 93d238e
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6ae1c71666f1d83753ee0d67a841a10556cafc6dd45ff5d6f0ddf65f7e2e6fcc0c04b44ec5dd82583ccae7fd54cec5ced017f7ca211456364a6143a28081f1b7
6 changes: 6 additions & 0 deletions Modules/Filtering/ImageFeature/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ itkZeroCrossingImageFilterTest.cxx
itkCannyEdgeDetectionImageFilterTest2.cxx
itkDerivativeImageFilterTest.cxx
itkLaplacianRecursiveGaussianImageFilterTest.cxx
itkLaplacianSharpeningImageFilterTest.cxx
itkMaskFeaturePointSelectionFilterTest.cxx
itkUnsharpMaskImageFilterTestSimple.cxx
itkUnsharpMaskImageFilterTest.cxx
Expand Down Expand Up @@ -175,6 +176,11 @@ itk_add_test(NAME itkLaplacianRecursiveGaussianImageFilterTest
--compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/LaplacianRecursiveGaussianImageFilterTest.png,:}
${ITK_TEST_OUTPUT_DIR}/LaplacianRecursiveGaussianImageFilterTest.png
itkLaplacianRecursiveGaussianImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/LaplacianRecursiveGaussianImageFilterTest.png)
itk_add_test(NAME itkLaplacianSharpeningImageFilterTest
COMMAND ITKImageFeatureTestDriver
--compare DATA{Baseline/itkLaplacianSharpeningImageFilterTest.png}
${ITK_TEST_OUTPUT_DIR}/itkLaplacianSharpeningImageFilterTest.png
itkLaplacianSharpeningImageFilterTest DATA{${ITK_DATA_ROOT}/Input/sf4.png} ${ITK_TEST_OUTPUT_DIR}/itkLaplacianSharpeningImageFilterTest.png 1)
itk_add_test(NAME itkMaskFeaturePointSelectionFilterTest
COMMAND ITKImageFeatureTestDriver
--compare DATA{Baseline/itkMaskFeaturePointSelectionFilterTest.mha}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/

#include "itkLaplacianSharpeningImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkTestingMacros.h"


int
itkLaplacianSharpeningImageFilterTest(int argc, char * argv[])
{
if (argc != 4)
{
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFilename"
<< " outputFilename"
<< " useImageSpacing" << std::endl;
return EXIT_FAILURE;
}

using PixelType = unsigned char;
constexpr unsigned int Dimension = 2;

using ImageType = itk::Image<PixelType, Dimension>;

using ReaderType = itk::ImageFileReader<ImageType>;

auto reader = ReaderType::New();
reader->SetFileName(argv[1]);

ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());


using LaplacianSharpeningFilterType = itk::LaplacianSharpeningImageFilter<ImageType, ImageType>;

auto laplacianSharpeningFilter = LaplacianSharpeningFilterType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(laplacianSharpeningFilter, LaplacianSharpeningImageFilter, ImageToImageFilter);


auto useImageSpacing = static_cast<bool>(std::stoi(argv[3]));
ITK_TEST_SET_GET_BOOLEAN(laplacianSharpeningFilter, UseImageSpacing, useImageSpacing);

laplacianSharpeningFilter->SetInput(reader->GetOutput());

ITK_TRY_EXPECT_NO_EXCEPTION(laplacianSharpeningFilter->Update());


itk::WriteImage(laplacianSharpeningFilter->GetOutput(), argv[2]);


std::cout << "Test finished." << std::endl;
return EXIT_SUCCESS;
}

0 comments on commit 93d238e

Please sign in to comment.