-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtinting.py
More file actions
91 lines (82 loc) · 2.48 KB
/
tinting.py
File metadata and controls
91 lines (82 loc) · 2.48 KB
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
82
83
84
85
86
87
88
89
90
91
import matplotlib.image as img
import numpy as np
import matplotlib.pyplot as plt
def tint_1_color(image,color,tint_value):
im=image.copy()
if color==1:
color_name = "Red"
elif color==0:
color_name="Blue"
elif color==2:
color_name="Green"
else:
raise Exception("\n\nGive valid color id\n\n")
print("\n\nYour ",color_name," tinted Images are processing...\n\n")
for i in range(n):
im[:,:,color]+=tint_value
print("Your ",i+1," image is processed")
plt.imshow(im)
plt.show()
def tint_2_color(image,color1,color2,tint_value):
im=image.copy()
if(color1==0 and color2==1) or (color1==1 and color2==0) :
color_name = "Purple"
elif(color1==1 and color2==2) or (color1==2 and color1==1):
color_name="Yellow"
elif(color1==0 and color2==2) or (color1==2 and color1==0):
color_name="Cyan"
else:
raise Exception("\n\nGive valid color id\n\n")
print("\n\nYour ",color_name," tinted Images are processing...\n\n")
for i in range(n):
im[:,:,color1]+=tint_value
im[:,:,color2]+=tint_value
print("Your ",i+1," image is processed")
plt.imshow(im)
plt.show()
if __name__== "__main__":
image_name = input("Enter Image Name : ")
im = img.imread(image_name)
plt.imshow(im)
plt.show()
green_im=im.copy()
print(type(im))
print("Shape = ",im.shape)
try:
im.setflags(write=1)
except Exception as e:
print(e)
#raise Exception("Download numpy 1.15.4")
diff=5
n=17
while(True):
choice=int(input("Choose a tint : \n1.Red\n2.Blue\n3.Green\n4.Yellow\n5.Purple\n6.Cyan\n7.All\n8.Exit\n Enter choice : "))
if choice==1:
tint_1_color(im,1,5)
elif choice==2:
tint_1_color(im,0,5)
elif choice==3:
tint_1_color(im,2,5)
elif choice==4:
tint_2_color(im,1,2,5)
elif choice==5:
tint_2_color(im,0,1,5)
elif choice==6:
tint_2_color(im,0,2,5)
elif choice==7:
tint_1_color(im,1,5)
tint_1_color(im,0,5)
tint_1_color(im,2,5)
tint_2_color(im,1,2,5)
tint_2_color(im,0,1,5)
tint_2_color(im,0,2,5)
elif choice==8:
break
else:
print("Enter valid choice")
plt.figure(1)
plt.imshow(im)
plt.figure(2)
plt.imshow(im)
plt.show()
print("\n\nDone\n\n")