diff --git a/test/2024,09,29/homework.py b/test/2024,09,29/homework.py new file mode 100644 index 0000000..ebfb9b0 --- /dev/null +++ b/test/2024,09,29/homework.py @@ -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) diff --git a/test/2024,09,29/modified_sample.jpg b/test/2024,09,29/modified_sample.jpg new file mode 100644 index 0000000..638631e Binary files /dev/null and b/test/2024,09,29/modified_sample.jpg differ diff --git a/test/2024,09,29/sample.jpg b/test/2024,09,29/sample.jpg new file mode 100644 index 0000000..67eeaeb Binary files /dev/null and b/test/2024,09,29/sample.jpg differ