Skip to main content

CostMap

Struct CostMap 

Source
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>

Source

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.

Source

pub fn pixel_count(&self) -> usize

Number of pixels covered by the map.

Source

pub fn costs(&self) -> &[f32]

The costs as a flat row-major slice.

The embedding layer consumes the map in permuted order, so it needs the raw vector rather than coordinate access.

Source

pub fn get(&self, x: u32, y: u32) -> Option<f32>

Cost of the pixel at (x, y), or None when the coordinates fall outside the map.

The total counterpart of the Index implementation.

Trait Implementations§

Source§

impl Debug for CostMap<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Prints the geometry of the map, never its contents.

Written by hand rather than derived: a derived implementation would format several million floats, which is not what anyone putting a cost map behind {:?} is asking for.

Source§

impl Index<(u32, u32)> for CostMap<'_>

Source§

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.

Source§

type Output = f32

The returned type after indexing.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.