Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depth Images support #83

Closed
bigcat88 opened this issue Feb 25, 2023 · 10 comments
Closed

Depth Images support #83

bigcat88 opened this issue Feb 25, 2023 · 10 comments
Labels
enhancement New feature or request fixed Fixed in last version

Comments

@bigcat88
Copy link
Owner

In this commit I have added an example of such heic file taken on iPhone.

Here is the primary image:

pug

Here is the depth image:

test-depth

Here is an Aux image(urn/apple_photo/2020/aux/hdrgainmap):

test-urn_com_apple_photo_2020_aux_hdrgainmap

Does anyone need the opportunity to read them?

@bigcat88 bigcat88 added the enhancement New feature or request label Feb 25, 2023
@bigcat88 bigcat88 added this to the 1.0.0 milestone Apr 3, 2023
@bigcat88 bigcat88 removed this from the 1.0.0 milestone Jul 9, 2023
@wiggin15
Copy link

Yes please :)

@bigcat88
Copy link
Owner Author

I'll try to add support for depth image types in the next release

@bigcat88
Copy link
Owner Author

bigcat88 commented Jul 19, 2023

@wiggin15 If you need aux images support, please tell me in #117 where they can be used besides converting a photo to HDR?
And preferably some examples besides those generated by iPhone...

@bigcat88 bigcat88 changed the title Depth and Aux images read support - does it relevant? Depth images read support - does it relevant? Jul 19, 2023
@bigcat88 bigcat88 added the fixed in upcoming release fix will arrive with next release label Jul 19, 2023
@bigcat88 bigcat88 changed the title Depth images read support - does it relevant? Depth Images support Jul 20, 2023
bigcat88 added a commit that referenced this issue Jul 20, 2023
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
@bigcat88
Copy link
Owner Author

bigcat88 commented Jul 20, 2023

    im = Image.open("../tests/images/heif_other/pug.heic")
    depth_im = im.info["depth_images"][0]  # we know that there is a depth image
    # depth images are just `class HeifDepthImage(BaseImage)`, so work with them as usual pillow_heif's image 
    # depending on for what you need depth image you can convert it to numpy array or convert to pillow
    pil_im = depth_im.to_pillow()
    np_im = np.asarray(depth_im)
    print(pil_im)
    print(pil_im.info["metadata"])
<PIL.Image.Image image mode=L size=768x576 at 0x1069A7F50>
{'d_min': 1.498046875, 'd_max': 4.3828125, 'representation_type': 1, 'disparity_reference_view': 0, 'nonlinear_representation_model_size': 0}

@wiggin15
Copy link

Hi @bigcat88 thanks a lot for taking a look at this! We're trying to visualize datasets of photos taken by iPhone, so I have no examples outside this use case. Depth is important to our use case because we compare it to depth data created for the photos by external machine-learning algorithms. The HDR Gain Map data is less important to us specifically (but it could be nice for "completeness" of the visualization options we display to users).

@bigcat88 bigcat88 added fixed Fixed in last version and removed fixed in upcoming release fix will arrive with next release labels Aug 9, 2023
@bigcat88
Copy link
Owner Author

bigcat88 commented Aug 9, 2023

done, new version is out

@bigcat88 bigcat88 closed this as completed Aug 9, 2023
@gau-nernst
Copy link

    im = Image.open("../tests/images/heif_other/pug.heic")
    depth_im = im.info["depth_images"][0]  # we know that there is a depth image
    # depth images are just `class HeifDepthImage(BaseImage)`, so work with them as usual pillow_heif's image 
    # depending on for what you need depth image you can convert it to numpy array or convert to pillow
    pil_im = depth_im.to_pillow()
    np_im = np.asarray(depth_im)
    print(pil_im)
    print(pil_im.info["metadata"])
<PIL.Image.Image image mode=L size=768x576 at 0x1069A7F50>
{'d_min': 1.498046875, 'd_max': 4.3828125, 'representation_type': 1, 'disparity_reference_view': 0, 'nonlinear_representation_model_size': 0}

Hi @bigcat88, thank you for this useful library. Can you add this snippet to access depth image to the README file, so that it is more accessible? I keep going back to this issue just to see this snippet. I think others will appreciate this feature too :)

@bigcat88
Copy link
Owner Author

bigcat88 commented May 8, 2024

Good point, thanks and done!

@GaussianGuaicai
Copy link

Is there any support for save HEIF with depth images ?I try put it in im.info['depth_images'][0] and then im.save(), but the depth images wont save in file.

@bigcat88
Copy link
Owner Author

No, libheif does not currently have an API for this. I advise you to create a question there with a request to add such an API to their soon to be released version 1.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed Fixed in last version
Projects
None yet
Development

No branches or pull requests

4 participants