コード例 #1
0
def PickLayer(total_fractions, img_rgb, show=False, axis=True):

    print('')
    print('here comes a new layer')
    print('......')
    print('please pick the layer')

    #点击获取像素点坐标
    layer_point_pos = plt.ginput(1)[0]

    print('......')
    print('picking the layer')

    #注意反过来,因为是xy坐标
    pos_xy = [int(layer_point_pos[0]), int(layer_point_pos[1])]

    pos_IJ = cp.deepcopy(pos_xy)

    #IJ形式是xy形式的颠倒
    pos_IJ.reverse()

    #所有fault的列表
    total_layers = []

    #这个点到所有fault的距离列表
    distance_total_layers = []

    #建立所有fault的列表
    #计算这个点到fault中心的远近
    for this_fraction in total_fractions:

        if isinstance(this_fraction, layer):

            #上车上车
            total_layers.append(this_fraction)

            #计算距离
            distance_this_layer = Geom.Distance(this_fraction.center, pos_xy)
            distance_total_layers.append(distance_this_layer)

    #队距离和fault对象建立索引你关系
    map_distance_total_layers = dict(zip(distance_total_layers, total_layers))

    #    print(total_faults)

    for this_layer in total_layers:

        #首先直接判断是否位于content内部
        if pos_IJ in this_layer.content:

            print('......')
            print('picking of the layer is over')

            if show:

                Dis.ShowEdge(this_layer, img_rgb, axis)

            return this_layer

    #其次如果第一下没点上,通过计算距离远近来判断
    that_fraction = map_distance_total_layers[min(distance_total_layers)]

    print('......')
    print('picking of the layer is over')

    if show:

        Dis.ShowEdge(that_fraction, img_rgb, axis)

    return that_fraction
コード例 #2
0
def PickAndGeneratePlate(total_fractions, img_rgb):

    print('')
    print('here comes a new plate')

    #建立fractions的content
    Content = []

    #建立pos总集合
    for this_fraction in total_fractions:

        Content += this_fraction.content

    #这个plate中所有的fractions
    that_fractions = []

    count = 0

    import copy

    #像素矩阵
    img_rgb_temp = copy.deepcopy(img_rgb)

    #循环呗
    while True:

        print('......')
        print('please pick the layer')

        #点击获取像素点坐标
        layer_point_pos = plt.ginput(1)[0]

        #注意反过来,因为是xy坐标
        pos_xy = [int(layer_point_pos[0]), int(layer_point_pos[1])]

        pos_IJ = copy.deepcopy(pos_xy)

        #IJ形式是xy形式的颠倒
        pos_IJ.reverse()

        #    print('......')
        #    print(pos_IJ)

        #如果点到外面,此plate的fraction提取结束
        if pos_IJ not in Content:

            print('......')
            print('layer picking of this plate is over')

            break

        #判断这个坐标合理与否
        for this_fraction in total_fractions:

            #判断他在哪
            if pos_IJ in this_fraction.content:

                #且不在已收录的fraction对象集中
                if this_fraction in that_fractions:

                    print('......')
                    print('this layer is already picked')

                    break

                if this_fraction not in that_fractions:

                    count += 1

                    print('......')
                    print('picking the layer' + '' + str(count))

                    Dis.ShowEdge(this_fraction, img_rgb_temp)

                    that_fractions.append(this_fraction)

                    break

    #显示一下呗
    plt.figure()
    plt.imshow(img_rgb_temp)

    #生成的plate对象
    that_plate = plate()

    #初始化
    that_plate.Init(that_fractions)

    return that_plate