Skip to content

Commit 1508eae

Browse files
jhlegarretadzenanz
authored andcommitted
ENH: Add itk::GrayscaleGrindPeakImageFilter class test
Add `itk::GrayscaleGrindPeakImageFilter` class test.
1 parent ab14339 commit 1508eae

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fa7eb2b24ade1f2f29348858d65146a0864f60903810ce2a330776b4f74ef29fa62a4d390ba7b1116a60e954462f3e46ae316b389903ab3438240e73272ab548

Modules/Filtering/MathematicalMorphology/test/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ itkGrayscaleFunctionErodeImageFilterTest.cxx
1212
itkGrayscaleMorphologicalClosingImageFilterTest.cxx
1313
itkGrayscaleMorphologicalOpeningImageFilterTest.cxx
1414
itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx
15+
itkGrayscaleGrindPeakImageFilterTest.cxx
1516
itkHConcaveImageFilterTest.cxx
1617
itkHConvexImageFilterTest.cxx
1718
itkHConvexConcaveImageFilterTest.cxx
@@ -136,6 +137,11 @@ itk_add_test(NAME itkGrayscaleGeodesicErodeDilateImageFilterTest
136137
--compare DATA{${ITK_DATA_ROOT}/Baseline/BasicFilters/HMaximaMinimaImageFilterTest.png}
137138
${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGeodesicErodeDilateImageFilterTest.png
138139
itkGrayscaleGeodesicErodeDilateImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cake_easy.png} ${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGeodesicErodeDilateImageFilterTest.png 35)
140+
itk_add_test(NAME itkGrayscaleGrindPeakImageFilterTest
141+
COMMAND ITKMathematicalMorphologyTestDriver
142+
--compare DATA{Baseline/itkGrayscaleGrindPeakImageFilterTest.png}
143+
${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGrindPeakImageFilterTest.png
144+
itkGrayscaleGrindPeakImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cthead1.png} ${ITK_TEST_OUTPUT_DIR}/itkGrayscaleGrindPeakImageFilterTest.png 0)
139145
itk_add_test(NAME itkHConcaveImageFilterTestFullyConnectedOff
140146
COMMAND ITKMathematicalMorphologyTestDriver
141147
--compare-MD5 ${ITK_TEST_OUTPUT_DIR}/itkHConcaveImageFilterTestFullyConnectedOff.png
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
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+
//
20+
21+
#include "itkImageFileReader.h"
22+
#include "itkImageFileWriter.h"
23+
24+
#include "itkGrayscaleGrindPeakImageFilter.h"
25+
#include "itkTestingMacros.h"
26+
27+
int
28+
itkGrayscaleGrindPeakImageFilterTest(int argc, char * argv[])
29+
{
30+
if (argc < 3)
31+
{
32+
std::cerr << "Missing arguments." << std::endl;
33+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputImageFile"
34+
<< " outputImageFile"
35+
<< " fullyConnected" << std::endl;
36+
return EXIT_FAILURE;
37+
}
38+
39+
40+
//
41+
// The following code defines the input and output pixel types and their
42+
// associated image types.
43+
//
44+
constexpr unsigned int Dimension = 2;
45+
46+
using InputPixelType = unsigned char;
47+
using OutputPixelType = unsigned char;
48+
using WritePixelType = unsigned char;
49+
50+
using InputImageType = itk::Image<InputPixelType, Dimension>;
51+
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
52+
using WriteImageType = itk::Image<WritePixelType, Dimension>;
53+
54+
using ReaderType = itk::ImageFileReader<InputImageType>;
55+
ReaderType::Pointer reader = ReaderType::New();
56+
reader->SetFileName(argv[1]);
57+
58+
59+
// Create the filter
60+
using GrindPeakFilterType = itk::GrayscaleGrindPeakImageFilter<InputImageType, OutputImageType>;
61+
GrindPeakFilterType::Pointer grindpeak = GrindPeakFilterType::New();
62+
63+
ITK_EXERCISE_BASIC_OBJECT_METHODS(grindpeak, GrayscaleGrindPeakImageFilter, ImageToImageFilter);
64+
65+
grindpeak->SetInput(reader->GetOutput());
66+
67+
auto fullyConnected = static_cast<bool>(std::stoi(argv[3]));
68+
ITK_TEST_SET_GET_BOOLEAN(grindpeak, FullyConnected, fullyConnected);
69+
70+
ITK_TRY_EXPECT_NO_EXCEPTION(grindpeak->Update());
71+
72+
// Write the output
73+
using WriterType = itk::ImageFileWriter<WriteImageType>;
74+
WriterType::Pointer writer = WriterType::New();
75+
writer->SetFileName(argv[2]);
76+
writer->SetInput(grindpeak->GetOutput());
77+
78+
ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
79+
80+
81+
std::cout << "Test finished" << std::endl;
82+
return EXIT_SUCCESS;
83+
}

0 commit comments

Comments
 (0)