summary refs log tree commit diff stats
path: root/opencv/code/a3.py
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@termux-alpine>2024-02-10 12:49:55 +0000
committerSudipto Mallick <smlckz@termux-alpine>2024-02-10 12:49:55 +0000
commit4182a108a01df3aa28009716472f0ef291704866 (patch)
tree8fabeb2d6ddff80b930c02b3d535b5447bbd41dc /opencv/code/a3.py
parent02884d29e4f5aea71364a203dcaecd53600d8aa4 (diff)
downloadzadania-main.tar.gz
Complete DIP assignments main
Diffstat (limited to 'opencv/code/a3.py')
-rw-r--r--opencv/code/a3.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/opencv/code/a3.py b/opencv/code/a3.py
new file mode 100644
index 0000000..5a8ffcd
--- /dev/null
+++ b/opencv/code/a3.py
@@ -0,0 +1,14 @@
+import cv2
+import matplotlib.pyplot as plt
+
+image = cv2.imread("1i.png", cv2.IMREAD_GRAYSCALE)
+
+histogram = cv2.calcHist([image], [0], None, [256], [0, 256])
+
+plt.figure(figsize=(8, 5))
+plt.plot(histogram, color="black")
+plt.title("Grayscale Histogram")
+plt.xlabel("Pixel Value")
+plt.ylabel("Frequency")
+plt.xlim([0, 256])
+plt.savefig("3.svg")