Eroding Text to from blobs

I need to detect text blocks on a document and get back their bounding boxes, I have heard that I should erode the image which will "smudge" the text together and form blobs, then I can use blob detection to find where the text is. Currently I have I binarized image with some text on it.

I have been using this code to erode, and it is slightly merging the text together. But how can I make it more severe? The parameters have me slightly confused and if someone could explain how I could make the erosion harsher that would be great!

erode(quad, quad, Mat(), cv::Point(-1, -1), 2, 1, 1);


Thanks.

edit retag close merge delete

Sort by » oldest newest most voted

Hi Luek,

By using Mat() as the third argument on erode you are using de default 3x3 structuring element, which might be too small for your case. You should experiment with larger sizes/different shapes of structuring element until you achieve satisfying results..

You can try something like this:

int size = 6; //Play with this size until you get the results you want
erode ( quad, quad, cv::getStructuringElement ( MORPH_RECT, size ), cv::Point ( -1, -1 ), 2, 1 , 1);

more