summary refs log tree commit diff stats
path: root/opencv/code/a3.py
blob: 5a8ffcd0b8d132bbdc482ccc686f804e05b0a567 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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")