(gray)
| 4 | |
| 5 | |
| 6 | def custom_hist(gray): |
| 7 | h, w = gray.shape |
| 8 | hist = np.zeros([256], dtype=np.int32) |
| 9 | for row in range(h): |
| 10 | for col in range(w): |
| 11 | pv = gray[row, col] |
| 12 | hist[pv] += 1 |
| 13 | |
| 14 | y_pos = np.arange(0, 256, 1, dtype=np.int32) |
| 15 | plt.bar(y_pos, hist, align='center', color='r', alpha=0.5) |
| 16 | plt.xticks(y_pos, y_pos) |
| 17 | plt.ylabel('Frequency') |
| 18 | plt.title('Histogram') |
| 19 | plt.show() |
| 20 | |
| 21 | |
| 22 | src = cv.imread("./test.png") |