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

Color hashing with alpha channel? #122

Open
Sariellee opened this issue Oct 29, 2020 · 5 comments
Open

Color hashing with alpha channel? #122

Sariellee opened this issue Oct 29, 2020 · 5 comments

Comments

@Sariellee
Copy link

The new colorhash is great, it gives me the possibility to hash images based on color; combining that with other hash (aHash etc) lets users find matching images with great accuracy.
However, I am now working with images with alpha channels, which make difference a lot. Is there any possibility to hash images including the alpha channel into the hash? I haven't found any papers on this topic, but if there is a way, it would be great to include it into this library.

@JohannesBuchner
Copy link
Owner

How about projecting onto a white or black background and removing the alpha channel? Presumably you want two images that look the same.

@Sariellee
Copy link
Author

Images containing 100% transparent background usually have RGB channels as (0,0,0), so even manual projection is unnecessary. However, the blacks (or whites) can occur in the image itself, which would probably make the colorhash more lossy, but that can still work as a workaround.
Another workaround that I've come up with is:

  • hash the RGB part with colorhash
  • hash the alpha channel image with aHash or pHash
  • use them in a combination to determine similarness of the image

But that still is a workaround which will be more precise, but require 2x computations. It would be nice if there existed a colorhash alternative with the support for alpha channels.

@JohannesBuchner
Copy link
Owner

You mean including a rounded fraction of the image with 100% transparency?

@Sariellee
Copy link
Author

Yes

@JohannesBuchner
Copy link
Owner

Can you post here how you extract a alpha channel image (which is I guess then used as a grayscale image)?

From that it should be easy to compute the transparent fraction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants