Reputation: 11192
I'm new to image processing. I want to perform character segmentation in OCR. I have already done necessary pre-processing. When I perform character segmentation by finding contouring it works well except for the character 3, 8.
After pre processed image looks like this,
Output after finding contouring for 3 and 8 is
Code used:
imgGray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
ret, imgThresh = cv2.threshold(imgGray, 127, 255, 0)
image, contours , _ = cv2.findContours(imgThresh, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
But it gives good result for other characters:
How to solve this issue?
Upvotes: 0
Views: 143
Reputation: 21203
Since your image does not involve any complex background I used Otsu's method to pick the right threshold for me:
threshold, thresh_img = cv2.threshold(imgGray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
Now when you find contours it will be easier. That is because contours are found for objects or charaters that are in white.
Have a look at those characters that caused problems now:
Upvotes: 4