pub struct CostMap<'img> { /* private fields */ }Expand description
Per-pixel embedding cost of a container image, in row-major order.
§What the lifetime buys
'img is the borrow of the ImageBuffer the map was computed from. The
map holds no reference to the image at run time — only a PhantomData —
but the borrow checker treats it as if it did, so for as long as a
CostMap<'img> is alive the compiler refuses every call to
CoverSource::pixels_mut on the source image.
That is the whole point. A cost map computed from one set of samples and applied to another is silently wrong: the embedder would steer bits towards regions that are no longer the textured ones, which is exactly the mistake a steganalyst is looking for. Rather than keeping map and image in sync by convention, the pipeline is forced to drop the map before it may touch the pixels, and the invariant is checked at compile time.
Implementations§
Source§impl<'img> CostMap<'img>
impl<'img> CostMap<'img>
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Dimensions of the map as (width, height), in pixels.
Always the dimensions of the image the map was computed from.
Sourcepub fn pixel_count(&self) -> usize
pub fn pixel_count(&self) -> usize
Number of pixels covered by the map.
Trait Implementations§
Source§impl Index<(u32, u32)> for CostMap<'_>
impl Index<(u32, u32)> for CostMap<'_>
Source§fn index(&self, (x, y): (u32, u32)) -> &f32
fn index(&self, (x, y): (u32, u32)) -> &f32
Cost of the pixel at (x, y).
Follows the convention of every indexing implementation in the standard
library and treats out-of-range coordinates as a programming error
rather than as a runtime condition. Use CostMap::get wherever the
coordinates come from outside the caller.
Auto Trait Implementations§
impl<'img> Freeze for CostMap<'img>
impl<'img> RefUnwindSafe for CostMap<'img>
impl<'img> Send for CostMap<'img>
impl<'img> Sync for CostMap<'img>
impl<'img> Unpin for CostMap<'img>
impl<'img> UnsafeUnpin for CostMap<'img>
impl<'img> UnwindSafe for CostMap<'img>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more