-
Notifications
You must be signed in to change notification settings - Fork 11
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
new_from_memory / write_to_memory #12
Comments
Sure, this is a great idea! Are you OK doing this? I'm working on a JS binding now and I ought to get that done before I switch languages again. dHash is rather old, fwiw, I know it from the 1980s and it's probably older than that. I would do it slightly differently: shrink to 8x8 greyscale, find image average, then set bits depending on whether the pixel is brighter or darker than the image average. This has the same independence from brightness property you get with the difference image, but saves you computing left-right differences. You can also look at the images and guess what they represent, which you can't with a left-right diff. |
I'm OK with implementing this. You can expect a pull request on the weekend. Wow, I didn't know that dHash already existed since 1980s. Your hash calculation sounds like an average hash. I tried to implement this and it seems not to work for sequential access. (I think this is fixable when there is a By the way, |
Oh heh yes, I described aHash. I suppose dHash is a little better for non-linear lightness changes. |
I think this is all done now, I'll close and update pecl. Good job! |
It would be nice to wrap an image around a memory array or to write an image to a large memory array. This can be useful for moving images between libvips and imagemagick or to calculate the perceptual hash of an image (see below).
The new functions can be named like this:
Extension:
new_from_memory
,write_to_memory
.php-vips:
Image::newFromMemory
,->writeToMemory
.I can open a PR at the php layer to support these new functions if this has been implemented in the extension.
If you are wondering why I need this:
For our test cases we are calculating the perceptual hash of an image (based on the dHash algorithm) to verify the similarity of expected vs actual images (using a distance threshold). It looks like this (so
->copyMemory
and->getpoint
are the important ones). If there's a->writeToMemory
function it could be somewhat optimized.The text was updated successfully, but these errors were encountered: