🧮 Image Operations¶
This document describes the image adjustment operations implemented in CaptureMoment, including their mathematical formulas and implementation details.
🧮 Tone Adjustments¶
Brightness¶
- Purpose: Adjusts the overall lightness or darkness of an image.
- Color Space: Operations are applied in Oklab perceptual color space. Brightness adjustments modify the L channel (perceptual luminance) directly.
- Formula: For each pixel
pin Oklab space: Wherevalueis the brightness adjustment factor (typically in the range [-1.0, 1.0]). - Implementation:
OperationBrightnessincore/operations/basic_adjustment_operations/. - QML Model:
BrightnessModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
Contrast¶
- Purpose: Adjusts the difference in perceptual lightness in different parts of an image.
- Color Space: Operations are applied in Oklab perceptual color space. Contrast adjustments modify the L channel centered at mid-gray (0.5).
- Formula: For each pixel
pin Oklab space: Wherevalueis the contrast adjustment factor (typically in the range [-1.0, 1.0]). A value of 0 means no change. - Implementation:
OperationContrastincore/operations/basic_adjustment_operations/. - QML Model:
ContrastModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
Highlights¶
- Purpose: Adjusts the perceptual luminosity of the brightest areas of the image.
- Color Space: Operations are applied in Oklab perceptual color space. Adjustments target the L channel using a smooth mask.
- Formula (Approximation): A smoothstep mask based on Oklab L channel is created. Pixels with L above a threshold (0.7) are adjusted: The smoothstep mask ensures gradual transitions without banding in the highlight roll-off.
- Implementation:
OperationHighlightsincore/operations/basic_adjustment_operations/. - QML Model:
HighlightsModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
Shadows¶
- Purpose: Adjusts the perceptual luminosity of the darkest areas of the image.
- Color Space: Operations are applied in Oklab perceptual color space. Adjustments target the L channel using a smooth mask.
- Formula (Approximation): A smoothstep mask based on Oklab L channel is created. Pixels with L below a threshold (0.5) are adjusted: The smoothstep mask ensures gradual transitions without banding in the shadow roll-off.
- Implementation:
OperationShadowsincore/operations/basic_adjustment_operations/. - QML Model:
ShadowsModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
Whites¶
- Purpose: Adjusts the perceptual luminosity of the extreme white point of the image.
- Color Space: Operations are applied in Oklab perceptual color space. Adjustments target the L channel using a smooth mask for extreme highlights.
- Formula (Approximation): A smoothstep mask based on Oklab L channel is created. Pixels with very high L (above 0.85) are adjusted: The mask ensures only the extreme highlights are primarily affected, preserving upper midtones.
- Implementation:
OperationWhitesincore/operations/basic_adjustment_operations/. - QML Model:
WhitesModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
Blacks¶
- Purpose: Adjusts the perceptual luminosity of the extreme black point of the image.
- Color Space: Operations are applied in Oklab perceptual color space. Adjustments target the L channel using a smooth mask for deep shadows.
- Formula (Approximation): A smoothstep mask based on Oklab L channel is created. Pixels with very low L (below 0.3) are adjusted: The mask ensures only the deep shadows are primarily affected, preserving lower midtones.
- Implementation:
OperationBlacksincore/operations/basic_adjustment_operations/. - QML Model:
BlacksModelinqt/core/models/operations/basic_adjustment_models/. - Fusion Support: Implements
IOperationFusionLogicinterface withappendToFusedPipelinemethod for pipeline fusion optimization.
🧮 Implementation Notes¶
- Core: Operations are implemented as classes inheriting from
IOperationin theCore::Operationsnamespace. - Fusion Logic: Operations also implement
IOperationFusionLogicinterface to support pipeline fusion optimization. - Sequential Method: Each operation maintains a
[[maybe_unused]] executemethod for sequential processing compatibility. - QML Models: UI-specific models inherit from
BaseAdjustmentModelwhich provides common properties (value,minimum,maximum,name,active) and Qt infrastructure. - Halide: Many operations use the Halide library for efficient image processing on the CPU/GPU.
- Oklab Color Space: All tone adjustments operate in Oklab perceptual color space. The L channel represents perceptual luminance, enabling more natural and uniform adjustments compared to RGB luminance formulas.
- Channel Isolation: Adjustments are applied only to the L channel (
c == 0). The a, b, and Alpha channels are preserved unchanged to prevent hue shifts and maintain color fidelity. - Smoothstep Masks: Mask generation uses the smoothstep polynomial
3t² - 2t³instead of linear interpolation, eliminating harsh transitions and banding artifacts in shadow/highlight roll-offs. - No Intermediate Clamping: Operations do not clamp the L channel during processing. Clamping is applied only after conversion back to RGB (
oklab_to_rgb) to prevent hue shifts caused by clamping L while a and b are non-zero. - Pipeline Fusion: Operations contribute their logic to combined computational graphs through the
appendToFusedPipelinemethod, eliminating intermediate buffer copies. The full pipeline follows the flow:RGB → Oklab → fused operations → RGB.