-
Notifications
You must be signed in to change notification settings - Fork 510
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
Rectangle Detection Logic #2094
Comments
Thanks for the report. BTW: There is no intention to detect arbitrary rectangle-like things. Detection delivers a rectangle if and only if all of the following conditions are met:
While method Depending on whether line 1 is "above" or "below" line 3, the rectangle orientation is determined: below means anti-clockwise, above is clockwise. |
Issue 2087: `fitz.i (extract_image)´: the type of JPX images with more than one `/Filter` are not correctly recognized if inspecting the raw stream. Fixing this by extracting the decoded stream: we already know the type from the PDF dict. Issue 2094: Rectangle recognition `(helper-devices.i (jm_checkrect())` was wrong in not confirming that also x-coordinates are the same in respective corners. Also simplified rectangle orientation detection.
Issue 2087: `fitz.i (extract_image)´: the type of JPX images with more than one `/Filter` are not correctly recognized if inspecting the raw stream. Fixing this by extracting the decoded stream: we already know the type from the PDF dict. Issue 2094: Rectangle recognition `(helper-devices.i (jm_checkrect())` was wrong in not confirming that also x-coordinates are the same in respective corners. Also simplified rectangle orientation detection.
Fix #2110 (Discussion item #2111): File `__main__.py` - also include the font's xref in the generated file name. Fix #2094: File `helper-device.i' - also ensure equality of x coordinates of relevant corners before assuming a rectangle. Fix #2087: File `fitz.i`- if JPX image format is already known, make sure to read the decoded image stream, instead of raw stream in the other cases.
Fix pymupdf#2110 (Discussion item pymupdf#2111): File `__main__.py` - also include the font's xref in the generated file name. Fix pymupdf#2094: File `helper-device.i' - also ensure equality of x coordinates of relevant corners before assuming a rectangle. Fix pymupdf#2087: File `fitz.i`- if JPX image format is already known, make sure to read the decoded image stream, instead of raw stream in the other cases.
Fix #2110 (Discussion item #2111): File `__main__.py` - also include the font's xref in the generated file name. Fix #2094: File `helper-device.i' - also ensure equality of x coordinates of relevant corners before assuming a rectangle. Fix #2087: File `fitz.i`- if JPX image format is already known, make sure to read the decoded image stream, instead of raw stream in the other cases.
Fixed in PyMuPDF-1.21.1. |
Describe the bug (mandatory)
I found incorrect logic in the rectangle detection.
To Reproduce (mandatory)
Case 1
Passed the detection test
Case 2
Passed the detection test
My Solution
I have 2 solutions to resolve this issue
Solution 1
Only works if the line0 is horizontal
Solution 2
It can also detect rectangle if the line0 is vertical
Your configuration (mandatory)
3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]
win32
PyMuPDF 1.21.0: Python bindings for the MuPDF 1.21.0 library.
Version date: 2022-11-08 00:00:01.
Built for Python 3.9 on win32 (64-bit).
The text was updated successfully, but these errors were encountered: