darktable-org / darktable-org/darktable
Rotate and perspective module: perspective correction skewed with (automatically) resized images
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.1k
- Forks
- 1.4k
- Avg merge
- 22h 14m
- Merged PRs (30d)
- 198
Description
Is there an existing issue for this?
- I checked and did not find my issue in the already reported ones
Describe the bug
In rotate and perspective, the two manual ways of defining structure — "manually define perspective rectangle" and "manually draw structure lines" — give wrong results on images where an earlier module changes the image dimensions (as it is done with Fuji SuperCCD RAF images). Automatic line analysis on the same image is correct.
Steps to reproduce
- Open a Fuji Super CCD raw file (e.g. FinePix S100FS .RAF). These get rotate pixels applied automatically, which changes the image dimensions.
- In rotate and perspective, click "manually define perspective rectangle" and place the four handles on the corners of something rectangular in the scene.
- Click the vertical + horizontal fit button.
The image comes out rotated and skewed.
Further observations
- Every modifier variant of the fit buttons is equally wrong, including the rotation-only fit. A rotation-only fit cannot skew an image, so the line data must be wrong rather than the solver.
- "Automatically analyse line structure in image" on the same image gives a perfect correction.
Expected behavior
the rectangle is corrected to a rectangle.
Logfile | Screenshot | Screencast
No response
Commit
No response
Where did you obtain darktable from?
self compiled
darktable version
5.7.0+762~gefee9282a0
What OS are you using?
Windows
What is the version of your OS?
11
Describe your system
No response
Are you using OpenCL GPU in darktable?
Yes
If yes, what is the GPU card and driver?
No response
Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip
WARNING: The below "Cause" and "Possible direction for a fix" are from Claude AI
Cause
The manual methods record the reference size that their line coordinates are measured against as the pixelpipe's input size — the size before any module has run. The automatic analysis instead uses the module's own input size.
Normally nothing resizes the image before this module, so the two are the same and the value happens to be correct. When rotate pixels is active (for instance with Fuji SuperCCD images from S100FS camera) they differ, and the manual methods then fit against the wrong image geometry: both the wrong aspect ratio and the wrong image center.
Possible direction for a fix
In src/iop/ashift.c, the manual paths take these dimensions from piece->iwidth/iheight, which is the whole pipe's input; the working automatic path uses the module's own input buffer. Taking them from piece->buf_in instead makes the manual methods agree with the automatic one. There are four such places: the rectangle setup, the draw-lines setup, and the two restore-from-saved-parameters paths.
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
Start in src/iop/ashift.c and inspect the manual rectangle, draw-lines, and saved-parameter restoration paths, comparing their dimensions with the automatic analysis path. Reproduce with a Fuji SuperCCD RAF image whose dimensions were changed earlier in the pipe; done means the manual fit methods produce the same uns skewed rectangle correction as automatic analysis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100