Closed alexmera88 closed 4 months ago
If you look in pixFindSkewSweepAndSearchScorePivot
, you will see that we don't actually rotate the image. We do vertical shears, because they are much more efficient. The function pixDeskewGeneral()
does these vertical shears about the upper-left corner.
The algorithm was never designed for very large rotation corrections. If you run this program, you'll see a possible problem; namely, the rotation about the corner removes most of the image!
pix1 = pixRead("/tmp/feyn-fract.tif");
pixGetDimensions(pix1, &w, &h, NULL);
pix2 = pixRotate(pix1, 3.14159 / 4.0, L_ROTATE_SAMPLING, L_BRING_IN_WHITE,
0, 0);
pixDisplay(pix2, 100, 100);
pix3 = pixVShearCorner(NULL, pix2, -3.14159 / 4.0, L_BRING_IN_WHITE);
pixDisplay(pix3, 600, 100);
If that is the problem, then before you apply the deskew function, add a very large border the the image, of at least 1/3 the width on left and right sides and 1/3 the height on top and bottom
Excellent answer; thanks a lot, Dan!
Hi all, I'm using the following code to deskew some images:
This works just fine with text images (just black text over a white background) skewed by 5º, 10º....40º. But if the text is rotated 45º or 135º (clockwise), the detected angle is wrong, and the confidence is low.
Do you have any suggestions on how to handle these cases?