def genEll(rect):
    top=[]
    bottom=[]
    for i in xrange(len(rect)):
        if rect[i][1]==len(rect)-1: top.append(i)
        if rect[i][0]==0: bottom.append(i)
    score=1000000000
    for a,b in [(0,rect[0][0]),(0,rect[0][1]),(len(rect)-1,rect[len(rect)-1][0])
                ,(len(rect)-1,rect[len(rect)-1][1]), (top[0],len(rect)-1),
                (top[1],len(rect)-1),(bottom[0],0),(bottom[1],0)]:
        ellx=rect[:]
        elly=rectDiagMisc.transpose(rect)
        ellx[a]=-1
        elly[b]=-1
        tmp=evalEll(ellx,elly)
        if tmp<score:
            sellx=ellx
            selly=elly
            score=tmp
    return (score,sellx,selly)
Exemple #2
0
def genEll(rect):
    top = []
    bottom = []
    for i in range(len(rect)):
        if rect[i][1] == len(rect) - 1:
            top.append(i)
        if rect[i][0] == 0:
            bottom.append(i)
    score = 1000000000
    for a, b in [(0, rect[0][0]), (0, rect[0][1]),
                 (len(rect) - 1, rect[len(rect) - 1][0]),
                 (len(rect) - 1, rect[len(rect) - 1][1]),
                 (top[0], len(rect) - 1), (top[1], len(rect) - 1),
                 (bottom[0], 0), (bottom[1], 0)]:
        ellx = rect[:]
        elly = rectDiagMisc.transpose(rect)
        ellx[a] = -1
        elly[b] = -1
        tmp = evalEll(ellx, elly)
        if tmp < score:
            sellx = ellx
            selly = elly
            score = tmp
    return (score, sellx, selly)
def getShortEllipses(rect):########
    ellx=rect[:]
    ellx[0]=-1
    elly=rectDiagMisc.transpose(rect)
    elly[rect[0][0]]=-1
    return (ellx,elly)
Exemple #4
0
def getShortEllipses(rect):
    ellx = rect[:]
    ellx[0] = -1
    elly = rectDiagMisc.transpose(rect)
    elly[rect[0][0]] = -1
    return (ellx, elly)