-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pixOrientCorrect/pixOrientDetect issue with PBM #748
Comments
What does the file format have to do with the operation on a raster image? pixOrientDetect() works on a 1 bpp image. First of all, I do get the bogus results that you get from pixOrientDetect() with your image. This is very strange. Consider this program running on your image:
If the scale factor is 1.0 (i.e., your input image), the bad results are obtained. Suppose we compare them with an XOR:
We see the outlines of the characters but with a very noisy result. The noise appears to be from the image previously having been compressed with jpeg, before being binarized, causing this "squirrel noise" near character edges. And somehow all this noise near the edges is causing the algorithm to fail. Yet, the algorithm succeeds if the raster image is scaled by 1 part in a thousand, which doesn't get rid of the squirrel noise -- it just moves it around a little bit. So, I can only tell you that the jpeg artifacts are causing the problem, and you can more easily fix the problem by doing a tiny rescaling operation. But I cannot visualize the underlying mechanism behind these results. It is a great puzzle!!! Do you have any insight into this? |
Here's a much more efficient work-around. |
Thanks for sharing. I noticed that in some cases downscaling just by 1/1000 will not work but trying by both upscaling and downscaling works. |
I did the experiments with downscaling by a tiny fraction to determine how sensitive the anomalous images are when modified. As I indicated, this is by far the strangest situation I've seen with this algorithm. The use of special 2x reduction before testing for orientation will give you the correct answer as fast as possible, because those 2x reductions are blazingly fast, and running the orientation function on a half-sized image will be 4 times faster than at full res. |
I have tested the pixOrientDetect/pixOrientCorrect through thousands of similar pages of annual reports with similar layouts. For some reason which I trying to understand I get a 90 cw rotation for pages that are still upright but ONLY when they are in PBM format and if I first convert the PBM files to a JPEG I don't get the rotation.
Attaching PBM in a ZIP file since Github doesn't allow me to upload the PBM.
Leptonica-casuses-wrong-rotation.zip
The text was updated successfully, but these errors were encountered: