0
My code reads an image and transforms the RGB color model to HSV, and then I make a frequency histogram of each channel (H, S and V), with H varying from 0-179 and the rest from 0-255. With histogram plotting it is possible to check peaks in channels H, S and V. This histogram shows through the vertical axis the amount of pixels and the horizontal axis the channels H ,S and V. I want to return the values of H, S and V in which the amount of pixels is higher, that is, the peak histogram of each channel. How to do this? I have already used the np.amax() method but it returns 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 find the most frequent value for each channel. Do you have any method for this? I know it exists in the medium, medium numpy.
Fashion can find the most frequent value for each channel. Do you have any method for this? I know it exists in the medium, medium numpy.
– Vitor Romano