Ejemplo n.º 1
0
def findMinimaMaxima(dogstack,mainImage,octaveNumber,tracker):
    #mult = octaveNumber
    count=0
    for mid_window_h in range(0,(getShape(dogstack[1])[0] - 2)):
        for mid_window_w in range(0,(getShape(dogstack[1])[1] - 2)):
            middogslice = sliceMat(dogstack[1],mid_window_h,(mid_window_h+3),mid_window_w,mid_window_w+3)
            upperdogslice = sliceMat(dogstack[0],mid_window_h,(mid_window_h+3),mid_window_w,mid_window_w+3)
            lowerdogslice = sliceMat(dogstack[2],mid_window_h,(mid_window_h+3),mid_window_w,mid_window_w+3)
            center = middogslice[1][1]
            h_coords = mid_window_h+1
            w_coords = mid_window_w+1
            #print(getShape(middogslice))
            if(getShape(upperdogslice)[0] == 3 and getShape(upperdogslice)[1] == 3):
                if(isMinima(middogslice,center,True) and isMinima(upperdogslice,center,False) and isMinima(lowerdogslice,center,False)):
                    print("Keypoint Minima!");
                    print(mid_window_h,mid_window_w)
                    mainImage[h_coords*octaveNumber][w_coords*octaveNumber] = 255
                    count+=1
                    tracker.append([h_coords*octaveNumber,w_coords*octaveNumber])
                elif(isMaxima(middogslice,center,True) and isMaxima(upperdogslice,center,False) and isMaxima(lowerdogslice,center,False)):
                    print("Keypoint Maxima!");
                    print(mid_window_h,mid_window_w)
                    mainImage[h_coords*octaveNumber][w_coords*octaveNumber] = 255
                    count+=1
                    tracker.append([h_coords*octaveNumber,w_coords*octaveNumber])             
    print(count)
    return mainImage
Ejemplo n.º 2
0
def windowMult(matA,matB):
    matResult = 0
    for x_iter in range(0,getShape(matA)[0]):
        for y_iter in range(0,getShape(matA)[0]):
            if not len(matA) or not len(matB) == 0:
                matResult += matA[x_iter][y_iter] * matB[x_iter][y_iter]
    return matResult
Ejemplo n.º 3
0
def invertMat(matA):
    skeleton=[[] for i in range(0,getShape(matA)[0])]
    i = 0
    for window_h in range(getShape(matA)[0]-1,-1,-1):
        for window_w in range(getShape(matA)[1]-1,-1,-1):
            skeleton[i].append(matA[window_h][window_w])
        i += 1
    return skeleton
Ejemplo n.º 4
0
def sobel(matA,sobel_op):
    matA = padMat(matA,3)
    resultImage = [[]for i in range(600)]
    for window_h in range(0,getShape(matA)[0]-2):
        for window_w in range(0,getShape(matA)[1]-2):
            window = sliceMat(matA,window_h,window_h+3,window_w,window_w+3)
            opResult = windowMult(sobel_op,window)
            resultImage[window_h].append(opResult)
    resultImage = normImage(resultImage)
    return resultImage
Ejemplo n.º 5
0
def differenceGaussians(matA,matB):
    if(getShape(matA) == getShape(matB)):
        skeleton = [[] for i in range(0,getShape(matA)[0])]
        for window_h in range(0,getShape(matA)[0]):
            for window_w in range(0,getShape(matB)[1]):
                difference = matB[window_h][window_w] - matA[window_h][window_w]
                skeleton[window_h].append(difference)
        return skeleton
    else:
        return -1
Ejemplo n.º 6
0
def genOctave(matA):
    #print(getShape(matA));
    skeleton = [[] for i in range(0,(int)(getShape(matA)[0]/2))]
    for window_h in range(0,getShape(matA)[0]):
        for window_w in range(0,getShape(matA)[1]):
            if(window_h % 2 ==0 and window_w % 2 == 0):
                sampleIndex = (int)(window_h / 2)
                if(sampleIndex < (int)(getShape(matA)[0]/2)):
                    skeleton[sampleIndex].append(matA[window_h][window_w])
    return(skeleton)
Ejemplo n.º 7
0
def padMat(matA,sizeWindow):
    space = (int)(sizeWindow/2)
    skeleton=[[] for i in range(0,(getShape(matA)[0]+(space*2)))]
    for window_h in range(0,getShape(matA)[0]+(space*2)):
        for window_w in range(0,getShape(matA)[1]+(space*2)):
            if(window_h >= 0 and window_h <= (space-1)) or (window_h >getShape(matA)[0]+(space-1) and window_h <= getShape(matA)[0]+((space*2)-1) ):
                
                skeleton[window_h].append(0)
            else:
                if(window_w >= 0 and window_w <= (space-1)) or (window_w > getShape(matA)[1]+(space-1) and window_w <= getShape(matA)[1]+((space*2)-1)):
                    #print("wpad")
                    #print(window_w)
                    skeleton[window_h].append(0)
                else:
                    skeleton[window_h].append(matA[window_h-(3)][window_w-(3)])
    return skeleton
Ejemplo n.º 8
0
def convolve(windowFilter,matA):
    from functions import invertMat,getShape,sliceMat,padMat,windowMult
    windowFilter = invertMat(windowFilter)
    matA = padMat(matA,getShape(windowFilter)[0])
    #print(getShape(matA))
    resultImage = [[] for i in range(0,(getShape(matA)[0] - (getShape(windowFilter)[0] - 1)))]
    for window_h in range(0,getShape(matA)[0]-(getShape(windowFilter)[0] - 1)):
        for window_w in range(0,getShape(matA)[1]-(getShape(windowFilter)[1] - 1) ):
            window = sliceMat(matA,window_h,window_h+getShape(windowFilter)[0],window_w,window_w+getShape(windowFilter)[0])
            #print(getShape(window))
            opResult = windowMult(windowFilter,window)
            resultImage[window_h].append(opResult)
    return resultImage
Ejemplo n.º 9
0
def combineEdges(matA,matB):
    from math import sqrt
    maxValue = 0
    skeleton = [[] for i in range(0,getShape(matA)[0])]
    for window_h in range(0,getShape(matA)[0]):
        for window_w in range(0,getShape(matA)[1]):
            skeleton[window_h].append(sqrt(matA[window_h][window_w]**2 + matB[window_h][window_w]**2))
    for window_h in range(0,getShape(skeleton)[0]):
        for window_w in range(0,getShape(skeleton)[1]):
            if(skeleton[window_h][window_w]>maxValue): maxValue = skeleton[window_h][window_w]
    for window_h in range(0,getShape(skeleton)[0]):
        for window_w in range(0,getShape(skeleton)[1]):
            skeleton[window_h][window_w] = skeleton[window_h][window_w]/maxValue
    return skeleton
Ejemplo n.º 10
0
def normImage(matA):
    from functions import getShape
    skeleton=[[] for i in range(0,getShape(matA)[0])]
    maxValue = 0
    absValue = 0
    for window_h in range(0,getShape(matA)[0]):
        for window_w in range(0,getShape(matA)[1]):
            absValue = abs(matA[window_h][window_w])
            skeleton[window_h].append(absValue)     
            if(maxValue < absValue) : maxValue = absValue
    returnMat=[[] for i in range(0,getShape(matA)[0])]
    for window_h in range(0,getShape(matA)[0]):
        for window_w in range(0,getShape(matA)[1]):
            returnMat[window_h].append(skeleton[window_h][window_w] / maxValue)
    return returnMat
Ejemplo n.º 11
0
def summession2d(matA):
    summession = 0
    for window_h in range(0,getShape(matA)[0]):
        for window_w in range(0,getShape(matA)[1]):
            summession += matA[window_h][window_w]
    return summession