colourspace and histogram examples
This commit is contained in:
parent
1e844218ea
commit
00e35ad78e
28
src/helpers/algorithms/colourspace.py
Normal file
28
src/helpers/algorithms/colourspace.py
Normal file
@ -0,0 +1,28 @@
|
||||
import cv2
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
DATASET_PATH = "C:\\Users\\tomse\\Documents\\Dataset\\"
|
||||
|
||||
full_img = cv2.imread(DATASET_PATH + "alder\\1.jpg", 1)
|
||||
bgr_img = cv2.resize(full_img, (0, 0), fx=0.2, fy=0.2)
|
||||
hsv_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2HSV)
|
||||
|
||||
cv2.imshow('BGR',bgr_img)
|
||||
cv2.imshow('HSV',hsv_img)
|
||||
cv2.imshow('HSV - H',hsv_img[:, :, 0])
|
||||
cv2.imshow('HSV - S',hsv_img[:, :, 1])
|
||||
cv2.imshow('HSV - V',hsv_img[:, :, 2])
|
||||
|
||||
|
||||
hist = cv2.calcHist([hsv_img], [0], None, [256], [0,256])
|
||||
plt.plot(hist, label='H')
|
||||
hist = cv2.calcHist([hsv_img], [1], None, [256], [0,256])
|
||||
plt.plot(hist, label='S')
|
||||
hist = cv2.calcHist([hsv_img], [2], None, [256], [0,256])
|
||||
plt.plot(hist, label='V')
|
||||
plt.grid()
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
Loading…
Reference in New Issue
Block a user