0

I have a trained face recognizer. After doing face_recognizer.getHistograms() I want to show them. How can I do this? Thanks ahead!

2 Answers 2

1

To plot histogram of an image, use you use pyplot.hist:

If you're image is in grayscale where gray scale intensities vary from 0 to 255, use:

from matplotlib import pyplot as plt
plt.hist(img.ravel(), 256, [0,256])

If it's a color image, you can also use opencv's calcHist function:

color = ('b', 'g', 'r')
for i,col in enumerate(color):
    histr = cv2.calcHist([img],[i],None,[256],[0,256])
    plt.plot(histr,color = col)
    plt.xlim([0,256])

The image intensity of each channel should be between [0, 255]

Sign up to request clarification or add additional context in comments.

8 Comments

I saw that function but I dont want to use it on an image. I want to show the histogram directly. Given a histogram as a numpy array - how can I show it?
Which function do you not want to use?
I have an pre-made histogram and I just want to show it. The pyplot.hist function shows a histogram of a given image. What I want is just to show an histogram without gibing the function the image itself.
Use plt.plot then
plt.plot(histogram), plt.show() does not work. It just creates an empty window with x and y axis
|
1

It's possible to simulate histogram collection via opencv using the OpenCV-Flow online tool.

See results here:

enter image description here

1 Comment

interesting web app!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.