Skip to content

Commit 0b6a102

Browse files
hjmjohnsonclaude
andcommitted
ENH: Convert itkGaborKernelFunctionTest to GTest
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 24c5bc9 commit 0b6a102

4 files changed

Lines changed: 95 additions & 90 deletions

File tree

Modules/Filtering/ImageSources/itk-module.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ itk_module(
55
COMPILE_DEPENDS
66
ITKCommon
77
TEST_DEPENDS
8+
ITKGoogleTest
89
ITKTestKernel
910
ITKImageIntensity
1011
DESCRIPTION "${DOCUMENTATION}"

Modules/Filtering/ImageSources/test/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
itk_module_test()
22
set(
33
ITKImageSourcesTests
4-
itkGaborKernelFunctionTest.cxx
54
itkGaborImageSourceTest.cxx
65
itkGaussianImageSourceTest.cxx
76
itkGridImageSourceTest.cxx
@@ -11,12 +10,10 @@ set(
1110

1211
createtestdriver(ITKImageSources "${ITKImageSources-Test_LIBRARIES}" "${ITKImageSourcesTests}")
1312

14-
itk_add_test(
15-
NAME itkGaborKernelFunctionTest
16-
COMMAND
17-
ITKImageSourcesTestDriver
18-
itkGaborKernelFunctionTest
19-
)
13+
set(ITKImageSourcesGTests itkGaborKernelFunctionGTest.cxx)
14+
15+
creategoogletestdriver(ITKImageSources "${ITKImageSources-Test_LIBRARIES}" "${ITKImageSourcesGTests}")
16+
2017
itk_add_test(
2118
NAME itkGaborImageSourceTest0
2219
COMMAND
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
* https://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+
#include "itkGaborKernelFunction.h"
20+
#include "itkMath.h"
21+
#include "itkGTest.h"
22+
23+
TEST(GaborKernelFunction, BasicObjectMethods)
24+
{
25+
using KernelFunctionType = itk::GaborKernelFunction<double>;
26+
auto gabor = KernelFunctionType::New();
27+
28+
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(gabor, GaborKernelFunction, KernelFunctionBase);
29+
}
30+
31+
TEST(GaborKernelFunction, SetGetParameters)
32+
{
33+
using KernelFunctionType = itk::GaborKernelFunction<double>;
34+
auto gabor = KernelFunctionType::New();
35+
36+
constexpr double sigma{ 1.5 };
37+
gabor->SetSigma(sigma);
38+
EXPECT_DOUBLE_EQ(gabor->GetSigma(), sigma);
39+
40+
constexpr double frequency{ 2.0 };
41+
gabor->SetFrequency(frequency);
42+
EXPECT_DOUBLE_EQ(gabor->GetFrequency(), frequency);
43+
44+
constexpr double phaseOffset{ 0.8 };
45+
gabor->SetPhaseOffset(phaseOffset);
46+
EXPECT_DOUBLE_EQ(gabor->GetPhaseOffset(), phaseOffset);
47+
48+
gabor->SetCalculateImaginaryPart(true);
49+
EXPECT_TRUE(gabor->GetCalculateImaginaryPart());
50+
51+
gabor->CalculateImaginaryPartOn();
52+
EXPECT_TRUE(gabor->GetCalculateImaginaryPart());
53+
54+
gabor->CalculateImaginaryPartOff();
55+
EXPECT_FALSE(gabor->GetCalculateImaginaryPart());
56+
}
57+
58+
TEST(GaborKernelFunction, EvaluateImaginaryPart)
59+
{
60+
using KernelFunctionType = itk::GaborKernelFunction<double>;
61+
auto gabor = KernelFunctionType::New();
62+
63+
gabor->SetSigma(1.5);
64+
gabor->SetFrequency(2.0);
65+
gabor->SetPhaseOffset(0.8);
66+
gabor->CalculateImaginaryPartOn();
67+
68+
constexpr double tolerance{ 1e-12 };
69+
constexpr double point{ 2.86 };
70+
constexpr double expectedValue{ -0.13297125073713259 };
71+
72+
EXPECT_NEAR(gabor->Evaluate(point), expectedValue, tolerance);
73+
}
74+
75+
TEST(GaborKernelFunction, EvaluateRealPart)
76+
{
77+
using KernelFunctionType = itk::GaborKernelFunction<double>;
78+
auto gabor = KernelFunctionType::New();
79+
80+
gabor->SetSigma(1.5);
81+
gabor->SetFrequency(2.0);
82+
gabor->SetPhaseOffset(0.8);
83+
gabor->CalculateImaginaryPartOff();
84+
85+
constexpr double tolerance{ 1e-12 };
86+
constexpr double point{ 2.86 };
87+
constexpr double expectedValue{ 0.093234196962237226 };
88+
89+
EXPECT_NEAR(gabor->Evaluate(point), expectedValue, tolerance);
90+
}

Modules/Filtering/ImageSources/test/itkGaborKernelFunctionTest.cxx

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)