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).
I want to recognize histograms that look like this
http://matplotlib.sourceforge.net/users/image_tutorial-6.png
as it is a typical shape for a text region. How can I do that?
Edit: Thank you for your help so far.
I compared the histograms I got from my ROIs to a sample histogram I provided:
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)
Assuming ROI 0, 1, 4 and 5 are text regions and ROI is an image region, I get output like this:
- ROI: 0, compareValue: 1.0
- ROI: 1, compareValue: -0.000195522081574 <--- wrong classified
- ROI: 2, compareValue: 0.0612670248952
- ROI: 3, compareValue: -0.000517370176887
- ROI: 4, compareValue: 1.0
- ROI: 5, compareValue: 1.0
What can I do to avoid wrong classification? For some images, the misclassification rate is about 30%, which is way too high.
(I tried also with CV_COMP_CHISQR, CV_COMP_INTERSECT, CV_COMP_BHATTACHARYY and (hist*samplehist).sum() but they also provide wrong compareValues)