import cv2 as cv
import numpy as np
def nothing():
pass
img = cv.imread("D://opencv_test//test_a.jpg")
cv.namedWindow("win")
cv.createTrackbar("Threshold", "win", 0, 255, nothing)
img_gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
while(1):
t = cv.getTrackbarPos("Threshold", "win")
ret, img_1 = cv.threshold(img_gray, t, 255, cv.THRESH_BINARY)
cv.imshow("win", img_1)
if(cv.waitKey(50)&0xFF == 27):
break
cv.destroyAllWindows()