-
Notifications
You must be signed in to change notification settings - Fork 0
/
Negative.py
51 lines (34 loc) · 952 Bytes
/
Negative.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
# Negative
import cv2
import matplotlib.pyplot as plt
img_bgr = cv2.imread('picture1.jpg', 1)
plt.imshow(img_bgr)
plt.show()
color = ('b', 'g', 'r')
for i, col in enumerate(color):
histr = cv2.calcHist([img_bgr],
[i], None,
[256],
[0, 256])
plt.plot(histr, color=col)
plt.xlim([0, 256])
plt.show()
height, width, _ = img_bgr.shape
for i in range(0, height - 1):
for j in range(0, width - 1):
pixel = img_bgr[i, j]
pixel[0] = 255 - pixel[0]
pixel[1] = 255 - pixel[1]
pixel[2] = 255 - pixel[2]
img_bgr[i, j] = pixel
plt.imshow(img_bgr)
plt.show()
color = ('b', 'g', 'r')
for i, col in enumerate(color):
histr = cv2.calcHist([img_bgr],
[i], None,
[256],
[0, 256])
plt.plot(histr, color=col)
plt.xlim([0, 256])
plt.show()