From 4182a108a01df3aa28009716472f0ef291704866 Mon Sep 17 00:00:00 2001 From: Sudipto Mallick Date: Sat, 10 Feb 2024 12:49:55 +0000 Subject: Complete DIP assignments --- opencv/code/a3.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 opencv/code/a3.py (limited to 'opencv/code/a3.py') 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") -- cgit 1.4.1-2-gfad0