resize function refactor
This commit is contained in:
+5
-2
@@ -5,6 +5,9 @@ pub trait Descriptor {
|
||||
fn info(&self) -> String {
|
||||
"Descriptor".to_string()
|
||||
}
|
||||
fn resize(&self, img: image::DynamicImage) -> image::DynamicImage {
|
||||
img.grayscale().thumbnail_exact(8, 8)
|
||||
}
|
||||
fn describe(&self, img: image::DynamicImage) -> u64;
|
||||
fn distance(&self, a: u64, b: u64) -> u64 {
|
||||
(a^b).count_ones().into()
|
||||
@@ -22,7 +25,7 @@ pub struct Median;
|
||||
|
||||
impl Descriptor for Median {
|
||||
fn describe(&self, img: image::DynamicImage) -> u64 {
|
||||
let img = img.grayscale().thumbnail_exact(8, 8);
|
||||
let img = self.resize(img);
|
||||
let mut values: [u8; 64] = [0; 64];
|
||||
let mut i: usize = 0;
|
||||
for (_, _, pix) in img.pixels() {
|
||||
@@ -47,7 +50,7 @@ pub struct DCT;
|
||||
impl Descriptor for DCT {
|
||||
fn describe(&self, img: image::DynamicImage) -> u64 {
|
||||
let mut dct_values: [f64; 64] = [0.0; 64];
|
||||
let img = img.grayscale().thumbnail_exact(8, 8);
|
||||
let img = self.resize(img);
|
||||
let mut total_sum: f64 = 0.0;
|
||||
|
||||
for j in 0..7 {
|
||||
|
||||
Reference in New Issue
Block a user