|
|
|
|
@ -26,9 +26,9 @@ class Photo:
|
|
|
|
|
def vertical_mirror(self):
|
|
|
|
|
self.img = cv2.flip(self.img, 0, dst=None)
|
|
|
|
|
|
|
|
|
|
# ratio: [1%, 500%]
|
|
|
|
|
# ratio: [1, 500]
|
|
|
|
|
def resize(self, ratio):
|
|
|
|
|
self.img = cv2.resize(self.img, dsize=None, fx=ratio, fy=ratio, interpolation=cv2.INTER_LINEAR)
|
|
|
|
|
self.img = cv2.resize(self.img, dsize=None, fx=ratio / 100.0, fy=ratio / 100.0, interpolation=cv2.INTER_LINEAR)
|
|
|
|
|
|
|
|
|
|
# value: [0,100]
|
|
|
|
|
def lighting(self, value):
|
|
|
|
|
@ -40,45 +40,39 @@ class Photo:
|
|
|
|
|
|
|
|
|
|
# value: [-100,100]
|
|
|
|
|
def contrast(self, value):
|
|
|
|
|
hsv = cv2.cvtColor(self.img, cv2.COLOR_BGR2HSV)
|
|
|
|
|
v = hsv[:, :, 2]
|
|
|
|
|
avg = 0
|
|
|
|
|
rows, cols, depth = hsv.shape
|
|
|
|
|
for r in range(0, rows):
|
|
|
|
|
for c in range(0, cols):
|
|
|
|
|
avg += v[r, c]
|
|
|
|
|
avg /= rows * cols
|
|
|
|
|
table = []
|
|
|
|
|
for i in range(0, avg):
|
|
|
|
|
table.append(-np.power((avg - i) / avg, value) * avg + avg)
|
|
|
|
|
for i in range(avg + 1, 255):
|
|
|
|
|
table.append(np.power((i - avg) / (255.0 - avg), value) * (255.0 - avg) + avg)
|
|
|
|
|
table = np.round(np.array(table)).astype(np.uint8)
|
|
|
|
|
hsv[:, :, 2] = cv2.LUT(v, table)
|
|
|
|
|
self.img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
|
|
|
|
|
lst = value * self.img
|
|
|
|
|
lst += np.mean(self.img - lst)
|
|
|
|
|
np.clip(lst, 0, 255, self.img)
|
|
|
|
|
|
|
|
|
|
# value: [-100,100]
|
|
|
|
|
|
|
|
|
|
def saturate(self, value):
|
|
|
|
|
pass
|
|
|
|
|
# value: [-100,100]
|
|
|
|
|
|
|
|
|
|
# value: [-100,100]
|
|
|
|
|
def hue(self, value):
|
|
|
|
|
pass
|
|
|
|
|
def saturate(self, value):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# value: [0,100]
|
|
|
|
|
def sharpen(self, value):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# value: [0,100]
|
|
|
|
|
def blur(self, value):
|
|
|
|
|
pass
|
|
|
|
|
# value: [-100,100]
|
|
|
|
|
def hue(self, value):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# value: [0,100]
|
|
|
|
|
def sharpen(self, value):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# value: [0,100]
|
|
|
|
|
def blur(self, value):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def toGray(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def toGray(self):
|
|
|
|
|
pass
|
|
|
|
|
def invert(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def invert(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def toBinary(self):
|
|
|
|
|
pass
|
|
|
|
|
def toBinary(self):
|
|
|
|
|
pass
|
|
|
|
|
|