fix(visualization): scale top y-edge by scale_y in draw_clusters#3790
Open
anxkhn wants to merge 1 commit into
Open
fix(visualization): scale top y-edge by scale_y in draw_clusters#3790anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
The top y-coordinate of debug cluster boxes and cells in draw_clusters was multiplied by scale_x while the matching bottom y-coordinate used scale_y. When the rasterized image aspect ratio differs from the page aspect ratio (scale_x != scale_y), this misplaces the top edge of every drawn rectangle. Scale both y-edges with scale_y, matching the correct pattern already used in the table structure and layout models. This only affects debug visualization overlays gated behind the debug settings; conversion output is unchanged. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @anxkhn, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
dolfim-ibm
reviewed
Jul 14, 2026
| @@ -0,0 +1,37 @@ | |||
| from docling_core.types.doc import BoundingBox, CoordOrigin, DocItemLabel | |||
Member
There was a problem hiding this comment.
@anxkhn this looks good but we would prefer to drop this test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
draw_clustersthe top y-coordinate of debug cluster boxes and their cellswas multiplied by
scale_x, while the matching bottom y-coordinate on the nextline correctly used
scale_y:scale_x = image.width / page.size.widthandscale_y = image.height / page.size.heightdiffer whenever the rasterized imageaspect ratio does not match the page aspect ratio (for example rendering/OCR at a
DPI that does not preserve aspect). In that case the top edge of every drawn box
is misplaced, distorting the overlay (and for a box whose scaled top passes its
bottom it can invert).
This changes the two top-edge lines to use
scale_y, so both y-edges scale byscale_y. That matches the pattern already used consistently elsewhere in therepo (
table_structure_model.py,table_structure_model_v2.py,layout_object_detection_model.py) and the earlier fix for the same axis bug inthe table model (#2287).
The change only affects debug visualization overlays gated behind the debug
settings (
visualize_cells/visualize_raw_layout/visualize_layout); theDoclingDocumentconversion output is unchanged, and it is a no-op under uniformscaling (
scale_x == scale_y), so no reference data is regenerated.A focused regression test captures the coordinates handed to
ImageDraw.rectangleunder non-uniform scaling and asserts both y-edges equalbbox.t/b * scale_y.Checklist: