43 using ElastixType =
typename TPyramid::ElastixType;
45 constexpr bool isFixed = std::is_same<TPyramid, FixedGenericPyramid<ElastixType>>::value;
46 constexpr bool isMoving = std::is_same<TPyramid, MovingGenericPyramid<ElastixType>>::value;
48 static_assert(isMoving != isFixed,
"TPyramid must be either FixedGenericPyramid or MovingGenericPyramid!");
50 const std::string parameterPrefix = isFixed ?
"Fixed" :
"Moving";
51 constexpr const char * pyramidAdjective = isFixed ?
"fixed" :
"moving";
57 Configuration & configuration = *(pyramid.GetConfiguration());
60 const unsigned int ImageDimension = TPyramid::ImageDimension;
63 unsigned int numberOfResolutions = 3;
64 configuration.
ReadParameter(numberOfResolutions,
"NumberOfResolutions", 0,
true);
65 if (numberOfResolutions == 0)
67 numberOfResolutions = 1;
71 pyramid.GetAsITKBaseType()->SetNumberOfLevels(numberOfResolutions);
72 typename TPyramid::RescaleScheduleType rescaleSchedule = pyramid.GetRescaleSchedule();
73 typename TPyramid::SmoothingScheduleType smoothingSchedule = pyramid.GetSmoothingSchedule();
82 bool foundRescale =
true;
83 for (
unsigned int i = 0; i < numberOfResolutions; ++i)
85 for (
unsigned int j = 0; j < ImageDimension; ++j)
88 const unsigned int entrynr = i * ImageDimension + j;
89 ijfound |= configuration.
ReadParameter(rescaleSchedule[i][j],
"ImagePyramidRescaleSchedule", entrynr,
false);
90 ijfound |= configuration.
ReadParameter(rescaleSchedule[i][j],
"ImagePyramidSchedule", entrynr,
false);
92 rescaleSchedule[i][j], parameterPrefix +
"ImagePyramidRescaleSchedule", entrynr,
false);
94 configuration.
ReadParameter(rescaleSchedule[i][j], parameterPrefix +
"ImagePyramidSchedule", entrynr,
false);
97 foundRescale &= ijfound;
102 if (!foundRescale && pyramid.GetConfiguration()->GetPrintErrorMessages())
104 xl::xout[
"warning"] <<
"WARNING: the " << pyramidAdjective
105 <<
" pyramid rescale schedule is not fully specified!\n";
106 xl::xout[
"warning"] <<
" A default pyramid rescale schedule is used." << std::endl;
111 pyramid.SetRescaleSchedule(rescaleSchedule);
113 const auto newSchedule = pyramid.GetRescaleSchedule();
115 if (newSchedule != rescaleSchedule)
117 xl::xout[
"warning"] <<
"WARNING: the " << pyramidAdjective
118 <<
" pyramid rescale schedule is adjusted!\n Input schedule from configuration:\n"
119 << rescaleSchedule <<
"\n Adjusted schedule:\n"
120 << newSchedule << std::endl;
129 bool foundSmoothing =
true;
130 for (
unsigned int i = 0; i < numberOfResolutions; ++i)
132 for (
unsigned int j = 0; j < ImageDimension; ++j)
134 bool ijfound =
false;
135 const unsigned int entrynr = i * ImageDimension + j;
137 configuration.
ReadParameter(smoothingSchedule[i][j],
"ImagePyramidSmoothingSchedule", entrynr,
false);
139 smoothingSchedule[i][j], parameterPrefix +
"ImagePyramidSmoothingSchedule", entrynr,
false);
142 foundSmoothing &= ijfound;
147 if (!foundSmoothing && pyramid.GetConfiguration()->GetPrintErrorMessages())
149 xl::xout[
"warning"] <<
"WARNING: the " << pyramidAdjective
150 <<
" pyramid smoothing schedule is not fully specified!\n";
151 xl::xout[
"warning"] <<
" A default pyramid smoothing schedule is used." << std::endl;
156 pyramid.SetSmoothingSchedule(smoothingSchedule);
158 const auto newSchedule = pyramid.GetSmoothingSchedule();
160 if (newSchedule != smoothingSchedule)
162 xl::xout[
"warning"] <<
"WARNING: the " << pyramidAdjective
163 <<
" pyramid smoothing schedule is adjusted!\n Input schedule from configuration:\n"
164 << smoothingSchedule <<
"\n Adjusted schedule:\n"
165 << newSchedule << std::endl;
188 bool useShrinkImageFilter =
false;
189 configuration.
ReadParameter(useShrinkImageFilter,
"ImagePyramidUseShrinkImageFilter", 0,
false);
190 pyramid.SetUseShrinkImageFilter(useShrinkImageFilter);
196 bool computeThisResolution =
false;
197 configuration.
ReadParameter(computeThisResolution,
"ComputePyramidImagesPerResolution", 0,
false);
198 pyramid.SetComputeOnlyForCurrentLevel(computeThisResolution);