experiments.py 611 Bytes
Newer Older
Arne Gerdes's avatar
Arne Gerdes committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2
import cvhelper
import numpy as np
from matplotlib import pyplot as plt

original = cv2.imread('resources/experiments/trump.jpg')
cvhelper.createwindow("Original", original, 0, 0)

gray = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
hsv = cv2.cvtColor(original, cv2.COLOR_BGR2HSV)
ret,thresh1 = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)

cvhelper.createwindow("Gray", gray, 100)
cvhelper.createwindow("HSV", hsv, 200)
cvhelper.createwindow("Threshold", thresh1, 300)

plt.hist(gray.ravel(), 256, [0,256])
plt.show()


k = cv2.waitKey(0)
if k == cv2.waitKey(0) & 0xFF:
    cv2.destroyAllWindows()