def resample(self, shape): from diffeo2c import diffeo_resample d2 = diffeo_resample(self.d, shape) # this might give negative values v2 = scipy_image_resample(self.variance, shape) np.clip(v2, 0, 1, out=v2) return Diffeomorphism2D(d2, v2)
def next_phase(self): """ Switches to the next phase. """ cur_estimator = self.estimators[self.current_phase] cur_diffeo = cur_estimator.get_value() next_phase = self.phases[self.current_phase + 1] next_estimator = self._get_phase_estimator(next_phase.max_displ) # resample cur_diffeo_upsampled = diffeo_resample(cur_diffeo.d, next_phase.shape) next_estimator.set_guess(cur_diffeo_upsampled) self.estimators.append(next_estimator) self.current_phase += 1 self.phase_obs = 0 self.last_tmp_guess = None