Skip to content

fix(image): correct HLG inverse-OETF clamp in hlg_to_linear#14762

Open
bigcat88 wants to merge 1 commit into
masterfrom
fix/core/hlg-to-linear-clamp
Open

fix(image): correct HLG inverse-OETF clamp in hlg_to_linear#14762
bigcat88 wants to merge 1 commit into
masterfrom
fix/core/hlg-to-linear-clamp

Conversation

@bigcat88

@bigcat88 bigcat88 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

hlg_to_linear (Save Image (Advanced), input_color_space=HDR) clamped its exp branch at _HLG_C (~0.5599) instead of the 0.5 branch point. Every HLG signal value in (0.500, 0.560] therefore produced the constant 0.10706 instead of the 0.0833->0.1071

Without patch Screenshot From 2026-07-04 10-55-44
With patch from this PR Screenshot From 2026-07-04 10-56-29
Additional data Screenshot From 2026-07-04 10-41-40 Screenshot From 2026-07-04 10-42-10

wf_plus_input_image.zip

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e08a2b12-c381-4f73-a920-56f84c08bce6

📥 Commits

Reviewing files that changed from the base of the PR and between 3fe9f5f and 611c728.

📒 Files selected for processing (1)
  • comfy_extras/nodes_images.py

📝 Walkthrough

Walkthrough

This change adjusts the hlg_to_linear function in comfy_extras/nodes_images.py. The clamping applied to the input of the log-branch exponential computation is changed from clamping at _HLG_C to clamping at the branch split point 0.5. The torch.where selection logic determining which branch's output is used remains unchanged.

Changes

File Change
comfy_extras/nodes_images.py Adjusted clamp bound in high-branch computation of hlg_to_linear from _HLG_C to 0.5

Related issues: None specified.

Related PRs: None specified.

Suggested labels: bug, image-processing

Suggested reviewers: None specified.

Poem: A rabbit tweaks a clamp so small,
From _HLG_C to point-five it falls,
The log branch now stays sane and bright,
No infinite glow to spoil the night,
A tiny hop, a fix worth all. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix to hlg_to_linear's HLG inverse-OETF clamp.
Description check ✅ Passed The description directly explains the HLG clamp bug and shows the expected before/after behavior for this patch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants