title: How to recognize histograms with a specific shape in opencv / python
body: <p>I want to segment images (from magazines) in text and image parts. I have several histograms for several ROIs in my picture. I use opencv with python (cv2).</p>
  
  <p>I want to recognize histograms that look like this</p>
  
  <p><a href="http://matplotlib.sourceforge.net/users/image_tutorial-6.png" rel="nofollow">http://matplotlib.sourceforge.net/users/image_tutorial-6.png</a></p>
  
  <p>as it is a typical shape for a text region. How can I do that?  </p>
  
  <p>Edit: Thank you for your help so far.</p>
  
  <p>I compared the histograms I got from my ROIs to a sample histogram I provided:</p>
  
  <pre><code>hist = cv2.calcHist(roi,[0,1], None, [180,256],ranges)
  compareValue = cv2.compareHist(hist, samplehist, cv.CV_COMP_CORREL)
  print "ROI: {0}, compareValue: {1}".format(i,compareValue)
  </code></pre>
  
  <p>Assuming ROI 0, 1, 4 and 5 are text regions and ROI is an image region, I get output like this: </p>
  
  <ul>
  <li>ROI: 0, compareValue: 1.0</li>
  <li>ROI: 1, compareValue: -0.000195522081574          &lt;--- wrong classified</li>
  <li>ROI: 2, compareValue: 0.0612670248952</li>
  <li>ROI: 3, compareValue: -0.000517370176887</li>
  <li>ROI: 4, compareValue: 1.0</li>
  <li>ROI: 5, compareValue: 1.0</li>
  </ul>
  
  <p>What can I do to avoid wrong classification? For some images, the misclassification rate is about 30%, which is way too high. </p>
  
  <p>(I tried also with CV_COMP_CHISQR, CV_COMP_INTERSECT, CV_COMP_BHATTACHARYY and (hist*samplehist).sum() but they also provide wrong compareValues)  </p>