better dct maybe
This commit is contained in:
+12
-12
@@ -51,24 +51,24 @@ impl Descriptor for DCT {
|
||||
fn describe(&self, img: image::DynamicImage) -> u64 {
|
||||
let mut dct_values: [f64; 64] = [0.0; 64];
|
||||
let img = self.resize(img);
|
||||
let mut _total_sum: f64 = 0.0;
|
||||
|
||||
for j in 0..7 {
|
||||
for i in 0..7 {
|
||||
for v in 0..7 {
|
||||
for u in 0..7 {
|
||||
let k = (u*8)+v;
|
||||
let v: f64 = v as f64;
|
||||
let u: f64 = u as f64;
|
||||
let mut sum: f64 = 0.0;
|
||||
let k = (i*8)+j;
|
||||
for (x, y, pix) in img.pixels() {
|
||||
let n: f64 = ((y*8)+x).into();
|
||||
let pixel: i16 = pix[0] as i16 - 127;
|
||||
sum += pixel as f64 * (PI/64.0 * (n + 0.5) * k as f64).cos();
|
||||
let x: f64 = 1.0 + 2.0 * x as f64;
|
||||
let y: f64 = 1.0 + 2.0 * y as f64;
|
||||
let pixel = (pix[0] as i16 - 127) as f64;
|
||||
sum +=
|
||||
pixel *
|
||||
(x*u*PI/16.0).cos() *
|
||||
(y*v*PI/16.0).cos()
|
||||
}
|
||||
dct_values[k] = sum;
|
||||
_total_sum += sum;
|
||||
//println!("{sum}");
|
||||
}
|
||||
}
|
||||
_total_sum /= 64.0;
|
||||
|
||||
let mut mask: u64 = 0;
|
||||
for dct in dct_values {
|
||||
if dct > 0.0 {
|
||||
|
||||
Reference in New Issue
Block a user