コード例 #1
0
ファイル: utils.py プロジェクト: AIunion/Course-Face3D
def face(index=0, fit=True, N=67, K=12, interpolation=True):
    from absfile import AbsFile
    from face import Face
    import algorithms

    file = ['test_16/04371d164.abs', 'test_same/04203d350.abs', 'test_same/04203d352.abs', 'test_same/04203d354.abs', 'test_8/04316d216.abs', 'test_4/04374d193.abs'][index]
    face = Face(AbsFile(file))
    
    if interpolation:
        algorithms.repair(face)

    algorithms.smooth(face)
    algorithms.crop(face)
    algorithms.zoom(face)
    algorithms.key_points(face)
    algorithms.rotate(face)

    if fit:
        algorithms.key_points(face)
        algorithms.fit(face)

    # Extract features
    algorithms.features_histogram(face, N, K)

    return face
コード例 #2
0
ファイル: utils.py プロジェクト: bhupinderr8/3D_Triplet_Loss
def face(index=0, fit=True, N=67, K=12, interpolation=True):
    from Absfile import AbsFile
    from face import Face
    import algorithms

    file = ['test_16/04371d164.abs', 'test_same/04203d350.abs', 'test_same/04203d352.abs', 'test_same/04203d354.abs',
            'test_8/04316d216.abs', 'test_4/04374d193.abs'][index]
    face = Face(AbsFile(file))

    if interpolation:
        algorithms.repair(face)

    algorithms.smooth(face)
    algorithms.crop(face)
    algorithms.zoom(face)
    algorithms.key_points(face)
    algorithms.rotate(face)

    if fit:
        algorithms.key_points(face)
        algorithms.fit(face)

    # Extract features
    algorithms.features_histogram(face, N, K)

    return face
コード例 #3
0
ファイル: utils.py プロジェクト: bhupinderr8/3D_Triplet_Loss
def evaluate_rotate(rotations=[-5.0, -2.5, -1.0, 1, 2.5, 5.0], index=4, output_file='rotations.pdf'):
    from scipy.ndimage import interpolation
    import algorithms

    original = face(index)
    other = face(1)
    faces = []

    for rotation in rotations:
        f = face(index)

        f.abs_file.data['X'] = interpolation.rotate(f.abs_file.data['X'], rotation, mode='nearest', prefilter=False,
                                                    reshape=False)
        f.abs_file.data['Y'] = interpolation.rotate(f.abs_file.data['Y'], rotation, mode='nearest', prefilter=False,
                                                    reshape=False)
        f.abs_file.data['Z'] = interpolation.rotate(f.abs_file.data['Z'], rotation, mode='nearest', prefilter=False,
                                                    reshape=False)

        algorithms.features_histogram(f)
        faces.append(f)

    pyplot.figure()

    subplot = pyplot.subplot(1, 2 + len(rotations), 1)

    subplot.imshow(original.Z)
    subplot.title.set_text("Original")
    subplot.title.set_fontsize(10)
    subplot.xaxis.set_visible(False)
    subplot.yaxis.set_visible(False)

    for rotation, f, i in zip(rotations, faces, range(len(rotations))):
        subplot = pyplot.subplot(1, 2 + len(rotations), 2 + i)
        subplot.imshow(f.Z)
        subplot.title.set_text("%.1f deg" % rotation)
        subplot.title.set_fontsize(10)
        subplot.xaxis.set_visible(False)
        subplot.yaxis.set_visible(False)

    subplot = pyplot.subplot(1, 2 + len(rotations), len(rotations) + 2)
    subplot.imshow(other.Z)
    subplot.title.set_text("Other")
    subplot.title.set_fontsize(10)
    subplot.xaxis.set_visible(False)
    subplot.yaxis.set_visible(False)

    pyplot.savefig(output_file, format='pdf', dpi=600, orientation='landscape', bbox_inches="tight")

    return algorithms.similarity_matrix([original] + faces + [other], methods=[algorithms.distance_histogram_euclidean,
                                                                               algorithms.distance_histogram_city_block,
                                                                               algorithms.distance_histogram_correlation],
                                        normalizers=[False, False, False])
コード例 #4
0
ファイル: utils.py プロジェクト: AIunion/Course-Face3D
def evaluate_rotate(rotations=[-5.0, -2.5, -1.0, 1, 2.5, 5.0], index=4, output_file='rotations.pdf'):
    from scipy.ndimage import interpolation
    import algorithms

    original = face(index)
    other = face(1)
    faces = []

    for rotation in rotations:
        f = face(index)

        f.abs_file.data['X'] = interpolation.rotate(f.abs_file.data['X'], rotation, mode='nearest', prefilter=False, reshape=False)
        f.abs_file.data['Y'] = interpolation.rotate(f.abs_file.data['Y'], rotation, mode='nearest', prefilter=False, reshape=False)
        f.abs_file.data['Z'] = interpolation.rotate(f.abs_file.data['Z'], rotation, mode='nearest', prefilter=False, reshape=False)

        algorithms.features_histogram(f)
        faces.append(f)

    pyplot.figure()

    subplot = pyplot.subplot(1, 2+len(rotations), 1)

    subplot.imshow(original.Z)
    subplot.title.set_text("Original")
    subplot.title.set_fontsize(10)
    subplot.xaxis.set_visible(False)
    subplot.yaxis.set_visible(False)

    for rotation, f, i in zip(rotations, faces, range(len(rotations))):
        subplot = pyplot.subplot(1, 2+len(rotations), 2 + i)
        subplot.imshow(f.Z)
        subplot.title.set_text("%.1f deg" % rotation)
        subplot.title.set_fontsize(10)
        subplot.xaxis.set_visible(False)
        subplot.yaxis.set_visible(False)

    subplot = pyplot.subplot(1, 2+len(rotations), len(rotations) + 2)
    subplot.imshow(other.Z)
    subplot.title.set_text("Other")
    subplot.title.set_fontsize(10)
    subplot.xaxis.set_visible(False)
    subplot.yaxis.set_visible(False)

    pyplot.savefig(output_file, format='pdf', dpi=600, orientation='landscape', bbox_inches="tight")

    return algorithms.similarity_matrix([original] + faces + [other], methods=[algorithms.distance_histogram_euclidean, algorithms.distance_histogram_city_block, algorithms.distance_histogram_correlation], normalizers=[False, False, False])