verify align hash output with imagehash#25
Merged
Conversation
|
Here's the code health analysis summary for commits Analysis Summary
|
CodSpeed Performance ReportMerging #25 will not alter performanceComparing Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
aHash
Now uses
1 << (63 - i)so that the most significant bit corresponds to the first pixel, matching imagehash’s convention.mHash
Bit order is reversed (using
1 << (63 - i)) to align with other hash types.Uses Rust’s
select_nth_unstableto compute the median in O(n) time instead of a full sort.dHash
Retrieves the first pixel outside the inner loop (iterating from x = 1 to 8) to avoid redundant calls.
pHash
Applies the DCT row‑wise and then column‑wise in place using a fixed‑size temporary array.
Extracts the top‑left 8×8 DCT coefficients and excludes the DC component when computing the median.
Uses
select_nth_unstable_byto find median in O(n).Final hash bits are reversed (using
1 << (63 - i)) for consistency with the other algorithms.Produces a pHash that is consistent with imagehash.
wHash (Wavelet Hash)
Now uses
1 << (63 - i)so that the most significant bit corresponds to the first pixel, matching imagehash’s convention.Implement Haar transform functions from the
dwtcrate.Immediately zero out the DC coefficient after forward transform.
Clones transformed pixel vector and uses
select_nth_unstable_byto find median in O(n).Iterates over the reconstructed coefficients from the inverse Haar transform, setting bits based on the median, to conform to imagehash’s output.
Produces a wHash that is consistent with imagehash.
Each change was made to improve performance, and ensure consistent bit ordering across all hash types, and simplify the implementations and align hash output with imagehash for consistency.