Exemple #1
0
            x,y = X_plot.meshgrid
            u = disp_func[0]([x,y])         
            v = disp_func[1]([x,y]) 
            
            plt.quiver(x,y,u,v,color='yellow')
            plt.axis('equal'),
            plt.axis([-1.3,1.3,-1.3,1.3]),
#                plt.axis('off'),
            plt.gca().set_aspect('equal', adjustable='box'),
            plt.savefig(folder_out + '/deformation_field.png',
                        bbox_inches='tight', 
                        pad_inches=0, 
                        transparent=True, dpi=600,format='png')

                            
            deform_op = defm.LinDeformFixedDisp(vf)
                    
            deformed_gt = odl.DiagonalOperator(deform_op, deform_op)(gt)
            
            # Forward operator    
            if unitary is True:
                F = ops.UnitaryRealFourierTransform(X)
            else:
                F = ops.RealFourierTransform(X)
            
            sampling_parts = sampling.split('-')
            if sampling_parts[0] == 'cartesian':
                r = int(sampling_parts[1])
                sampling_op, mask = ops.get_cartesian_sampling(F.range[0], r)
            elif sampling_parts[0] == 'random':
                p = float(sampling_parts[1])
Exemple #2
0
                vf_gt = Yaff.element([shift[0], shift[1], 0, 0.08, 0, 0])
            elif deformation == 'nonlinear':
                cosp = np.cos(phi)
                sinp = np.sin(phi)
                disp_func = [
                    lambda x: (cosp - 1) * x[0] - sinp * x[1] + 0.05 * x[
                        1]**2 + shift[0], lambda x: sinp * x[0] +
                    (cosp - 1) * x[1] - 0.05 * x[0]**3 + shift[1]
                ]
                vf_gt = Yaff.element(
                    [shift[0], shift[1], cosp - 1, -sinp, sinp, cosp - 1])

            vf = V.element(disp_func)
            vf_hr = Xside.tangent_bundle.element(disp_func)

            deform_op = defm.LinDeformFixedDisp(vf)
            deform_op_hr = defm.LinDeformFixedDisp(vf_hr)

            # create clipping operator and deformed data image
            clim = [0, np.max(aligned_data)]
            if colormap == 'viridis':
                clim[1] *= 0.7

            projY = odl.solvers.IndicatorBox(Y, lower=clim[0],
                                             upper=clim[1]).proximal(1)

            deformed_data = projY(deform_op(aligned_data))

            plt.imsave(folder_out + '/' + data_fname + '_data_deformed.png',
                       projY(deformed_data),
                       cmap=colormap)
 def transl_op_fixed_im_rest(self, im, rest):
     rest_deform = defm.LinDeformFixedDisp(rest)
     deformed_im = rest_deform(im)
     transl_operator = defm.LinDeformFixedTempl(
         deformed_im) * self.embedding_affine
     return transl_operator
 def transl_op_fixed_vf(self, disp):
     deform_op = defm.LinDeformFixedDisp(self.embedding_affine_rest(disp))
     transl_operator = deform_op
     return transl_operator
 def transl_op_fixed_im_aff(self, im, aff):
     affine_deform = defm.LinDeformFixedDisp(self.embedding_affine(aff))
     deform_op = defm.LinDeformFixedTempl(affine_deform(im))
     transl_operator = deform_op
     return transl_operator