darktable-org / darktable-org/darktable
Bezier-dewarping/flattening algorithm
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.1k
- Forks
- 1.4k
- Avg merge
- 22h 14m
- Merged PRs (30d)
- 198
Description
Problem description
I am active in the field of Early Music digitization and am using Darktable and Lightroom for post-processing of the photos of 16th/17th century prints and partbooks taken in libraries. Very often, the old books cannot be fully opened and due to the stiffness of the pages and their fragility, so I always end up with a certain warp in the photo towards the spine of the book no matter how I position the camera. Correcting this warp properly is not possible in neither Darktable nor Lightroom as the perspective or lens correction just does not allow for a "bezier-curved" stretching. I have tried using the Liquify-module to approach the problem, but it is too regional of an approach.
Possible solution
I would love to use a dewarp module which lets me define 4 bezier curves (one at the top, one at the bottom, one on the left page side and one on the right) and then stretches the content to a rectangle. Ideally, the module offers an automatic warp detection comparable to the perspective correction, which identifies the 4 bezier curves based on the warping of the content on the page and lets me adjust the curves if identified incorrectly. A more sophisticated version would also allow to toggle between single page and facing pages and identify the spine. In the latter case, there would need to be six bezier curves (left page left side, left page top, left page bottom, right page right side, right page top, right page bottom + maybe spine).
Alternatives
A Bezier-dewarping is described in different scanning softwares, such as
Scantailor Spectre: "Dewarping - Flattens curved pages from book spines. Set to “Auto” for automatic detection or “Manual” to adjust control points yourself. Most useful for thick books where pages curve near the spine."
Scantailor Advanced: "Marginal dewarping. An automatic dewarping mode. Works ONLY with such raw scans that have the top and bottom curved page borders (on the black background). It automatically sets the red points of the blue mesh along these borders (to create a distortion model) and then dewarps the scan according to them. Works best on the low-curved scans."
Booksorber: "Pages are flattened by detecting their curved boundaries and using this information to build a 3-dimensional model of the surface to correct for warping in the image. The boundaries are modeled by Bezier curves with four control points known from (vector) graphic design programs. One main feature is the automatic detection of those boundaries, but they can be manually adjusted as well."
Digitization ecosystems like CZUR: Offers "auto-flattening", but only in combination with their machine.
The following screenshots hopefully visualize the problem (taken from czur.com and booksorber.com)
I would be really grateful for any help.
Kind regards,
Jakob
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files, tests, or entry points. Start by turning the proposed manual and automatic Bezier-curve workflows into a scoped design, using the cited ScanTailor Spectre, ScanTailor Advanced, and Booksorber behavior as references. Done should include an agreed dewarping workflow and acceptance criteria for single and facing pages.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-vision
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100