pub struct ImageMultiHash {
pub segment_hashes: Vec<Hash>,
}Expand description
A collection of per-segment hashes produced by crop_resistant_hash.
Distance (subtract) returns a f64 — not an integer — because it sums
best-match Hamming distances and applies a penalty for unmatched segments.
Fields§
§segment_hashes: Vec<Hash>Implementations§
Source§impl ImageMultiHash
impl ImageMultiHash
Sourcepub fn subtract(&self, other: &Self) -> f64
pub fn subtract(&self, other: &Self) -> f64
Returns the float distance between two ImageMultiHash objects.
Matches Python ImageMultiHash.__sub__:
matches, sum_distance = self.hash_diff(other)
max_difference = len(self.segment_hashes)
if matches == 0: return max_difference
max_distance = matches * len(self.segment_hashes[0])
tie_breaker = -(sum_distance / max_distance)
match_score = matches + tie_breaker
return max_difference - match_scorepub fn subtract_with( &self, other: &Self, hamming_cutoff: Option<f64>, bit_error_rate: Option<f64>, ) -> f64
Sourcepub fn hash_diff(
&self,
other: &Self,
hamming_cutoff: Option<f64>,
bit_error_rate: Option<f64>,
) -> (usize, usize)
pub fn hash_diff( &self, other: &Self, hamming_cutoff: Option<f64>, bit_error_rate: Option<f64>, ) -> (usize, usize)
Returns (matches, sum_of_hamming_distances) for segments within cutoff.
Matches Python ImageMultiHash.hash_diff.
Sourcepub fn matches(
&self,
other: &Self,
region_cutoff: usize,
hamming_cutoff: Option<f64>,
bit_error_rate: Option<f64>,
) -> bool
pub fn matches( &self, other: &Self, region_cutoff: usize, hamming_cutoff: Option<f64>, bit_error_rate: Option<f64>, ) -> bool
True if at least region_cutoff segments match within the hamming cutoff.
Sourcepub fn best_match<'a>(&self, others: &'a [Self]) -> Option<&'a Self>
pub fn best_match<'a>(&self, others: &'a [Self]) -> Option<&'a Self>
Returns the ImageMultiHash in others that minimizes self.subtract(other).
Trait Implementations§
Source§impl Clone for ImageMultiHash
impl Clone for ImageMultiHash
Source§impl Debug for ImageMultiHash
impl Debug for ImageMultiHash
Auto Trait Implementations§
impl Freeze for ImageMultiHash
impl RefUnwindSafe for ImageMultiHash
impl Send for ImageMultiHash
impl Sync for ImageMultiHash
impl Unpin for ImageMultiHash
impl UnsafeUnpin for ImageMultiHash
impl UnwindSafe for ImageMultiHash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more