summary refs log tree commit diff stats
path: root/opencv/code/a1.py
diff options
context:
space:
mode:
Diffstat (limited to 'opencv/code/a1.py')
-rw-r--r--opencv/code/a1.py29
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)