File size: 2,437 Bytes
3dbf98e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from pathlib import Path


def print_image(image_name, landmarks_x, landmarks_y):

    my_file = Path(image_name)
    if my_file.is_file():
        im = plt.imread(image_name)
        implot = plt.imshow(im)

        plt.scatter(x=landmarks_x[:], y=landmarks_y[:], c='r', s=10)
        plt.show()


def print_image_arr_heat(k, image, print_single=False):
    import numpy as np
    for i in range(image.shape[2]):
        img = np.sum(image, axis=2)
        if print_single:
            plt.figure()
            plt.imshow(image[:, :, i])
            # implot = plt.imshow(image[:, :, i])
            plt.axis('off')
            plt.savefig('single_heat_' + str(i+(k*100)) + '.png', bbox_inches='tight')
            plt.clf()

    plt.figure()
    plt.imshow(img, vmin=0, vmax=1)
    plt.axis('off')
    plt.savefig('heat_' + str(k) + '.png', bbox_inches='tight')
    plt.clf()


def print_image_arr(k, image, landmarks_x, landmarks_y):
    plt.figure()
    plt.imshow(image)
    implot = plt.imshow(image)

    # for i in range(len(landmarks_x)):
    #     plt.text(landmarks_x[i], landmarks_y[i], str(i), fontsize=12, c='red',
    #              horizontalalignment='center', verticalalignment='center',
    #              bbox={'facecolor': 'blue', 'alpha': 0.3, 'pad': 0.0})

    plt.scatter(x=landmarks_x[:], y=landmarks_y[:], c='#000000', s=15)
    plt.scatter(x=landmarks_x[:], y=landmarks_y[:], c='#fddb3a', s=8)
    # plt.axis('off')
    plt.savefig('z_' + str(k) + '.png', bbox_inches='tight')
    # plt.show()
    plt.clf()


def print_image_arr_2(k, image, landmarks_x, landmarks_y, xs, ys):
    plt.figure()
    plt.imshow(image)
    implot = plt.imshow(image)

    # plt.scatter(x=landmarks_x[:], y=landmarks_y[:], c='b', s=5)
    # for i in range(68):
    #     plt.annotate(str(i), (landmarks_x[i], landmarks_y[i]), fontsize=6)

    plt.scatter(x=landmarks_x[:], y=landmarks_y[:], c='b', s=5)
    plt.scatter(x=xs, y=ys, c='r', s=5)
    plt.savefig('sss'+str(k)+'.png')
    # plt.show()
    plt.clf()


def print_two_landmarks(image, landmarks_1, landmarks_2):
    plt.figure()
    plt.imshow(image)
    implot = plt.imshow(image)

    plt.scatter(x=landmarks_1[:68], y=landmarks_1[68:], c='b', s=10)
    plt.scatter(x=landmarks_2[:68], y=landmarks_2[68:], c='r', s=10)
    # plt.savefig('a'+str(landmarks_x[0])+'.png')
    plt.show()
    plt.clf()