My code reads an image and transforms the RGB color model into HSV, and then makes a frequency histogram of each channel (H, S, and V), where H varies from 0-179 and the others 0-255. By plotting the histogram, it is possible to check peaks in H, S and V channels. This histogram shows the number of pixels and the horizontal axis through the vertical axis, the H, S and V channels. I want to return the values of H, S and V in which the number of pixels is larger, ie the peak of the histogram of each channel. /i.stack.imgur.com/2RGs0.png "> How to do this? I have already used the np.amax () method but it returns me the maximum values of each channel (H = 179, S = 255 and V = 255).
def show_hsv_hist(image):
# Hue
plt.figure(figsize=(20, 3))
histr0 = cv2.calcHist([hsv], [0], None, [180], [0, 180])
plt.plot(histr0)
plt.xlim([0, 180])
plt.title('Hue')
# Saturation
plt.figure(figsize=(20, 3))
histr1 = cv2.calcHist([hsv], [1], None, [255], [0, 255])
plt.xlim([0, 255])
plt.plot(histr1)
plt.title('Saturation')
# Value
plt.figure(figsize=(20, 3))
histr2 = cv2.calcHist([hsv], [2], None, [255], [0, 255])
plt.xlim([0,255])
plt.plot(histr2)
plt.title('Value')
max_v = np.amax(v)
print (max_v)
Fashion can discover the most frequent value for each channel. Do you have any method for this? I know it exists in the middle, middle numpy.