Convert a NumPy depth image or a batch of images to a PIL image.
(self, images: np.ndarray)
| 712 | return image[:, :, 1] * 2**8 + image[:, :, 2] |
| 713 | |
| 714 | def numpy_to_depth(self, images: np.ndarray) -> List[PIL.Image.Image]: |
| 715 | """ |
| 716 | Convert a NumPy depth image or a batch of images to a PIL image. |
| 717 | """ |
| 718 | if images.ndim == 3: |
| 719 | images = images[None, ...] |
| 720 | images_depth = images[:, :, :, 3:] |
| 721 | if images.shape[-1] == 6: |
| 722 | images_depth = (images_depth * 255).round().astype("uint8") |
| 723 | pil_images = [ |
| 724 | Image.fromarray(self.rgblike_to_depthmap(image_depth), mode="I;16") for image_depth in images_depth |
| 725 | ] |
| 726 | elif images.shape[-1] == 4: |
| 727 | images_depth = (images_depth * 65535.0).astype(np.uint16) |
| 728 | pil_images = [Image.fromarray(image_depth, mode="I;16") for image_depth in images_depth] |
| 729 | else: |
| 730 | raise Exception("Not supported") |
| 731 | |
| 732 | return pil_images |
| 733 | |
| 734 | def postprocess( |
| 735 | self, |
no test coverage detected