refactor dct and quality
This commit is contained in:
@@ -13,22 +13,25 @@ pub trait Descriptor {
|
||||
|
||||
/// Interprets a 64-element array as an 8x8 matrix
|
||||
/// returns a nicely printable string
|
||||
fn print_matrix<T: ToString>(array: [T; 64]) -> String {
|
||||
fn print_matrix<T: ToString + std::fmt::Display>(array: [T; 64]) -> String {
|
||||
let mut output = String::new();
|
||||
for x in 0..8 {
|
||||
for y in 0..8 {
|
||||
output.push_str(&array[x*8+y].to_string());
|
||||
output.push_str(",\t");
|
||||
let element = format!("{:.2}", &array[x*8+y]);
|
||||
let element = format!("{:8}\t", element);
|
||||
output.push_str(&element);
|
||||
}
|
||||
output.push('\n');
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
/// A struct representing a Discrete Cosine Transform descriptor
|
||||
/// Transforms an image into an 8x8 grayscale version, and transforms it
|
||||
/// into the frequency domain
|
||||
pub struct DCT {
|
||||
quantization_matrix: [u8; 64],
|
||||
quantization_matrix: [u8; 64]
|
||||
}
|
||||
|
||||
pub mod dct;
|
||||
|
||||
// fn median64<T: Ord + Copy>(values: &[T]) -> T {
|
||||
|
||||
Reference in New Issue
Block a user