title: Detect if image is color, grayscale or black and white using Python
body: <p>I extract pages images from a PDF file in jpeg format and I need to determine if each image is much more grayscale, color or black and white (with a tolerance factor).</p>
  <p>I have found some ways to work with color detection with PIL ( <a href="https://stackoverflow.com/questions/2270874/image-color-detection-using-python">here</a> and <a href="https://stackoverflow.com/questions/14041562/python-pil-detect-if-an-image-is-completely-black-or-white">here</a> ) but I can't figure out how to answer this simple (visual) question : is it much more black and white, color or grayscale image ?</p>
  <p>I prefer working with Python and PIL for this part but I could use too OpenCV if someone has a clue (or solution).</p>