'Tess4j deskew incorrectly detecting angle

I'm using the ImageDeskew class from Tess4j. I'm seeing an error in calculating the skew angle. The below sample code shows a rotation of -6.8 (the unredacted version shows -10) on the attached file even though it should be 0. Any idea why it’s not calculating correctly?

It seems to happen on somewhat sparse images like this, which understandably makes it harder to figure out the orientation. I'm wondering if anything can be done to make it more accurate. File was too big (8Mb) to attach here, so here's a link: https://www.dropbox.com/s/ahke8boksmk2f94/sample%20rotated%20image%20-%20Redacted.tif?dl=0

public class GetAngle {

    private static double getAngle(Path sourceFile) throws IOException {
        BufferedImage bi = ImageIO.read(sourceFile.toFile());
        ImageDeskew id = new ImageDeskew(bi);
        double angle = id.getSkewAngle();
        if (angle < 1.0D && angle > -1.0D) {
            angle = 0.0D;
        } else {
            System.out.println("*** angle: " + angle);
        }

        return angle;
    }

    public static void main(String[] args) throws IOException {
        Path path = Paths.get( "/testFiles", "sample rotated image - Redacted.tif");
        System.out.println("*** path: " + path);
        System.out.println("*** getAngle: " + getAngle(path));

    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source