Depth Map & Auxiliary API¶
Domain entities, physical metric depth conversions (ISO/IEC 23008-12 / ITU-T H.265), colormaps, and auxiliary image extractors.
DepthMap¶
pylibheif.DepthMap ¶
High-Dynamic Range & Metric Depth Map domain entity.
Encapsulates a HEIF depth image item, its representation info (ISO/IEC 23008-12), metric distance calculation, and zero-dependency pseudocolor visualization.
Maintains a strong reference to the master HeifImageHandle to guarantee memory safety and prevent premature garbage collection of native C++ handles.
info
cached
property
¶
Depth representation metadata (HeifDepthRepresentationInfo) if present.
decode ¶
Decode primary depth image and return as a 2D numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize
|
bool
|
If True, scale pixel values to float32 range [0.0, 1.0]. |
False
|
invert_if_disparity
|
bool
|
If True and data is disparity, invert values so 0.0 represents closest objects and 1.0 represents infinity. |
False
|
to_metric_depth ¶
Compute true physical metric distance matrix Z (in meters) as float32.
Uses the exact ISO/IEC 23008-12 and ITU-T H.265 Depth Representation formulas. Returns None if calibrated metric depth parameters (z_near / z_far) are absent.
to_pillow ¶
to_pillow(colormap: Optional[str] = 'turbo', size: Optional[Tuple[int, int]] = None, resample: Any = None) -> Any
Render depth map as a Pillow Image with zero external dependencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colormap
|
Optional[str]
|
'turbo' (default, high contrast), 'inferno', 'viridis', or 'grayscale'/'none'. |
'turbo'
|
size
|
Optional[Tuple[int, int]]
|
Optional (width, height) to resize the output depth image to match master image dimensions. |
None
|
resample
|
Any
|
Optional PIL resampling filter (defaults to BILINEAR if size is specified). |
None
|
AsyncDepthMap¶
pylibheif.AsyncDepthMap ¶
Asynchronous Depth Map domain entity attached to AsyncHeifImageHandle.
to_pillow ¶
to_pillow(colormap: Optional[str] = 'turbo', size: Optional[Tuple[int, int]] = None, resample: Any = None) -> Any
DepthRepresentationType¶
pylibheif.DepthRepresentationType ¶
Bases: enum.IntEnum
HEIF depth representation types according to ISO/IEC 23008-12 & ITU-T H.265 SEI.
NONUNIFORM_DISPARITY
class-attribute
¶
HEIF depth representation types according to ISO/IEC 23008-12 & ITU-T H.265 SEI.
UNIFORM_DISPARITY
class-attribute
¶
HEIF depth representation types according to ISO/IEC 23008-12 & ITU-T H.265 SEI.
UNIFORM_INVERSE_Z
class-attribute
¶
HEIF depth representation types according to ISO/IEC 23008-12 & ITU-T H.265 SEI.
UNIFORM_Z
class-attribute
¶
HEIF depth representation types according to ISO/IEC 23008-12 & ITU-T H.265 SEI.
__doc__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__format__
method descriptor
¶
Convert to a string according to format_spec.
Top-Level Extraction Helpers¶
pylibheif.extract_depth_map ¶
Inspect a HeifImageHandle and return a DepthMap domain entity if present, or None.
pylibheif.extract_portrait_matte ¶
Extract Apple Portrait Matte (hair/subject foreground alpha mask) if present.