Update mod.rs

This commit is contained in:
SirTalksalot75 2023-06-17 13:55:26 +02:00 committed by GitHub
parent fb8cc9fce2
commit d1f2ff5556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -1,3 +1,5 @@
use std::sync::Arc;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
enum FeatureResult { enum FeatureResult {
/// A boolean. Just a boolean /// A boolean. Just a boolean
@ -37,7 +39,7 @@ impl PartialEq for FeatureResult {
} }
} }
type FeatureGenerator = Box<dyn Fn(crate::Image<f32>) -> (String, FeatureResult)>; type FeatureGenerator = Box<dyn Fn(crate::Arc<Image<f32>>) -> (String, FeatureResult)>;
#[derive(Serialize, Deserialize, Default)] #[derive(Serialize, Deserialize, Default)]
struct Database { struct Database {
@ -79,7 +81,7 @@ impl Database {
} }
} }
fn average_luminance(image: Image<f32>) -> (String, FeatureResult) { fn average_luminance(image: Arc<Image<f32>>) -> (String, FeatureResult) {
let num_pixels = image.pixels.len() as u32; let num_pixels = image.pixels.len() as u32;
let total_brightness: f32 = image.pixels let total_brightness: f32 = image.pixels
.iter() .iter()
@ -92,7 +94,7 @@ fn average_luminance(image: Image<f32>) -> (String, FeatureResult) {
(feature_name, feature_result) (feature_name, feature_result)
} }
fn compare_Dim(image0: Image<f32>, image1: Image<f32>) -> (String, FeatureResult) { fn compare_Dim(image0: Arc<Image<f32>>, image1: Arc<Image<f32>>) -> (String, FeatureResult) {
let a = image0.width as f32 / image0.height as f32; let a = image0.width as f32 / image0.height as f32;
let b = image1.width as f32 / image1.height as f32; let b = image1.width as f32 / image1.height as f32;
let equal = a == b; let equal = a == b;