冒泡
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
import cv2 as cv
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# 1
|
||||||
|
img = cv.imread("sample.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
|
img2 = cv.imread('sample.jpg', cv.IMREAD_GRAYSCALE)
|
||||||
|
|
||||||
|
|
||||||
|
# 2
|
||||||
|
def draw_circle(event, x, y, flags, param):
|
||||||
|
if event == cv.EVENT_LBUTTONDOWN:
|
||||||
|
cv.circle(img, (x, y), 10, 0, -1)
|
||||||
|
|
||||||
|
|
||||||
|
# 4
|
||||||
|
alpha = 0.3
|
||||||
|
|
||||||
|
|
||||||
|
def updateBrightness(x):
|
||||||
|
global alpha, img, img2
|
||||||
|
alpha = cv.getTrackbarPos('Brightness', 'modify_sample')
|
||||||
|
alpha = alpha * 0.01
|
||||||
|
img = np.uint8(np.clip((alpha * img2), 0, 255))
|
||||||
|
|
||||||
|
|
||||||
|
# 3
|
||||||
|
cv.namedWindow('modify_sample')
|
||||||
|
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)
|
||||||
|
pressedKey = cv.waitKey(5)
|
||||||
|
# 5
|
||||||
|
if pressedKey == ord('q'):
|
||||||
|
break
|
||||||
|
if pressedKey == ord('s'):
|
||||||
|
cv.imwrite('modified_sample.jpg', img)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
Reference in New Issue
Block a user