-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions tests.py
72 lines (47 loc) · 2.63 KB
/
functions tests.py
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
from PIL import Image
import numpy as np
from DigitalImaging import DigitalImaging
d = DigitalImaging()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for convert_to_gs function
img_converted_gs = d.convert_to_gs('assets/dogs/puppy3.jpg')
img_converted_gs.show()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for color_at function
img_as_array = np.array(Image.open('assets/dogs/puppy3.jpg'))
# img_as_array.flags.writeable = False # if we change the flag the method will return None
rgb_colors = d.color_at(img_as_array, img_as_array.shape[0] / 2, img_as_array.shape[1] / 2)
print(rgb_colors)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test reduce_to function
agriculture_img_path = "./assets/agriculture.jpg"
img_red = d.reduce_to(agriculture_img_path, 'R')
img_green = d.reduce_to(agriculture_img_path, 'G')
img_blue = d.reduce_to(agriculture_img_path, 'B')
img_red.show()
img_green.show()
img_blue.show()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for make_collage function
images = DigitalImaging.list_of_all_img_in_folder("assets/dogs")
dogs_collage = d.make_collage(images)
Image.fromarray(dogs_collage, 'RGB').show()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for shapes_dict function
images = DigitalImaging.list_of_all_img_in_folder("assets/different image height")
for i in d.shapes_dict(images).items():
print(i)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for detect_obj function
img_arr_eyes = d.detect_obj('assets/people/people3.jpg', "eyes")
img_arr_faces = d.detect_obj('assets/people/people3.jpg', "face")
Image.fromarray(img_arr_eyes).show()
Image.fromarray(img_arr_faces).show()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for detect_obj_adv function
img_arr = d.detect_obj_adv('assets/people/people3.jpg', True, False)
Image.fromarray(img_arr).show()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test for detect_face_in_vid function
d.detect_face_in_vid("assets/people/vid.mp4")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~