pass image as reference

This commit is contained in:
2024-05-12 13:19:27 +02:00
parent fcfdf4add2
commit cb4c562214
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ fn main() {
let img = image::open(cfg.path)
.expect("Unable to open file");
let phash: u64 = desc.describe(img);
let phash: u64 = desc.describe(&img);
debug!("Phash integer:\n{phash}");
debug!("Phash binary:\n{phash:b}");
let output = URL_SAFE_NO_PAD.encode(phash.to_be_bytes());
+1 -1
View File
@@ -101,7 +101,7 @@ impl DCT {
}
impl Descriptor for DCT {
fn describe(&self, img: image::DynamicImage) -> u64 {
fn describe(&self, img: &image::DynamicImage) -> u64 {
let resized = self.resize(img);
let mut dct_values = self.dct(&resized);
debug!("DCT-coefficients:\n {}", print_matrix(dct_values));
+2 -2
View File
@@ -2,10 +2,10 @@ pub trait Descriptor {
fn info(&self) -> String {
"Descriptor".to_string()
}
fn resize(&self, img: image::DynamicImage) -> image::DynamicImage {
fn resize(&self, img: &image::DynamicImage) -> image::DynamicImage {
img.grayscale().thumbnail_exact(8, 8)
}
fn describe(&self, img: image::DynamicImage) -> u64;
fn describe(&self, img: &image::DynamicImage) -> u64;
fn distance(&self, a: u64, b: u64) -> u64 {
(a^b).count_ones().into()
}
+1 -1
View File
@@ -75,7 +75,7 @@ impl DescriptorStore {
continue
}
};
let phash = desc.describe(img);
let phash = desc.describe(&img);
self.map.insert(name, phash);
} else {
debug!("{} already known, skipping.", name);