diff options
author | Sudipto Mallick <smlckz@termux-alpine> | 2024-02-10 12:49:55 +0000 |
---|---|---|
committer | Sudipto Mallick <smlckz@termux-alpine> | 2024-02-10 12:49:55 +0000 |
commit | 4182a108a01df3aa28009716472f0ef291704866 (patch) | |
tree | 8fabeb2d6ddff80b930c02b3d535b5447bbd41dc /opencv/code/a1.py | |
parent | 02884d29e4f5aea71364a203dcaecd53600d8aa4 (diff) | |
download | zadania-4182a108a01df3aa28009716472f0ef291704866.tar.gz |
Complete DIP assignments main
Diffstat (limited to 'opencv/code/a1.py')
-rw-r--r-- | opencv/code/a1.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/opencv/code/a1.py b/opencv/code/a1.py new file mode 100644 index 0000000..1f00db7 --- /dev/null +++ b/opencv/code/a1.py @@ -0,0 +1,29 @@ +import cv2 +import numpy as np +import os + +os.chdir("images") + +image = cv2.imread("1i.png") + +gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) + +_, graytobin = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY) + +_, rgbtobin = cv2.threshold(image, 150, 255, cv2.THRESH_BINARY) + +hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV) + +hsvtorgb = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB) + +rcb = cv2.cvtColor(image, cv2.COLOR_BGR2YCR_CB) + +rcbtorgb = cv2.cvtColor(rcb, cv2.COLOR_YCrCb2BGR) + +cv2.imwrite("1.1.png", gray) +cv2.imwrite("1.2.png", hsv) +cv2.imwrite("1.3.png", rcb) +cv2.imwrite("1.4.png", hsvtorgb) +cv2.imwrite("1.5.png", rcbtorgb) +cv2.imwrite("1.6.png", graytobin) +cv2.imwrite("1.7.png", rgbtobin) |