Exemplo n.º 1
0
print 'aligning shapes at rest'
for i in range(cShape[0]):
    rPoints[i], rR[i], rS[i], rT[i] = IT.procrustesAlignment2D(
        rMeanShape, cRest[i])

#Contracted state
cR = [0] * cShape[0]
cS = [0] * cShape[0]
cT = [0] * cShape[0]
cPoints = [0] * cShape[0]
cMeanShape = cRest[0]

print 'apply the alignment of rest to contractoin'
for i in range(cShape[0]):
    cPoints[i] = IT.apply2DTransformation(list(cCont[i]), rT[i], rR[i], rS[i])
#	cPoints[i],cR[i],cS[i],cT[i]=IT.procrustesAlignment2D(cMeanShape,cCont[i])

#plot the aligned shapes
f2, ax2 = plt.subplots(1, 1)

for i in range(cShape[0]):
    ax2.plot(rPoints[i][:, 0], rPoints[i][:, 1] * -1, '-or')
    ax2.plot(cPoints[i][:, 0], cPoints[i][:, 1] * -1, '-xb')

#############################################################################

#############################################################################
#Perform PSLR on aligned geometries

#Step 1: Flatten the input vectors
	rPoints=[0]*cShape[0]
	rMeanShape=cRest[0] #start with the mean as the first shape
	print 'aligning shapes at rest'
	for i in range(cShape[0]):
		rPoints[i],rR[i],rS[i],rT[i]=IT.procrustesAlignment2D(rMeanShape,cRest[i])

	#Contracted state
	cR=[0]*cShape[0]
	cS=[0]*cShape[0]
	cT=[0]*cShape[0]
	cPoints=[0]*cShape[0]
	cMeanShape=cRest[0] 

	print 'apply the alignment of rest to contractoin'
	for i in range(cShape[0]):
		cPoints[i]=IT.apply2DTransformation(list(cCont[i]),rT[i],rR[i],rS[i])

	for i in range(cShape[0]):
		ax3[0,1].plot(rPoints[i][:,0],rPoints[i][:,1]*-1,'or')
		ax3[0,1].plot(cPoints[i][:,0],cPoints[i][:,1]*-1,'xb')
		ax3[0,1].axis('equal')

	#Perform PSLR on aligned geometries

	#Step 1: Flatten the input vectors
	t0=[0]*(cShape[0]-1)
	t1=[0]*(cShape[0]-1)

	TestShape=0
	count=0
	for i in range(cShape[0]):