Open jbarth-ubhd opened 2 years ago
detectTextSWT
is a bit slow. Perhaps bluring the image horizontally and average that image vertically could give a hint where main text is, but in case of skewed crop near text (as in https://user-images.githubusercontent.com/38561704/163437862-2691812d-611d-4824-8072-83104f5a2ef9.png on the left side) that wouldn't help
with this few lines I've got nearer to detect, where the text is:
Mat wim=white_on_black;
// size(im)==size(wim)
blur(wim, findtext, Size(34, 1));
// "ern" (12 pt., font Garamond No 8) = 68 px @ 300 dpi
// but imread("img size / 2")
resize(findtext, findtext, Size(im.cols, im.rows*2));
// *2 because medianBlur has kernel size(x, x)
// but I want size(x, x/2)
threshold(findtext, findtext, 0, 255, THRESH_OTSU);
medianBlur(findtext, findtext, 5);
if(debug) resize(findtext, findtext, im.size(), 0, 0, INTER_AREA); // it will generally look best with INTER_AREA interpolation
→
Would have to check typical line hights by scanning columns.
Good idea – but mind that this alley will lead to assumptions on the typesetting / page layout of the input. I have seen the same in https://github.com/mzucker/page_dewarp. This usually does not work with pages that have lots of tables or images in them, or text scattered across in single lines. Also, you might have to depend on a good binarization for the OpenCV function to work properly (think heavy shine-through or bleeding or drying-out).
detectTextSWT has limitations... negative examples:
left words in block not recognized (not only the bold ones):
only very small "dust" regions recognized:
large horizontal+vertical lines not recognized:
opencv has
detectTextSWT
http://www.math.tau.ac.il/~turkel/imagepapers/text_detection.pdf , perhaps I could limit the "optimal angle search" for the text area.