numpy image histogram plot

Solutions on MaxInterview for numpy image histogram plot by the best coders in the world

showing results for - "numpy image histogram plot"
Gabriele
12 Apr 2016
1# tuple to select colors of each channel line
2colors = ("red", "green", "blue")
3channel_ids = (0, 1, 2)
4
5# create the histogram plot, with three lines, one for
6# each color
7plt.xlim([0, 256])
8for channel_id, c in zip(channel_ids, colors):
9    histogram, bin_edges = np.histogram(
10        image[:, :, channel_id], bins=256, range=(0, 256)
11    )
12    plt.plot(bin_edges[0:-1], histogram, color=c)
13
14plt.xlabel("Color value")
15plt.ylabel("Pixels")
16
17plt.show()
18