Exemplo n.º 1
0
 def forward_alpha(self, v_t, x):
     """
     helper function for step (4): Calculation of forward flows
     @param v_t: the velocity field
     @param x: coordinates
     @return:
     """
     alpha = np.zeros(v_t.shape)
     for i in range(5):
         alpha = sampler.sample(v_t, x - 0.5 * alpha)
     return alpha
Exemplo n.º 2
0
    def pull_back(self, I1, Phi1):
        """
        implements step (6): pull back image I1 along flow Phi1
        @param I1: image
        @param Phi1: flow
        @return: sequence of back-pulled images J1
        """
        J1 = np.zeros((self.T, ) + I1.shape)

        for t in range(self.T - 1, -1, -1):
            J1[t] = sampler.sample(I1, Phi1[t])

        return J1
Exemplo n.º 3
0
    def push_forward(self, I0, Phi0):
        """
        implements step (5): push forward image I0 along flow Phi0
        @param I0: image
        @param Phi0: flow
        @return: sequence of forward pushed images J0
        """
        J0 = np.zeros((self.T, ) + I0.shape)

        for t in range(0, self.T):
            J0[t] = sampler.sample(I0, Phi0[t])

        return J0
Exemplo n.º 4
0
    def integrate_forward_flow(self, v):
        """
        implements step (4): Calculation of forward flows
        @return:
        """
        # make identity grid
        x = grid.coordinate_grid((self.H, self.W))

        # create flow
        Phi0 = np.zeros((self.T, self.H, self.W, 2))

        # Phi0_0 is the identity mapping
        Phi0[0] = x

        for t in range(0, self.T - 1):
            alpha = self.forward_alpha(v[t], x)
            Phi0[t + 1] = sampler.sample(Phi0[t], x - alpha)

        return Phi0
Exemplo n.º 5
0
    def integrate_backward_flow(self, v):
        """
        implements step (3): Calculation of backward flows
        @return:
        """
        # make identity grid
        x = grid.coordinate_grid((self.H, self.W))

        # create flow
        Phi1 = np.zeros((self.T, self.H, self.W, 2))

        # Phi1_1 is the identity mapping
        Phi1[self.T - 1] = x

        for t in range(self.T - 2, -1, -1):
            alpha = self.backwards_alpha(v[t], x)
            Phi1[t] = sampler.sample(Phi1[t + 1], x + alpha)

        return Phi1