forked from ProfessorKazarinoff/extensometer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_hsv_values_matplotlib.py
40 lines (31 loc) · 1.02 KB
/
get_hsv_values_matplotlib.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
#!/usr/bin/env python
import cv2
import numpy as np
import imutils
import sys
import platform
import matplotlib.pyplot as plt
from cv_image_show import print_version_params, simple_image_show
def matpltlib_hsv(image_path):
#lowerRed = (169, 92, 115) # red Hue values: 1-10 and red Hue values: 160-180
#upperRed = (175, 175, 150)
# import the image, resize and convert to hsv
frame = cv2.imread(image_path) # import image
frame = imutils.resize(frame,height=600) # resize
hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV) #convert to hsv colorspace
plt.imshow(hsv)
plt.show()
# construct mask
#mask = cv2.inRange(hsv,lowerRed,upperRed)
#mask = cv2.erode(mask, None, iterations=2)
#mask = cv2.dilate(mask, None, iterations=2)
#cv2.imshow('mask',mask)
#cv2.waitKey(0)
#pixel_distance = 32
#return(pixel_distance)
def main():
print_version_params()
matpltlib_hsv('tensile_bar_with_red_dots_cropped.jpg')
if __name__ =="__main__":
main()
cv2.waitKey(0)