Ejemplo n.º 1
0
                pointLine = True

            elif line is '}':
                pointLine = False
                pass
            elif pointLine:
                ptList.append(map(float, line.split(' ')))
            else:
                pass
    ptList
    s1 = Shape(ptList)

    f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)

    ## Original shape (input)
    cmShape = ASM.centroid(s1)
    plotAll(ax1, s1)

    ############## Calc transformations ###################
    ## Translate
    t = [[-cmShape.x], [-cmShape.y]]
    for pt in s1.shapePoints:
        pt.translate(t)
    s1.update()
    plotAll(ax2, s1)

    leftEyeIx = 33
    rightEyeIx = 28

    ## Scale
    d1 = s1.shapePoints[leftEyeIx].dist(s1.shapePoints[rightEyeIx])
Ejemplo n.º 2
0
def plotAll(axis, shape):
    cm = ASM.centroid(shape)
    drawShape(axis, shape)
    drawCentroid(axis, cm)
    drawEyeSegment(axis, shape)
import matplotlib.pyplot as plt
import seaborn as sns
import math
import numpy as np

s1 = Shape( [ Point(200,300), Point(100, 200), Point(300, 50 ) ] )
s2 = Shape( [ Point(150,250), Point(50, 100 ), Point(250, 0) ] )



f, ((ax1,ax2),(ax3,ax4)) = plt.subplots(2,2, sharex =True, sharey = True)
s1.draw( sns.xkcd_palette( ["light blue" ]), ax1)
s2.draw( sns.xkcd_palette( ["light blue"] ), ax2)


cmShape  = ASM.centroid( s1)

cmMeanShape = ASM.centroid( s2  )


ax1.scatter( cmShape.x, cmShape.y, c='r')
ax2.scatter( cmMeanShape.x, cmMeanShape.y, c='r')
ax1.plot( [s1.shapePoints[0].x, s1.shapePoints[1].x],
         [s1.shapePoints[0].y, s1.shapePoints[1].y],
         color= 'r', ls = '-')

ax2.plot( [s2.shapePoints[0].x, s2.shapePoints[1].x],
         [s2.shapePoints[0].y, s2.shapePoints[1].y],
         color= 'r', lw = 1, ls = '-')

from ActiveShapeModels import ASM, Point, Shape
import matplotlib.pyplot as plt
import seaborn as sns
import math
import numpy as np

s1 = Shape([Point(200, 300), Point(100, 200), Point(300, 50)])
s2 = Shape([Point(150, 250), Point(50, 100), Point(250, 0)])

f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, sharey=True)
s1.draw(sns.xkcd_palette(["light blue"]), ax1)
s2.draw(sns.xkcd_palette(["light blue"]), ax2)

cmShape = ASM.centroid(s1)

cmMeanShape = ASM.centroid(s2)

ax1.scatter(cmShape.x, cmShape.y, c='r')
ax2.scatter(cmMeanShape.x, cmMeanShape.y, c='r')
ax1.plot([s1.shapePoints[0].x, s1.shapePoints[1].x],
         [s1.shapePoints[0].y, s1.shapePoints[1].y],
         color='r',
         ls='-')

ax2.plot([s2.shapePoints[0].x, s2.shapePoints[1].x],
         [s2.shapePoints[0].y, s2.shapePoints[1].y],
         color='r',
         lw=1,
         ls='-')

t = [[cmShape.x - cmMeanShape.x], [cmShape.y - cmMeanShape.y]]
def plotAll( axis, shape ):
    cm = ASM.centroid( shape )
    drawShape( axis, shape)
    drawCentroid( axis, cm )
    drawLineUP( axis, shape, cm )
    drawScaleSegment( axis, shape )
def plotAll( axis, shape ):
    cm = ASM.centroid( shape )
    drawShape( axis, shape)
    drawCentroid( axis, cm )
    drawEyeSegment( axis, shape )
                pointLine = True
                
            elif line is '}':
                pointLine = False
                pass
            elif pointLine:
                ptList.append( map( float, line.split(' ') ) )
            else:
                pass
    ptList
    s1 = Shape( ptList )

    f, ((ax1,ax2),(ax3,ax4)) = plt.subplots(2,2)

    ## Original shape (input)
    cmShape = ASM.centroid( s1 )
    plotAll( ax1, s1 ) 

    ############## Calc transformations ###################
    ## Translate
    t = [[ -cmShape.x ], [ -cmShape.y ]] 
    for pt in s1.shapePoints:
        pt.translate( t )
    s1.update()
    plotAll( ax2, s1)

    leftEyeIx = 33
    rightEyeIx = 28
    
    ## Scale
    d1 = s1.shapePoints[leftEyeIx].dist( s1.shapePoints[rightEyeIx] )