GithubHelp home page GithubHelp logo

Comments (12)

nguyenq avatar nguyenq commented on September 28, 2024

While we're investigating this issue, can you try the Leptonica methods that determine the skew angles? If they yield more consistent and accurate results, you may want to go that route; however, the image format conversion, Java BufferedImage to Leptonica Pix and back, will incur some overheads. Please do some analysis, and submit a PR if needed. Thanks.

http://tess4j.sourceforge.net/docs/index.html

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

Could it be that the image has some invisible artifacts (lines) that skewed the results?

The existing Java native method has been in use ever since the library inception, and no one has complained about it.

from tess4j.

peterkronenberg avatar peterkronenberg commented on September 28, 2024

I attached the file. No lines that I could see. Again, the document is not skewed at all. Not sure if anyone has ever tried it on an image like that. Do you see the same results?
I can try the Leptonica library. What exactly is that for?
I see the findSkew() method. I assume that pangle is the skew angle it finds. But what is pconf?

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

The lines may be invisible to human eyes.

Leptonica is the image processing library that Tesseract directly depends on. You will need to consult its documentation for usage.

https://tpgit.github.io/Leptonica/skew_8c.html

from tess4j.

peterkronenberg avatar peterkronenberg commented on September 28, 2024

I don't think that's likely. Are you able to try it and determine if this is a bug? I thought this was a place I could get support

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

I tried your image in VietOCR gui. Deskewing the entire image did incorrectly skew it. If I split it in half top/bottom and trim empty spaces, it works correctly. The large empty space in between the header/footer seems to have thrown it off.

from tess4j.

peterkronenberg avatar peterkronenberg commented on September 28, 2024

Yes, that is exactly my point. Is there anything I can do to improve this? I have several images like this (pages from a PDF file), that have an address at the top or a few other lines of text, with a lot of white space. But the lines of text are clearly horizontal

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

Try your question and images in SO. There are image processing experts that could help.

Or you may want to try to use Leptonica methods first; if need be, post on Leptonica site for help.

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

@peterkronenberg Any luck (better results) with Leptonica methods?

from tess4j.

peterkronenberg avatar peterkronenberg commented on September 28, 2024

Sorry, haven't had an opportunity to try it yet.

from tess4j.

nguyenq avatar nguyenq commented on September 28, 2024

Ran a test case for Lept4J:

   /**
     * Test of pixFindSkew method, of class Leptonica1.
     */
    @Test
    public void testPixFindSkew() {
        System.out.println("pixFindSkew");
        File input = new File("C:\\Temp\\samplerotatedimage-Redacted.tif");
        Pix pixs = Leptonica1.pixRead(input.getPath());
        Pix pix1pp = Leptonica1.pixConvertTo1(pixs, 128);
        FloatBuffer pangle = FloatBuffer.allocate(1);
        FloatBuffer pconf = FloatBuffer.allocate(1);
        int expResult = 0;
        int result = Leptonica1.pixFindSkew(pix1pp, pangle, pconf);
        float conf = pconf.get();
        float angle = pangle.get();
        System.out.println("Confidence: " + conf + " Angle: " + angle);
        assertEquals(expResult, result);
    }

Output:

Running net.sourceforge.lept4j.Leptonica1Test
pixFindSkew
Confidence: 2.8027375 Angle: 0.21875

Documentation: https://tpgit.github.io/Leptonica/skew_8c.html

from tess4j.

peterkronenberg avatar peterkronenberg commented on September 28, 2024

Thanks for trying this out!

from tess4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.