I have a binary image, but it is all messy, I would like to know if there is a way to "clean" the image. How/what I can do to turn the first exemple image in something like the second one using OpenCV?
3 Answers
When working with B&W images, it is a usual practice to use image morphology. In your case you can extract connected components. You shall then leave only the large connected components.
You also can erode the image, to make sure digits are not connected to any noise.
However, the most robust way is to exploit OCR capabilities, since you're looking for digits. I.e. you can use your prior knowledge of how the significant areas should look like. But in your example it seems like simple morphology would be enough.
-
I was trying the techniques, but even with them, although I have to train the OCR. You know something about it? I'm using Tessearct training tutorial but it is very confusing. – U23r Jun 28 '13 at 12:35
-
I don't have much experience in OCR, so I don't think I can help you. If you have any _specific_ question, you can ask it here, on StackOverflow. – Mikhail Jun 28 '13 at 16:18
Hi if this is not too late... make use of morphology and blob filtering... For your image case, do a morphology closing with element of Size(30, 1), then closing with element of Size(1, 25). After that filter any blob less than the size of your (image rows / 2) should gives clean image.

- 201
- 2
- 4
-
You better mention what parameters "30", "25" of method "Size()" mean! – Horizon1710 Jan 30 '17 at 13:24