When I do an OTSU threshold on this image it always takes erodes away the same text every time no matter the lighting conditions.

Here is how I am calling the method:

threshold(outImg_gray(boxRoi), outImg_binarized(boxRoi), 0, 255, CV_THRESH_BINARY_INV|CV_THRESH_OTSU);

When given this image:

enter image description here

I get this image:

enter image description here

As you can see the bottom text removes part of the text at the bottom and it always removes part of this text.

How can I avoid this from happening?

有帮助吗?

解决方案

Add a border to the image before processing (use copyMakeBorder), and remove it after processing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top