Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get the optimal binary threshold value

Hi, I'm trying to use opencv to process text images before sending them to OCR. This involves binarizing the images, but because they vary greatly (from very dark to very faint), I need an adaptive thresholding method. I tried Otsu but id doesn't give the desired result. This is my original image: Original

...and this is what its like after Otsu thresholding: Otsu

...Otsu calculates a threshold of 238 for this image, but if I experiment manually, I find that that a threshold of 222 produces a better result as follows: Threshold 222

If I try adaptiveThreshold, the best I get is (with a block size of 17 and a C of 6) as follows: image description

...but this is still not as good as the 222 image. Can anyone suggest a programmatic way of coming up with an optimal threshold value? ....or some other adaptive method which might give me better results?

Any help would be much appreciated Thanks Jim

How to get the optimal binary threshold value

Hi, I'm trying to use opencv to process text images before sending them to OCR. This involves binarizing the images, but because they vary greatly (from very dark to very faint), I need an adaptive thresholding method. I tried Otsu but id doesn't give the desired result. This is my original image: Original

...and this is what its like after Otsu thresholding: Otsu

...Otsu calculates a threshold of 238 for this image, but if I experiment manually, I find that that a threshold of 222 produces a better result as follows: Threshold 222

If I try adaptiveThreshold, the best I get is (with a block size of 17 and a C of 6) as follows: image description

...but this is still not as good as the 222 image. Can anyone suggest a programmatic way of coming up with an optimal threshold value? ....or some other adaptive method which might give me better results?

Any help would be much appreciated Thanks Jim

How to get the optimal binary threshold value

Hi, I'm trying to use opencv to process text images before sending them to OCR. This involves binarizing the images, but because they vary greatly (from very dark to very faint), I need an adaptive thresholding method. I tried Otsu but id doesn't give the desired result. This is my original image: Original

...and this is what its like after Otsu thresholding: Otsu

...Otsu calculates a threshold of 238 for this image, but if I experiment manually, I find that that a threshold of 222 produces a better result as follows: Threshold 222

If I try adaptiveThreshold, the best I get is (with a block size of 17 and a C of 6) as follows: image description

...but this is still not as good as the 222 image. Can anyone suggest a programmatic way of coming up with an optimal threshold value? ....or some other adaptive method which might give me better results?

Any help would be much appreciated Thanks Jim