pub struct BlockHasher { /* private fields */ }Expand description
Block hash for perceptual image comparison.
Block hash divides the image into blocks and computes a hash based on the average brightness of each block compared to the overall image average.
§Algorithm
- Divide image into NxN blocks
- Compute average brightness for each block
- Compute overall image average
- Set bit to 1 if block average > image average, else 0
§Example
ⓘ
use figif_core::hashers::BlockHasher;
use figif_core::traits::FrameHasher;
let hasher = BlockHasher::new();
let hash = hasher.hash_frame(&image);Implementations§
Source§impl BlockHasher
impl BlockHasher
Sourcepub fn with_size(width: u32, height: u32) -> Self
pub fn with_size(width: u32, height: u32) -> Self
Create a block hasher with custom hash dimensions.
The hash size determines the number of blocks (width * height bits).
Sourcepub fn hash_width(&self) -> u32
pub fn hash_width(&self) -> u32
Get the hash width.
Sourcepub fn hash_height(&self) -> u32
pub fn hash_height(&self) -> u32
Get the hash height.
Trait Implementations§
Source§impl Clone for BlockHasher
impl Clone for BlockHasher
Source§fn clone(&self) -> BlockHasher
fn clone(&self) -> BlockHasher
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockHasher
impl Debug for BlockHasher
Source§impl Default for BlockHasher
impl Default for BlockHasher
Source§impl FrameHasher for BlockHasher
impl FrameHasher for BlockHasher
Source§fn hash_frame(&self, image: &RgbaImage) -> Self::Hash
fn hash_frame(&self, image: &RgbaImage) -> Self::Hash
Compute the perceptual hash for a single frame. Read more
Source§fn distance(&self, a: &Self::Hash, b: &Self::Hash) -> u32
fn distance(&self, a: &Self::Hash, b: &Self::Hash) -> u32
Compute the distance between two hashes. Read more
Source§fn suggested_threshold(&self) -> u32
fn suggested_threshold(&self) -> u32
Suggested threshold for considering frames as duplicates. Read more
Auto Trait Implementations§
impl Freeze for BlockHasher
impl RefUnwindSafe for BlockHasher
impl Send for BlockHasher
impl Sync for BlockHasher
impl Unpin for BlockHasher
impl UnsafeUnpin for BlockHasher
impl UnwindSafe for BlockHasher
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FrameHasherExt for Twhere
T: FrameHasher,
impl<T> FrameHasherExt for Twhere
T: FrameHasher,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more