fast image operations
Diffstat (limited to 'src/pixels/wam.rs')
| -rw-r--r-- | src/pixels/wam.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pixels/wam.rs b/src/pixels/wam.rs index cf0f461..1da4c4d 100644 --- a/src/pixels/wam.rs +++ b/src/pixels/wam.rs @@ -1,7 +1,7 @@ +use super::{float, unfloat}; +use atools::prelude::*; use umath::{generic_float::Constructors, FF32}; -use super::{float, unfloat, PMap}; - pub trait Wam { /// this function weighs the sides and combines /// @@ -14,7 +14,7 @@ pub trait Wam { impl<const N: usize> Wam for [u8; N] { unsafe fn wam(self, b: Self, l: FF32, r: FF32) -> Self { // SAFETY: read [`weigh`] - self.pmap(b, |a, b| unsafe { weigh(a, b, l, r) }) + self.zip(b).map(|(a, b)| unsafe { weigh(a, b, l, r) }) } } @@ -23,7 +23,7 @@ impl<const N: usize> Wam for [u8; N] { /// /// floats must be smart unsafe fn weigh(a: u8, b: u8, l: FF32, r: FF32) -> u8 { - // SAFETY: float(x) returns 0..=1, 0..=1 * f32::MAX isnt Inf, but if you add 1.0 and then mul by max again, you get inf (big bad, hence unsafe fn) + // SAFETY: float(x) returns 0..=1, 0..=1 * f32::MAX isn't Inf, but if you add 1.0 and then mul by max again, you get inf (big bad, hence unsafe fn) unsafe { unfloat((float(a) * l + float(b) * r).clamp(FF32::zero(), FF32::one())) } } |