将滑动条修改为一条
This commit is contained in:
@@ -14,28 +14,19 @@ def draw_circle(event, x, y, flags, param):
|
||||
|
||||
# 4
|
||||
alpha = 0.3
|
||||
beta = 80
|
||||
|
||||
|
||||
def updateAlpha(x):
|
||||
def updateBrightness(x):
|
||||
global alpha, img, img2
|
||||
alpha = cv.getTrackbarPos('Alpha', 'modify_sample')
|
||||
alpha = cv.getTrackbarPos('Brightness', 'modify_sample')
|
||||
alpha = alpha * 0.01
|
||||
img = np.uint8(np.clip((alpha * img2 + beta), 0, 255))
|
||||
|
||||
|
||||
def updateBeta(x):
|
||||
global beta, img, img2
|
||||
beta = cv.getTrackbarPos('Beta', 'modify_sample')
|
||||
img = np.uint8(np.clip((alpha * img2 + beta), 0, 255))
|
||||
img = np.uint8(np.clip((alpha * img2), 0, 255))
|
||||
|
||||
|
||||
# 3
|
||||
cv.namedWindow('modify_sample')
|
||||
cv.createTrackbar('Alpha', 'modify_sample', 0, 300, updateAlpha)
|
||||
cv.createTrackbar('Beta', 'modify_sample', 0, 255, updateBeta)
|
||||
cv.setTrackbarPos('Alpha', 'modify_sample', 100)
|
||||
cv.setTrackbarPos('Beta', 'modify_sample', 10)
|
||||
cv.createTrackbar('Brightness', 'modify_sample', 0, 255, updateBrightness)
|
||||
cv.setTrackbarPos('Brightness', 'modify_sample', 100)
|
||||
cv.setMouseCallback('modify_sample', draw_circle)
|
||||
while (1):
|
||||
cv.imshow('modify_sample', img)
|
||||
|
||||
Reference in New Issue
Block a user