44 using ElastixType =
typename TPyramid::ElastixType;
46 constexpr bool isFixed = std::is_same_v<TPyramid, FixedGenericPyramid<ElastixType>>;
47 constexpr bool isMoving = std::is_same_v<TPyramid, MovingGenericPyramid<ElastixType>>;
49 static_assert(isMoving != isFixed,
"TPyramid must be either FixedGenericPyramid or MovingGenericPyramid!");
51 const std::string parameterPrefix = isFixed ?
"Fixed" :
"Moving";
52 constexpr const char * pyramidAdjective = isFixed ?
"fixed" :
"moving";
58 const Configuration & configuration = itk::Deref(pyramid.GetConfiguration());
61 const unsigned int ImageDimension = TPyramid::ImageDimension;
64 unsigned int numberOfResolutions = 3;
65 configuration.
ReadParameter(numberOfResolutions,
"NumberOfResolutions", 0,
true);
66 if (numberOfResolutions == 0)
68 itkGenericExceptionMacro(
"The NumberOfResolutions parameter must have a non-zero value!");
72 pyramid.GetAsITKBaseType()->SetNumberOfLevels(numberOfResolutions);
73 typename TPyramid::RescaleScheduleType rescaleSchedule = pyramid.GetRescaleSchedule();
74 typename TPyramid::SmoothingScheduleType smoothingSchedule = pyramid.GetSmoothingSchedule();
83 bool foundRescale =
true;
84 for (
unsigned int i = 0; i < numberOfResolutions; ++i)
86 for (
unsigned int j = 0; j < ImageDimension; ++j)
89 const unsigned int entrynr = i * ImageDimension + j;
90 ijfound |= configuration.
ReadParameter(rescaleSchedule[i][j],
"ImagePyramidRescaleSchedule", entrynr,
false);
91 ijfound |= configuration.
ReadParameter(rescaleSchedule[i][j],
"ImagePyramidSchedule", entrynr,
false);
93 rescaleSchedule[i][j], parameterPrefix +
"ImagePyramidRescaleSchedule", entrynr,
false);
95 configuration.
ReadParameter(rescaleSchedule[i][j], parameterPrefix +
"ImagePyramidSchedule", entrynr,
false);
98 foundRescale &= ijfound;
103 if (!foundRescale && pyramid.GetConfiguration()->GetPrintErrorMessages())
105 log::warn(std::ostringstream{} <<
"WARNING: the " << pyramidAdjective
106 <<
" pyramid rescale schedule is not fully specified!\n"
107 <<
" A default pyramid rescale schedule is used.");
112 pyramid.SetRescaleSchedule(rescaleSchedule);
114 const auto newSchedule = pyramid.GetRescaleSchedule();
116 if (newSchedule != rescaleSchedule)
119 std::ostringstream{} <<
"WARNING: the " << pyramidAdjective
120 <<
" pyramid rescale schedule is adjusted!\n Input schedule from configuration:\n"
121 << rescaleSchedule <<
"\n Adjusted schedule:\n"
131 bool foundSmoothing =
true;
132 for (
unsigned int i = 0; i < numberOfResolutions; ++i)
134 for (
unsigned int j = 0; j < ImageDimension; ++j)
136 bool ijfound =
false;
137 const unsigned int entrynr = i * ImageDimension + j;
139 configuration.
ReadParameter(smoothingSchedule[i][j],
"ImagePyramidSmoothingSchedule", entrynr,
false);
141 smoothingSchedule[i][j], parameterPrefix +
"ImagePyramidSmoothingSchedule", entrynr,
false);
144 foundSmoothing &= ijfound;
149 if (!foundSmoothing && pyramid.GetConfiguration()->GetPrintErrorMessages())
151 log::warn(std::ostringstream{} <<
"WARNING: the " << pyramidAdjective
152 <<
" pyramid smoothing schedule is not fully specified!\n"
153 <<
" A default pyramid smoothing schedule is used.");
158 pyramid.SetSmoothingSchedule(smoothingSchedule);
160 const auto newSchedule = pyramid.GetSmoothingSchedule();
162 if (newSchedule != smoothingSchedule)
165 std::ostringstream{} <<
"WARNING: the " << pyramidAdjective
166 <<
" pyramid smoothing schedule is adjusted!\n Input schedule from configuration:\n"
167 << smoothingSchedule <<
"\n Adjusted schedule:\n"
191 bool useShrinkImageFilter =
false;
192 configuration.
ReadParameter(useShrinkImageFilter,
"ImagePyramidUseShrinkImageFilter", 0,
false);
193 pyramid.SetUseShrinkImageFilter(useShrinkImageFilter);
199 bool computeThisResolution =
false;
200 configuration.
ReadParameter(computeThisResolution,
"ComputePyramidImagesPerResolution", 0,
false);
201 pyramid.SetComputeOnlyForCurrentLevel(computeThisResolution);