y5gfunc.filter.tonemap¶
tonemap
¶
Classes:
| Name | Description |
|---|---|
ColorSpace |
Color spaces used in tonemapping operations. |
ColorPrimaries |
Color primaries standards. |
GamutMapping |
Gamut mapping functions. |
ToneMappingFunction |
Tone mapping functions. |
Metadata |
Metadata sources for tone-mapping. |
Functions:
| Name | Description |
|---|---|
tonemap |
Color mapping using placebo.Tonemap. |
ColorSpace
¶
Bases: IntEnum
Color spaces used in tonemapping operations.
Attributes:
| Name | Type | Description |
|---|---|---|
SDR |
Standard Dynamic Range |
|
HDR10 |
High Dynamic Range (HDR10) |
|
HLG |
Hybrid Log-Gamma |
|
DOLBY_VISION |
Dolby Vision |
ColorPrimaries
¶
Bases: IntEnum
Color primaries standards.
Attributes:
| Name | Type | Description |
|---|---|---|
UNKNOWN |
Unknown primaries |
|
BT601_525 |
ITU-R Rec. BT.601 (525-line = NTSC, SMPTE-C) |
|
BT601_625 |
ITU-R Rec. BT.601 (625-line = PAL, SECAM) |
|
BT709 |
ITU-R Rec. BT.709 (HD), also sRGB |
|
BT470M |
ITU-R Rec. BT.470 M |
|
EBU_TECH_3213E |
EBU Tech. 3213-E / JEDEC P22 phosphors |
|
BT2020 |
ITU-R Rec. BT.2020 (UltraHD) |
|
APPLE_RGB |
Apple RGB |
|
ADOBE_RGB |
Adobe RGB (1998) |
|
PROPHOTO_RGB |
ProPhoto RGB (ROMM) |
|
CIE1931_RGB |
CIE 1931 RGB primaries |
|
DCI_P3 |
DCI-P3 (Digital Cinema) |
|
DCI_P3_D65 |
DCI-P3 (Digital Cinema) with D65 white point |
|
V_GAMUT |
Panasonic V-Gamut (VARICAM) |
|
S_GAMUT |
Sony S-Gamut |
|
FILM_C |
Traditional film primaries with Illuminant C |
|
ACES0 |
ACES Primaries #0 (ultra wide) |
|
ACES1 |
ACES Primaries #1 |
GamutMapping
¶
Bases: IntEnum
Gamut mapping functions.
Attributes:
| Name | Type | Description |
|---|---|---|
CLIP |
Performs no gamut-mapping, just hard clips out-of-range colors per-channel |
|
PERCEPTUAL |
Performs a perceptually balanced (saturation) gamut mapping with a soft knee function |
|
SOFTCLIP |
Performs perceptually balanced gamut mapping using a soft knee function and hue shifting |
|
RELATIVE |
Performs relative colorimetric clipping, maintaining exponential brightness/chromaticity relationship |
|
SATURATION |
Performs simple RGB->RGB saturation mapping; never clips but may distort hues |
|
ABSOLUTE |
Performs absolute colorimetric clipping without adapting white point |
|
DESATURATE |
Performs constant-luminance colorimetric clipping, desaturating colors towards white |
|
DARKEN |
Uniformly darkens the input to prevent highlight clipping, then clamps colorimetrically |
|
HIGHLIGHT |
Performs no gamut mapping, but highlights out-of-gamut pixels |
|
LINEAR |
Linearly/uniformly desaturates the image to bring it into the target gamut |
ToneMappingFunction
¶
Bases: IntEnum
Tone mapping functions.
Attributes:
| Name | Type | Description |
|---|---|---|
CLIP |
No tone-mapping, just clips out-of-range colors |
|
SPLINE |
Simple spline consisting of two polynomials joined by a pivot point |
|
ST2094_40 |
EETF from SMPTE ST 2094-40 Annex B, using Bezier curves |
|
ST2094_10 |
EETF from SMPTE ST 2094-10 Annex B.2 |
|
BT2390 |
EETF from ITU-R Report BT.2390, a hermite spline roll-off with linear segment |
|
BT2446A |
EETF from ITU-R Report BT.2446, method A |
|
REINHARD |
Simple non-linear curve named after Erik Reinhard |
|
MOBIUS |
Generalization of reinhard algorithm (legacy/low-quality) |
|
HABLE |
Piece-wise, filmic tone-mapping algorithm by John Hable (legacy/low-quality) |
|
GAMMA |
Fits a gamma (power) function between source and target (legacy/low-quality) |
|
LINEAR |
Linearly stretches input range to output range in PQ space |
|
LINEARLIGHT |
Like LINEAR but in linear light instead of PQ |
Metadata
¶
tonemap
¶
tonemap(clip: VideoNode, src_csp: ColorSpace, dst_csp: ColorSpace, dst_prim: Optional[Union[ColorPrimaries, Primaries]] = None, src_max: Optional[Union[float, int]] = None, src_min: Optional[Union[float, int]] = None, dst_max: Optional[Union[float, int]] = None, dst_min: Optional[Union[float, int]] = None, dynamic_peak_detection: bool = True, smoothing_period: Union[float, int] = 20.0, scene_threshold_low: Union[float, int] = 1.0, scene_threshold_high: Union[float, int] = 3.0, percentile: Union[float, int] = 99.995, gamut_mapping: GamutMapping = PERCEPTUAL, tone_mapping_function: ToneMappingFunction = SPLINE, tone_mapping_param: Optional[Union[float, int]] = None, metadata: Metadata = AUTO, use_dovi: Optional[bool] = None, visualize_lut: bool = False, show_clipping: bool = False, contrast_recovery: Union[float, int] = 0.3, log_level: int = 2) -> VideoNode
Color mapping using placebo.Tonemap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
VideoNode
|
Input video clip |
required |
|
ColorSpace
|
Source colorspace (SDR, HDR10, HLG, DOLBY_VISION) |
required |
|
ColorSpace
|
Destination colorspace (SDR, HDR10, HLG, DOLBY_VISION) |
required |
|
Optional[Union[ColorPrimaries, Primaries]]
|
Destination color primaries |
None
|
|
Optional[Union[float, int]]
|
Source maximum display level in nits (cd/m²) |
None
|
|
Optional[Union[float, int]]
|
Source minimum display level in nits (cd/m²) |
None
|
|
Optional[Union[float, int]]
|
Destination maximum display level in nits (cd/m²) |
None
|
|
Optional[Union[float, int]]
|
Destination minimum display level in nits (cd/m²) |
None
|
|
bool
|
Enables HDR peak detection |
True
|
|
Union[float, int]
|
Smoothing coefficient for detected values (in frames) |
20.0
|
|
Union[float, int]
|
Lower bound for scene change detection (in units of 1% PQ) |
1.0
|
|
Union[float, int]
|
Upper bound for scene change detection (in units of 1% PQ) |
3.0
|
|
Union[float, int]
|
Percentile of brightness histogram to consider as true peak |
99.995
|
|
GamutMapping
|
Gamut mapping function to handle out-of-gamut colors |
PERCEPTUAL
|
|
ToneMappingFunction
|
Tone mapping function |
SPLINE
|
|
Optional[Union[float, int]]
|
Optional parameter for tone mapping function |
None
|
|
Metadata
|
Data source to use when tone-mapping |
AUTO
|
|
Optional[bool]
|
Whether to use Dolby Vision RPU for ST2086 metadata |
None
|
|
bool
|
Display a (PQ-PQ) graph of the active tone-mapping LUT |
False
|
|
bool
|
Highlight hard-clipped pixels during tone-mapping |
False
|
|
Union[float, int]
|
HDR contrast recovery strength |
0.3
|
|
int
|
Logging verbosity level |
2
|
Returns:
| Type | Description |
|---|---|
VideoNode
|
Tonemapped video clip |
Source code in y5gfunc/filter/tonemap.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |