예제 #1
0
파일: ft.py 프로젝트: AAAyag/FASText
 def saveKeypints(self, keypoints, outFile):
     
     keypointSegments = {}
     for i in range(keypoints.shape[0]):
         strokes = ftext.getKeypointStrokes(i)
         keypointSegments[i] = strokes
     
     np.savez(outFile, keypoints=keypoints, keypointSegments = keypointSegments)    
예제 #2
0
파일: ft.py 프로젝트: Flipajs/FASText
 def saveKeypints(self, keypoints, outFile):
     
     keypointSegments = {}
     for i in range(keypoints.shape[0]):
         strokes = ftext.getKeypointStrokes(i)
         keypointSegments[i] = strokes
     
     np.savez(outFile, keypoints=keypoints, keypointSegments = keypointSegments)    
예제 #3
0
파일: vis.py 프로젝트: zgsxwsdxg/FASText
def drawFast(point, ax, img, threshold, idx):
    #s = 2000
    point[0] = round(point[0])
    point[1] = round(point[1])
    global added_objects
    for k in range(len(added_objects)):
        plotObject = added_objects[k]
        if type(plotObject) is matplotlib.collections.PathCollection:
            plotObject.remove()
        elif type(plotObject) is matplotlib.text.Text:
            plotObject.remove()
        elif type(plotObject) is Wedge:
            plotObject.remove()
        else:
            plotObject[0].remove()
    added_objects = []

    if idx > -1:
        strokes = ftext.getKeypointStrokes(idx)
        if strokes.shape[0] > 0:
            added_objects.append(
                ax.scatter(strokes[:, 0], strokes[:, 1], c='yellow', s=s))

    global last_selection
    pointmarkers = np.asarray(fastAll)
    pointmarkers[:, 0] += int(round(point[0]))
    pointmarkers[:, 1] += int(round(point[1]))
    pointmarkers12 = np.asarray(fastOffsets12)
    pointmarkers12[:, 0] += int(round(point[0]))
    pointmarkers12[:, 1] += int(round(point[1]))
    if len(point) > 4:
        print('point: {0} - {1} - {2} - {3}'.format(
            point, img[round(point[1]), round(point[0])], img[round(point[6]),
                                                              round(point[5])],
            img[round(point[8]), round(point[7])]))
    else:
        print('point: {0} - {1}'.format(point, img[round(point[1]),
                                                   round(point[0])]))

    np.round(pointmarkers, 0, pointmarkers)
    if len(img.shape) == 3:

        diff = (img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(
            np.int) - img[point[1], point[0]]
        if len(point) > 10:
            diff = diff[:, point[11]]
        else:
            diff = diff[:, 0]
        '''
        diff = np.zeros((pointmarkers12.shape[0]), dtype=np.int)
        for i in range(pointmarkers12.shape[0]):
            diff[i] = cdist(img[round(point[1]), round(point[0])], img[pointmarkers12[i, 1], pointmarkers12[i, 0]])
        print(diff)
        '''
        masksame = diff < threshold
        maskDiff = np.invert(masksame)
        added_objects.append(
            ax.scatter(pointmarkers12[masksame, 0],
                       pointmarkers12[masksame, 1],
                       c='black',
                       s=s))
        added_objects.append(
            ax.scatter(pointmarkers12[maskDiff, 0],
                       pointmarkers12[maskDiff, 1],
                       c='white',
                       s=s))
        added_objects.append(
            ax.scatter([round(point[0])], [round(point[1])], c='black'))

        if len(point) > 4:
            #added_objects.append(  )
            added_objects.append(
                ax.plot([point[0], point[7]], [point[1], point[8]], 'r-'))
            #added_objects.append( ax.plot([point[0], point[5]], [point[1], point[6]], 'g-') )

        if point[10] == 0:
            last_selection = (
                point,
                img[round(point[1]), round(point[0])][0] + threshold * 4,
                greater_then_b)
        else:
            last_selection = (point, point[3], greater_then_b)
        return
    diff = (img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(
        np.int) - img[point[1], point[0]]
    print((img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(np.int))
    if len(point) < 3:
        added_objects.append(
            ax.scatter([round(point[0])], [round(point[1])], c='black'))
        maxDiff = np.argmax(np.abs(diff))
        minDiff = np.argmin(np.abs(diff))
        point = (point[0], point[1], point[0], point[1], 0,
                 pointmarkers12[maxDiff, 0], pointmarkers12[maxDiff, 1],
                 pointmarkers12[minDiff, 0], pointmarkers12[minDiff, 1])
        print(diff)

    added_objects.append(
        ax.plot([point[0], point[7]], [point[1], point[8]], 'r-'))
    added_objects.append(
        ax.plot([point[0], pointmarkers12[0, 0]],
                [point[1], pointmarkers12[0, 1]], 'r-'))
    #added_objects.append( ax.plot([point[0], pointmarkers12[0, 0]], [point[1], pointmarkers12[0, 1]], 'r-') )
    #ax.plot([point[0], point[7]], [point[1], point[8]], 'r-')
    #added_objects.append( ax.plot([point[0], point[5]], [point[1], point[6]], 'g-') )
    #added_objects.append( ax.plot([point[0], pointmarkers12[7, 0]], [point[1], pointmarkers12[7, 1]], 'b-') )
    #added_objects.append( ax.plot([point[0], pointmarkers12[11, 0]], [point[1], pointmarkers12[11, 1]], 'b-') )

    if img[point[8], point[7]] <= img[point[6], point[5]]:
        print(diff)
        masksame = diff <= threshold
        maskDiff = np.invert(masksame)
        if showFast16:
            added_objects.append(
                ax.scatter(pointmarkers[masksame, 0],
                           pointmarkers[masksame, 1],
                           c='black'))
            added_objects.append(
                ax.scatter(pointmarkers[maskDiff, 0],
                           pointmarkers[maskDiff, 1],
                           c='white'))
        otsu_t = otsu_threshold(img, point, pointmarkers, negative=True)
        print('otsu: {0}'.format(otsu_t))
        print('otsur: {0}'.format(point[3] + img[point[1], point[0]]))
        last_selection = (point, otsu_t, lower_then)

        if True:
            pointmarkers12 = np.asarray(fastOffsets12)
            pointmarkers12[:, 0] += int(round(point[0]))
            pointmarkers12[:, 1] += int(round(point[1]))
            '''
            pointc12 = np.asarray(fastCorners12)
            pointc12[:, 0] += round(point[0])
            pointc12[:, 1] += round(point[1])
            '''

            added_objects.append(
                ax.scatter([point[0]], [point[1]], c='red', s=s))

            diff12 = (img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(
                np.int) - (img[point[1], point[0]])).astype(np.int)
            #diffc12 = ( img[pointc12[:, 1], pointc12[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int)
            print('diff12: {0} ({1})'.format(diff12, threshold))
            masksame = diff12 <= threshold
            #masksamec = diffc12 <= threshold
            added_objects.append(
                ax.scatter(pointmarkers12[masksame, 0],
                           pointmarkers12[masksame, 1],
                           c='red',
                           s=s))
            #added_objects.append( ax.scatter(pointc12[masksamec,0], pointc12[masksamec,1],c='red', s=s ) )
            masksame = np.invert(masksame)
            #masksamec = np.invert(masksamec)
            added_objects.append(
                ax.scatter(pointmarkers12[masksame, 0],
                           pointmarkers12[masksame, 1],
                           c='white',
                           s=s))

            #added_objects.append( ax.scatter(pointc12[masksamec,0], pointc12[masksamec,1],c='white', s=s ) )
            xoffset = -0.05
            for i in range(pointmarkers12.shape[0]):
                if i > 9:
                    xoffset = -0.1
                added_objects.append(
                    ax.text(pointmarkers12[i][0] + xoffset,
                            pointmarkers12[i][1] + 0.05, '{0}'.format(i)))

            #added_objects.append(ax.text(pointc12[0][0] -0.05, pointc12[0][1] + 0.05, '{0}\''.format(2)))
            #added_objects.append(ax.text(pointc12[1][0] -0.05, pointc12[1][1] + 0.05, '{0}\''.format(5)))
            #added_objects.append(ax.text(pointc12[2][0] -0.05, pointc12[2][1] + 0.05, '{0}\''.format(8)))
            #added_objects.append(ax.text(pointc12[3][0] -0.1, pointc12[3][1] + 0.05, '{0}\''.format(11)))

            #w1 = Wedge((round(point[0]), round(point[1])), 2.6, 145, 72, fc='none', ec='green')
            #added_objects.append(ax.add_artist(w1))
            #added_objects.append(ax.text(pointmarkers12[6][0] -0.5, pointmarkers12[6][1] - 0.8, '$P_b$'.format(11), fontsize=24, color='green'))
            '''
            w1 = Wedge((round(point[0]), round(point[1])), 2.6, 320, 50, fc='none', ec='green')
            added_objects.append(ax.add_artist(w1))
            added_objects.append(ax.text(pointmarkers12[2][0] + 0.8, pointmarkers12[2][1] + 0.5, '$P_b$'.format(11), fontsize=24, color='green'))
            
            w1 = Wedge((round(point[0]), round(point[1])), 2.6, 105, 255, fc='none', ec='green')
            added_objects.append(ax.add_artist(w1))
            added_objects.append(ax.text(pointmarkers12[8][0] - 0.8, pointmarkers12[8][1] - 0.5, '$P^\prime_b$'.format(11), fontsize=24, color='green'))
            '''

            if showFast8 and True:
                pointmarkers8 = np.asarray(fastOffsets8)
                pointmarkers8[:, 0] += int(round(point[0]))
                pointmarkers8[:, 1] += int(round(point[1]))
                diff8 = (img[pointmarkers8[:, 1], pointmarkers8[:, 0]].astype(
                    np.int) - (img[point[1], point[0]])).astype(np.int)
                print('diff8: {0} ({1})'.format(diff8, threshold))
                masksame = diff8 <= threshold
                if (point[1] - point[6]) == 2:
                    if (point[0] - point[5]) == 0:
                        added_objects.append(
                            ax.scatter(pointmarkers8[0, 0],
                                       pointmarkers8[0, 1],
                                       c='magenta',
                                       s=s))
                        added_objects.append(
                            ax.scatter(pointmarkers8[7, 0],
                                       pointmarkers8[7, 1],
                                       c='magenta',
                                       s=s))
                if (point[1] - point[6]) == -1:
                    if (point[0] - point[5]) == -2:
                        added_objects.append(
                            ax.scatter(pointmarkers8[2, 0],
                                       pointmarkers8[2, 1],
                                       c='magenta',
                                       s=s))
                        added_objects.append(
                            ax.scatter(pointmarkers8[3, 0],
                                       pointmarkers8[3, 1],
                                       c='magenta',
                                       s=s))

                        added_objects.append(
                            ax.scatter(pointmarkers8[7, 0],
                                       pointmarkers8[7, 1],
                                       c='magenta',
                                       s=s))
                        added_objects.append(
                            ax.scatter(pointmarkers8[0, 0],
                                       pointmarkers8[0, 1],
                                       c='magenta',
                                       s=s))
                        #added_objects.append( ax.scatter(pointmarkers8[7,0], pointmarkers8[7,1],c='red' ) )
                #added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='black' ) )
                #masksame = np.invert(masksame)
                added_objects.append(
                    ax.scatter(pointmarkers8[masksame, 0],
                               pointmarkers8[masksame, 1],
                               c='magenta',
                               s=s))
            '''
            pointmarkers12 = np.asarray(fastOffsetsC)
            pointmarkers12[:, 0] += round(point[0])
            pointmarkers12[:, 1] += round(point[1])
            diff12 = ( img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int) 
            masksame = diff12 <= threshold
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='#000044' ) )
            masksame = np.invert(masksame)
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='#ffffaa' ) )
            '''

    else:
        vt = img[round(point[1]), round(point[0])] - threshold
        diff = img[point[1], point[0]] - (
            img[pointmarkers[:, 1], pointmarkers[:, 0]]).astype(np.int)
        print(diff)
        masksame = img[pointmarkers[:, 1], pointmarkers[:, 0]] >= vt
        maskDiff = np.invert(masksame)
        if showFast16:
            added_objects.append(
                ax.scatter(pointmarkers[masksame, 0],
                           pointmarkers[masksame, 1],
                           c='black'))
            added_objects.append(
                ax.scatter(pointmarkers[maskDiff, 0],
                           pointmarkers[maskDiff, 1],
                           c='white'))
        otsu_t = otsu_threshold(img, point, pointmarkers, negative=False)
        print('otsu: {0}'.format(otsu_t))
        print('otsur: {0}'.format(img[point[1], point[0]] - point[3]))
        last_selection = (point, otsu_t, greater_then)

        if True:
            pointmarkers12 = np.asarray(fastOffsets12)
            pointmarkers12[:, 0] += int(round(point[0]))
            pointmarkers12[:, 1] += int(round(point[1]))

            diff12 = ((img[point[1], point[0]]) -
                      img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(
                          np.int)).astype(np.int)
            print('diff12: {0}'.format(diff12))
            masksame = diff12 <= threshold
            added_objects.append(
                ax.scatter(pointmarkers12[masksame, 0],
                           pointmarkers12[masksame, 1],
                           c='red'))
            masksame = np.invert(masksame)
            added_objects.append(
                ax.scatter(pointmarkers12[masksame, 0],
                           pointmarkers12[masksame, 1],
                           c='white'))

            if showFast8:
                pointmarkers8 = np.asarray(fastOffsets8)
                pointmarkers8[:, 0] += int(round(point[0]))
                pointmarkers8[:, 1] += int(round(point[1]))
                diff8 = ((img[point[1], point[0]]) -
                         img[pointmarkers8[:, 1], pointmarkers8[:, 0]].astype(
                             np.int)).astype(np.int)
                print('diff8: {0} ({1})'.format(diff8, threshold))
                masksame = diff8 <= threshold
                added_objects.append(
                    ax.scatter(pointmarkers8[masksame, 0],
                               pointmarkers8[masksame, 1],
                               c='black'))
                #masksame = np.invert(masksame)
                #added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='#aaffff' ) )
            '''
예제 #4
0
파일: vis.py 프로젝트: AAAyag/FASText
def drawFast(point, ax, img, threshold, idx):
    #s = 2000
    point[0] = round(point[0])
    point[1] = round(point[1])
    global added_objects
    for k in range( len(added_objects ) ) :
        plotObject =  added_objects[k]
        if type(plotObject) is matplotlib.collections.PathCollection:
            plotObject.remove()
        elif type(plotObject) is matplotlib.text.Text:
            plotObject.remove()
        elif type(plotObject) is Wedge:
            plotObject.remove()
        else:
            plotObject[0].remove()
    added_objects = []
    
    if idx > -1:
        strokes = ftext.getKeypointStrokes(idx)
        if strokes.shape[0] > 0:
            added_objects.append( ax.scatter(strokes[:,0], strokes[:,1], c='yellow', s=s) )
    
    global last_selection
    pointmarkers = np.asarray(fastAll)
    pointmarkers[:, 0] += int(round(point[0]))
    pointmarkers[:, 1] += int(round(point[1]))
    pointmarkers12 = np.asarray(fastOffsets12)
    pointmarkers12[:, 0] += int(round(point[0]))
    pointmarkers12[:, 1] += int(round(point[1]))
    if len(point) > 4:
        print('point: {0} - {1} - {2} - {3}'.format(point, img[round(point[1]), round(point[0])], img[round(point[6]), round(point[5])], img[round(point[8]), round(point[7])]))
    else:
        print('point: {0} - {1}'.format(point, img[round(point[1]), round(point[0])]))
    
    np.round(pointmarkers, 0, pointmarkers)
    if len(img.shape) == 3:
        
        diff = (img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(np.int) - img[point[1], point[0]]
        if len(point) > 10:
            diff = diff[:, point[11]]
        else:
            diff = diff[:, 0]
        '''
        diff = np.zeros((pointmarkers12.shape[0]), dtype=np.int)
        for i in range(pointmarkers12.shape[0]):
            diff[i] = cdist(img[round(point[1]), round(point[0])], img[pointmarkers12[i, 1], pointmarkers12[i, 0]])
        print(diff)
        '''    
        masksame = diff < threshold
        maskDiff = np.invert(masksame)
        added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1], c='black', s=s) )
        added_objects.append( ax.scatter(pointmarkers12[maskDiff,0], pointmarkers12[maskDiff,1], c='white', s=s) )
        added_objects.append( ax.scatter([round(point[0])], [round(point[1])], c='black') )
        
        if len(point) > 4:
            #added_objects.append(  )
            added_objects.append(ax.plot([point[0], point[7]], [point[1], point[8]], 'r-'))
            #added_objects.append( ax.plot([point[0], point[5]], [point[1], point[6]], 'g-') )
        
        if point[10] == 0:   
            last_selection = (point, img[round(point[1]), round(point[0])][0] + threshold * 4, greater_then_b)
        else :
            last_selection = (point, point[3], greater_then_b)
        return
    diff = (img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(np.int) - img[point[1], point[0]]
    print((img[pointmarkers12[:, 1], pointmarkers12[:, 0]]).astype(np.int))
    if len(point) < 3:
        added_objects.append( ax.scatter( [round(point[0])], [round(point[1])], c='black' ) )
        maxDiff = np.argmax(np.abs(diff))
        minDiff = np.argmin(np.abs(diff))
        point = ( point[0], point[1], point[0], point[1], 0, pointmarkers12[maxDiff, 0], pointmarkers12[maxDiff, 1], pointmarkers12[minDiff, 0], pointmarkers12[minDiff, 1])
        print(diff)    
    
    added_objects.append( ax.plot([point[0], point[7]], [point[1], point[8]], 'r-') )
    added_objects.append( ax.plot([point[0], pointmarkers12[0, 0]], [point[1], pointmarkers12[0, 1]], 'r-') )
    #added_objects.append( ax.plot([point[0], pointmarkers12[0, 0]], [point[1], pointmarkers12[0, 1]], 'r-') ) 
    #ax.plot([point[0], point[7]], [point[1], point[8]], 'r-')
    #added_objects.append( ax.plot([point[0], point[5]], [point[1], point[6]], 'g-') )
    #added_objects.append( ax.plot([point[0], pointmarkers12[7, 0]], [point[1], pointmarkers12[7, 1]], 'b-') )
    #added_objects.append( ax.plot([point[0], pointmarkers12[11, 0]], [point[1], pointmarkers12[11, 1]], 'b-') )
    
    if img[point[8], point[7]] <= img[point[6], point[5]]:
        print(diff)
        masksame = diff <= threshold
        maskDiff = np.invert(masksame)
        if showFast16:
            added_objects.append( ax.scatter(pointmarkers[masksame,0], pointmarkers[masksame,1], c='black') )
            added_objects.append( ax.scatter(pointmarkers[maskDiff,0], pointmarkers[maskDiff,1], c='white') )
        otsu_t = otsu_threshold(img, point, pointmarkers, negative=True)
        print('otsu: {0}'.format(otsu_t))
        print('otsur: {0}'.format( point[3] +  img[point[1], point[0]] ))
        last_selection = (point, otsu_t, lower_then)
        
        if True:
            pointmarkers12 = np.asarray(fastOffsets12)
            pointmarkers12[:, 0] += int(round(point[0]))
            pointmarkers12[:, 1] += int(round(point[1]))
            
            '''
            pointc12 = np.asarray(fastCorners12)
            pointc12[:, 0] += round(point[0])
            pointc12[:, 1] += round(point[1])
            '''
            
            added_objects.append( ax.scatter([point[0]], [point[1]],c='red', s=s ) )
            
            diff12 = ( img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int)
            #diffc12 = ( img[pointc12[:, 1], pointc12[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int)
            print('diff12: {0} ({1})'.format(diff12, threshold)) 
            masksame = diff12 <= threshold
            #masksamec = diffc12 <= threshold
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='red', s=s ) )
            #added_objects.append( ax.scatter(pointc12[masksamec,0], pointc12[masksamec,1],c='red', s=s ) )
            masksame = np.invert(masksame)
            #masksamec = np.invert(masksamec)
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='white', s=s ) )
            
            #added_objects.append( ax.scatter(pointc12[masksamec,0], pointc12[masksamec,1],c='white', s=s ) )
            xoffset = -0.05
            for i in range( pointmarkers12.shape[0]):
                if i > 9:
                    xoffset = -0.1
                added_objects.append(ax.text(pointmarkers12[i][0] + xoffset, pointmarkers12[i][1] + 0.05, '{0}'.format(i)))
            
            #added_objects.append(ax.text(pointc12[0][0] -0.05, pointc12[0][1] + 0.05, '{0}\''.format(2)))
            #added_objects.append(ax.text(pointc12[1][0] -0.05, pointc12[1][1] + 0.05, '{0}\''.format(5)))
            #added_objects.append(ax.text(pointc12[2][0] -0.05, pointc12[2][1] + 0.05, '{0}\''.format(8)))
            #added_objects.append(ax.text(pointc12[3][0] -0.1, pointc12[3][1] + 0.05, '{0}\''.format(11)))
            
            #w1 = Wedge((round(point[0]), round(point[1])), 2.6, 145, 72, fc='none', ec='green')
            #added_objects.append(ax.add_artist(w1))
            #added_objects.append(ax.text(pointmarkers12[6][0] -0.5, pointmarkers12[6][1] - 0.8, '$P_b$'.format(11), fontsize=24, color='green'))
            
            '''
            w1 = Wedge((round(point[0]), round(point[1])), 2.6, 320, 50, fc='none', ec='green')
            added_objects.append(ax.add_artist(w1))
            added_objects.append(ax.text(pointmarkers12[2][0] + 0.8, pointmarkers12[2][1] + 0.5, '$P_b$'.format(11), fontsize=24, color='green'))
            
            w1 = Wedge((round(point[0]), round(point[1])), 2.6, 105, 255, fc='none', ec='green')
            added_objects.append(ax.add_artist(w1))
            added_objects.append(ax.text(pointmarkers12[8][0] - 0.8, pointmarkers12[8][1] - 0.5, '$P^\prime_b$'.format(11), fontsize=24, color='green'))
            '''
            
            
            if showFast8 and True:
                pointmarkers8 = np.asarray(fastOffsets8)
                pointmarkers8[:, 0] += int(round(point[0]))
                pointmarkers8[:, 1] += int(round(point[1]))
                diff8 = ( img[pointmarkers8[:, 1], pointmarkers8[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int)
                print('diff8: {0} ({1})'.format(diff8, threshold)) 
                masksame = diff8 <= threshold
                if (point[1] - point[6]) == 2:
                    if ( point[0] - point[5] ) == 0:
                        added_objects.append( ax.scatter(pointmarkers8[0,0], pointmarkers8[0,1],c='magenta', s=s ) )
                        added_objects.append( ax.scatter(pointmarkers8[7,0], pointmarkers8[7,1],c='magenta', s=s ) )
                if (point[1] - point[6]) == -1:
                    if ( point[0] - point[5] ) == -2:
                        added_objects.append( ax.scatter(pointmarkers8[2,0], pointmarkers8[2,1],c='magenta', s=s ) )
                        added_objects.append( ax.scatter(pointmarkers8[3,0], pointmarkers8[3,1],c='magenta', s=s ) )
                        
                        added_objects.append( ax.scatter(pointmarkers8[7,0], pointmarkers8[7,1],c='magenta', s=s ) )
                        added_objects.append( ax.scatter(pointmarkers8[0,0], pointmarkers8[0,1],c='magenta', s=s ) )
                        #added_objects.append( ax.scatter(pointmarkers8[7,0], pointmarkers8[7,1],c='red' ) )
                #added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='black' ) )
                #masksame = np.invert(masksame)
                added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='magenta', s=s ) )
            '''
            pointmarkers12 = np.asarray(fastOffsetsC)
            pointmarkers12[:, 0] += round(point[0])
            pointmarkers12[:, 1] += round(point[1])
            diff12 = ( img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(np.int) - (img[point[1], point[0]])).astype(np.int) 
            masksame = diff12 <= threshold
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='#000044' ) )
            masksame = np.invert(masksame)
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='#ffffaa' ) )
            '''
            
            
            
        
    else:
        vt = img[round(point[1]), round(point[0])] - threshold
        diff = img[point[1], point[0]] - (img[pointmarkers[:, 1], pointmarkers[:, 0]]).astype(np.int)  
        print(diff)
        masksame = img[pointmarkers[:, 1], pointmarkers[:, 0]] >= vt
        maskDiff = np.invert(masksame)
        if showFast16:
            added_objects.append( ax.scatter(pointmarkers[masksame,0], pointmarkers[masksame,1], c='black') )
            added_objects.append( ax.scatter(pointmarkers[maskDiff,0], pointmarkers[maskDiff,1], c='white') )
        otsu_t = otsu_threshold(img, point, pointmarkers, negative=False)
        print('otsu: {0}'.format(otsu_t))
        print('otsur: {0}'.format( img[point[1], point[0]] - point[3]  ))
        last_selection = (point, otsu_t, greater_then)
        
        if True:
            pointmarkers12 = np.asarray(fastOffsets12)
            pointmarkers12[:, 0] += int(round(point[0]))
            pointmarkers12[:, 1] += int(round(point[1]))
            
            diff12 = ((img[point[1], point[0]]) - img[pointmarkers12[:, 1], pointmarkers12[:, 0]].astype(np.int)).astype(np.int) 
            print('diff12: {0}'.format(diff12))
            masksame = diff12 <= threshold
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='red' ) )
            masksame = np.invert(masksame)
            added_objects.append( ax.scatter(pointmarkers12[masksame,0], pointmarkers12[masksame,1],c='white' ) )
            
            if showFast8:
                pointmarkers8 = np.asarray(fastOffsets8)
                pointmarkers8[:, 0] += int(round(point[0]))
                pointmarkers8[:, 1] += int(round(point[1]))
                diff8 = ( (img[point[1], point[0]]) - img[pointmarkers8[:, 1], pointmarkers8[:, 0]].astype(np.int)).astype(np.int)
                print('diff8: {0} ({1})'.format(diff8, threshold)) 
                masksame = diff8 <= threshold
                added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='black' ) )
                #masksame = np.invert(masksame)
                #added_objects.append( ax.scatter(pointmarkers8[masksame,0], pointmarkers8[masksame,1],c='#aaffff' ) )
            
            '''