Beispiel #1
0
    for nu in range(num_smoothes):
        print strain.shape[1]
        for ni in range(strain_number):  # this loop may be simplied used Ax=B matrix assembly
            print "the computation process for the strain smooth(%)" + str(ni*100.0/strain.shape[1])
            connector = getConnector(ni,mesh_edge)
            np.append(connector,ni) # including itself for smoothing
            connecting_strains =  getConnectorValue(strain, connector)
            strain[:,ni] = np.mean(connecting_strains, 1)

if __name__ == "__main__":
    print "this a unit test process!"
    import SaveLoad
    import SpatialSampling
    import Visualization
    import scipy.ndimage as ndimage
    inputDVC = SaveLoad.DVCdata("Dir")
    point_arr1 = inputDVC.getPoints1()
    Sample_Density = 12
    
    mesh2 = SpatialSampling.MeshDelaunay(point_arr1.T) # use the original point_arr1 
    mesh2.mesh()
    mesh2.alpha_shape(Sample_Density)
    mesh2.mesh_triangle() # find unique triangles
    
    for dummy_i in range(1):   
        Mesh_optimizer = SpatialSampling.MeshOptimizer(point_arr1.T,mesh2.ntri)
        Mesh_optimizer.edge_connector_smooth()
      
    displacements = [inputDVC.getDisplacementX()[0], 
                                inputDVC.getDisplacementY()[0], 
                                inputDVC.getDisplacementZ()[0]]
"""
this module creates image transformation or project for two images' registration

"""
import SaveLoad
import Visulization
from scipy import ndimage
from scipy import interpolate
import numpy as np
import scipy.ndimage as ndimage

inputDVC = SaveLoad.DVCdata("/Users/junchaowei/Desktop/MultiStrainGage11182016/") # import the DVC database

################### save the displacement, and create interpolation ##############
inter_x = interpolate.LinearNDInterpolator(inputDVC.getPoints1(), inputDVC.getDisplacementX()[0], fill_value=0.0, rescale=True) 
inter_y = interpolate.LinearNDInterpolator(inputDVC.getPoints1(), inputDVC.getDisplacementY()[0], fill_value=0.0, rescale=True) 
inter_z = interpolate.LinearNDInterpolator(inputDVC.getPoints1(), inputDVC.getDisplacementZ()[0], fill_value=0.0, rescale=True) 

image1 = inputDVC.getImage1()
image2 = inputDVC.getImage2()

sx, sy = image1[:,:,0].shape  # get dimensionality of image
mx, my = np.meshgrid(np.linspace(1,sx,sx),np.linspace(1,sy,sy))
# meshgrid change the orientation of x,y: x becomes the horizontal axis, y becomes the vertical
# this change would affect the return statement of reshape.
Cord_xy = np.vstack([mx.flatten(), my.flatten()]) # column major vector

displacementDataX = np.zeros([sy,sx, image1.shape[2]]) 
displacementDataY = np.zeros([sy,sx, image1.shape[2]])
displacementDataZ = np.zeros([sy,sx, image1.shape[2]])