feat(koptcontext): Add getAllPanelsFromPage() for panel detection#2257
Open
vmanojkumar wants to merge 2 commits intokoreader:masterfrom
Open
feat(koptcontext): Add getAllPanelsFromPage() for panel detection#2257vmanojkumar wants to merge 2 commits intokoreader:masterfrom
vmanojkumar wants to merge 2 commits intokoreader:masterfrom
Conversation
Frenzie
reviewed
Jan 21, 2026
ffi/koptcontext.lua
Outdated
Comment on lines
+496
to
+510
| for box in boxaIterBoxes(bb) do | ||
| local pix_tmp = _gc_ptr(leptonica.pixClipRectangle(pixs, box, nil), pixDestroy) | ||
| local w = leptonica.pixGetWidth(pix_tmp) | ||
| local h = leptonica.pixGetHeight(pix_tmp) | ||
| -- check if it's panel or part of the panel, if it's part of the panel skip | ||
| if w >= img_w / 8 and h >= img_h / 8 then | ||
| local box_x, box_y, box_w, box_h = boxGetGeometry(box) | ||
| table.insert(panels, { | ||
| x = box_x, | ||
| y = box_y, | ||
| w = box_w, | ||
| h = box_h, | ||
| }) | ||
| end | ||
| end |
Member
There was a problem hiding this comment.
Couldn't this be simplified to something like this (untested both functionally and performance-wise, regard as pseudocode)?
Suggested change
| for box in boxaIterBoxes(bb) do | |
| local pix_tmp = _gc_ptr(leptonica.pixClipRectangle(pixs, box, nil), pixDestroy) | |
| local w = leptonica.pixGetWidth(pix_tmp) | |
| local h = leptonica.pixGetHeight(pix_tmp) | |
| -- check if it's panel or part of the panel, if it's part of the panel skip | |
| if w >= img_w / 8 and h >= img_h / 8 then | |
| local box_x, box_y, box_w, box_h = boxGetGeometry(box) | |
| table.insert(panels, { | |
| x = box_x, | |
| y = box_y, | |
| w = box_w, | |
| h = box_h, | |
| }) | |
| end | |
| end | |
| for box_x, box_y, box_w, box_h in boxaIterBoxGeometries(bb) do | |
| if box_w >= img_w / 8 and box_h >= img_h / 8 then | |
| panels[#panels + 1] = { x = box_x, y = box_y, w = box_w, h = box_h } | |
| end | |
| end |
b4071ef to
ceb81d8
Compare
Frenzie
reviewed
Jan 31, 2026
| h = box_h, | ||
| } | ||
| break -- we found panel, exit the loop and clean up memory | ||
| res = { x = box_x, y = box_y, w = box_w, h = box_h } |
Member
There was a problem hiding this comment.
Let's keep that spread out so it doesn't show as changed in the diff. I just randomly wrote it on one line without thinking about anything like that. :-)
Add a new method to detect all panels on a page using Leptonica's
connected component analysis. This enables panel-by-panel navigation
for comics and manga in KOReader.
Returns an array of panel bounding boxes {x, y, w, h} for panels
that are at least 1/8 of page dimensions (filtering out small elements).
…actor panel filtering
ceb81d8 to
4238faf
Compare
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.
Add a new method to detect all panels on a page using Leptonica's connected component analysis. This enables panel-by-panel navigation for comics and manga in KOReader.
Returns an array of panel bounding boxes {x, y, w, h} for panels that are at least 1/8 of page dimensions (filtering out small elements).
This change is