modosaic.depth.visualization¶
modosaic.depth.visualization ¶
DepthVisualizationService ¶
Convert depth arrays into image visualizations.
depth_to_heatmap
staticmethod
¶
depth_to_heatmap(depth, size=None, colormap=cv2.COLORMAP_TURBO)
Convert a depth map to a color heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
Depth map. |
required |
size
|
tuple[int, int] | None
|
Optional output |
None
|
colormap
|
int
|
OpenCV color-map identifier. |
COLORMAP_TURBO
|
Returns:
| Type | Description |
|---|---|
Image
|
RGB PIL heatmap image. |
Source code in modosaic/depth/visualization.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
depth_to_image
staticmethod
¶
depth_to_image(depth, size=None)
Convert a depth map to a grayscale PIL image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
Depth map. |
required |
size
|
tuple[int, int] | None
|
Optional output |
None
|
Returns:
| Type | Description |
|---|---|
Image
|
PIL image visualization. |
Source code in modosaic/depth/visualization.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
normalize_to_uint8
staticmethod
¶
normalize_to_uint8(depth, eps=1e-08)
Normalize a depth map to an 8-bit grayscale array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
Depth map. |
required |
eps
|
float
|
Minimum denominator used to avoid division by zero. |
1e-08
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, float]
|
Normalized uint8 array, original minimum, and original maximum. |
Source code in modosaic/depth/visualization.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
overlay_depth
staticmethod
¶
overlay_depth(image, depth, alpha=0.55)
Blend a depth preview over an RGB image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Source image. |
required |
depth
|
ndarray
|
Depth map. |
required |
alpha
|
float
|
Blend factor for the depth image. |
0.55
|
Returns:
| Type | Description |
|---|---|
Image
|
Blended RGB image. |
Source code in modosaic/depth/visualization.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |