def steer(self): N = self.fixedCL.shape # Obtain 2D view SteeringGeneric.update_slices(self) fixed2D, moving2D = self.get_slices() fixedV, movingV = self.get_slice_axes() F = SteeringGeneric.get_frame_matrix(self, fixedV, movingV) # Perform 2D registration scale, T2 = self.register_scale2d(fixed2D, moving2D) print "S = ", scale S = np.identity(3, np.single) * scale T = F[:,0] * T2[0] + F[:,1] * T2[1] C = np.array([N[0]/2, N[1]/2, N[2]/2], np.single) T += C - np.dot(S,C) T = np.single(T) # Subtract identitiy from matrix to match convention for PolyAffineCL for dim in range(3): S[dim, dim] -= 1.0 # Return 3D transformation that will be folded into an existing polyaffine return S, T
def steer(self): N = self.fixedCL.shape # Obtain 2D view SteeringGeneric.update_slices(self) fixed2D, moving2D = self.get_slices() fixedV, movingV = self.get_slice_axes() F = SteeringGeneric.get_frame_matrix(self, fixedV, movingV) # Perform 2D registration R2, T2 = self.register_rigid2d(fixed2D, moving2D) print "R2 = ", R2 print "T2 = ", T2 R = np.identity(3, np.float32) R[:2,:2] = R2 # Project trafo to 3D, from 2D transform in u,v axes from frame F = [u v w] # [u v w] [R2 0; 0 0 1] [x; y; 0] = R [u v w] [x; y; 0] # R = F [R2 0; 0 0 1] inv(F) R = np.dot(F, np.dot(R, np.linalg.inv(F))) T = F[:,0] * T2[0] + F[:,1] * T2[1] C = np.array([N[0]/2, N[1]/2, N[2]/2], np.float32) T += C - np.dot(R,C) # Subtract identity from R to follow convention in PolyAffineCL for dim in range(3): R[dim, dim] -= 1.0 # Return 3D transformation that will be folded into an existing polyaffine return R, T