Skip to content

Commit 9e42b76

Browse files
committed
BUG: Fix warp filter exception and apply clang-format to src/
The ContinuousBorderWarpImageFilter incorrectly threw an exception when TransformPhysicalPointToContinuousIndex returned false (point outside image domain). Out-of-bounds points are expected in warp operations — the subsequent clamping to boundary indices provides the continuous-border behavior. This caused all 14 registration tests to fail with "Failed to warp moving image." Also apply clang-format 19 to VariationalRegistrationMain.cxx and win32_compatibility/getopt.h (lint CI failures).
1 parent 05183ce commit 9e42b76

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

include/itkContinuousBorderWarpImageFilter.hxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ ContinuousBorderWarpImageFilter<TInputImage, TOutputImage, TDisplacementField>::
7070
point[j] += displacement[j];
7171
}
7272

73-
// project point into image region
74-
if (!inputPtr->TransformPhysicalPointToContinuousIndex(point, contIndex))
75-
{
76-
itkExceptionMacro("Physical point " << point << " is outside the image domain");
77-
}
73+
// project point into image region (out-of-bounds is expected;
74+
// the clamping below provides continuous-border behavior)
75+
inputPtr->TransformPhysicalPointToContinuousIndex(point, contIndex);
7876

7977
for (unsigned int j = 0; j < ImageDimension; j++)
8078
{

src/VariationalRegistrationMain.cxx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ main(int argc, char * argv[])
640640
FunctionType::Pointer function;
641641
switch (forceType)
642642
{
643-
case 0: {
643+
case 0:
644+
{
644645
DemonsFunctionType::Pointer demonsFunction = DemonsFunctionType::New();
645646
switch (forceDomain)
646647
{
@@ -658,7 +659,8 @@ main(int argc, char * argv[])
658659
function = demonsFunction;
659660
}
660661
break;
661-
case 1: {
662+
case 1:
663+
{
662664
SSDFunctionType::Pointer ssdFunction = SSDFunctionType::New();
663665
switch (forceDomain)
664666
{
@@ -676,7 +678,8 @@ main(int argc, char * argv[])
676678
function = ssdFunction;
677679
}
678680
break;
679-
case 2: {
681+
case 2:
682+
{
680683
NCCFunctionType::Pointer nccFunction = NCCFunctionType::New();
681684
NCCFunctionType::RadiusType r;
682685
for (unsigned int dim = 0; dim < NCCFunctionType::ImageDimension; dim++)
@@ -719,19 +722,22 @@ main(int argc, char * argv[])
719722
RegularizerType::Pointer regularizer;
720723
switch (regularizerType)
721724
{
722-
case 0: {
725+
case 0:
726+
{
723727
GaussianRegularizerType::Pointer gaussRegularizer = GaussianRegularizerType::New();
724728
gaussRegularizer->SetStandardDeviations(std::sqrt(regulVar));
725729
regularizer = gaussRegularizer;
726730
}
727731
break;
728-
case 1: {
732+
case 1:
733+
{
729734
DiffusionRegularizerType::Pointer diffRegularizer = DiffusionRegularizerType::New();
730735
diffRegularizer->SetAlpha(regulAlpha);
731736
regularizer = diffRegularizer;
732737
}
733738
break;
734-
case 2: {
739+
case 2:
740+
{
735741
#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)
736742
ElasticRegularizerType::Pointer elasticRegularizer = ElasticRegularizerType::New();
737743
elasticRegularizer->SetMu(regulMu);
@@ -742,7 +748,8 @@ main(int argc, char * argv[])
742748
#endif
743749
}
744750
break;
745-
case 3: {
751+
case 3:
752+
{
746753
#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)
747754
CurvatureRegularizerType::Pointer curvatureRegularizer = CurvatureRegularizerType::New();
748755
curvatureRegularizer->SetAlpha(regulAlpha);
@@ -768,17 +775,20 @@ main(int argc, char * argv[])
768775
RegistrationFilterType::Pointer regFilter;
769776
switch (searchSpace)
770777
{
771-
case 0: {
778+
case 0:
779+
{
772780
regFilter = RegistrationFilterType::New();
773781
break;
774782
}
775-
case 1: {
783+
case 1:
784+
{
776785
DiffeomorphicRegistrationFilterType::Pointer diffeoRegFilter = DiffeomorphicRegistrationFilterType::New();
777786
diffeoRegFilter->SetNumberOfExponentiatorIterations(numberOfExponentiatorIterations);
778787
regFilter = diffeoRegFilter;
779788
break;
780789
}
781-
case 2: {
790+
case 2:
791+
{
782792
SymmetricDiffeomorphicRegistrationFilterType::Pointer symmDiffeoRegFilter =
783793
SymmetricDiffeomorphicRegistrationFilterType::New();
784794
symmDiffeoRegFilter->SetNumberOfExponentiatorIterations(numberOfExponentiatorIterations);

src/win32_compatibility/getopt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
#ifdef _WIN32
4444
/* from <sys/cdefs.h> */
4545
# ifdef __cplusplus
46-
# define __BEGIN_DECLS \
47-
extern "C" \
46+
# define __BEGIN_DECLS \
47+
extern "C" \
4848
{
4949
# define __END_DECLS }
5050
# else

0 commit comments

Comments
 (0)