Skip to main content

ImageOps

Struct ImageOps 

Source
pub struct ImageOps { /* private fields */ }
Expand description

GPU image operations sharing the caller’s model context and compilation cache.

Implementations§

Source§

impl ImageOps

Source

pub fn prepare_affine_rgb( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<Arc<PreparedModel>>

Prepare several affine crops from one packed RGB image [1,h,w,3]. The second input is contiguous F32 [crops,2,3] (General layout), mapping integer output pixel centers to source coordinates. Output is U8 NHWC. Sampling uses the explicit FP32 border/arithmetic/rounding contract. Non-finite or excessively large coordinates produce black, never an unsafe integer conversion. Matrices are runtime data, not part of the cache key.

Source

pub fn affine_rgb_fragment( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<ModelFragment>

Recordable affine crop sampling for composition with model kernels.

Source

pub fn affine_packed_rgb_fragment( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<ModelFragment>

Sample crops from differently sized RGB images in one packed byte buffer. Inputs are U8 [bytes], F32 [crops,2,3] inverse matrices, and U32 [crops,3] records (byte_offset, width, height). Repeated records sample several faces from one image without duplicating its pixels. Geometry is runtime data: changing image sizes does not compile another graph. Axes must be 1..=32767. Invalid records produce black; source reads are bounded to the byte buffer.

Source

pub fn affine_rgb( &self, image: &DeviceTensor, inverse: &DeviceTensor, height: usize, width: usize, sampling: RgbSampling, ) -> Result<Inference>

Sample resident RGB into resident crops without a host wait or readback.

Source§

impl ImageOps

Source

pub fn prepare_composite_rgb( &self, image: &TensorDesc, crop: &TensorDesc, mode: RgbComposite, ) -> Result<Arc<PreparedModel>>

Prepare affine compositing of one F32 NHWC RGB crop and its F32 [height,width] alpha mask into one U8 NHWC frame. RGB uses replicated borders; mask sampling uses zero borders and clamps alpha to [0,1].

Inputs: frame, crop, mask, F32 [1,2,3] frame-to-crop matrix, F32 [5] containing [left,top,right,bottom,blend]. Region bounds are exclusive on right/bottom. Pixels outside it (or with invalid coordinates) are unchanged. Blend is clamped to [0,1] and used only for QuantizedBlend.

Source

pub fn composite_rgb_fragment( &self, image: &TensorDesc, crop: &TensorDesc, mode: RgbComposite, ) -> Result<ModelFragment>

Record compositing with directly bound frame, crop, mask, matrix and region/blend inputs. Descriptors and arithmetic match prepare_composite_rgb.

Source

pub fn composite_rgb( &self, image: &DeviceTensor, crop: &DeviceTensor, mask: &DeviceTensor, matrix: &DeviceTensor, region: [usize; 4], blend: f32, mode: RgbComposite, ) -> Result<Inference>

Composite resident pixels. Bounds and blend are small host metadata; image, crop, mask and matrix never cross the host boundary.

Source§

impl ImageOps

Source

pub fn prepare_normalize_rgb( &self, input: &TensorDesc, mean: [f32; 3], std: [f32; 3], ) -> Result<Arc<PreparedModel>>

Prepare packed RGB U8 NHWC to F32 NCHW conversion, computing (pixel / 255 - mean[channel]) / std[channel] in that order.

Source

pub fn normalize_rgb_fragment( &self, input: &TensorDesc, mean: [f32; 3], std: [f32; 3], ) -> Result<ModelFragment>

Recordable normalization with no slot pool or host staging. Connect its output directly to a model fragment in a caller-owned graph.

Source

pub fn normalize_rgb( &self, input: &DeviceTensor, mean: [f32; 3], std: [f32; 3], ) -> Result<Inference>

Normalize resident RGB pixels and change layout without a host boundary.

Source§

impl ImageOps

Source

pub fn prepare_resize_rgb( &self, input: &TensorDesc, resize: RgbResize, ) -> Result<Arc<PreparedModel>>

Prepare a reusable three-slot RGB resize/letterbox plan for contiguous U8 NHWC [batch,height,width,3]. Only image bytes are runtime inputs.

Source

pub fn resize_rgb_fragment( &self, input: &TensorDesc, resize: RgbResize, ) -> Result<ModelFragment>

Recordable resize/letterbox for direct composition with a model graph.

Source

pub fn resize_rgb( &self, image: &DeviceTensor, resize: RgbResize, ) -> Result<Inference>

Resize a resident RGB batch; output padding is initialized to black on every replay. Retained outputs apply bounded per-shape backpressure.

Source§

impl ImageOps

Source

pub fn prepare_similarity_2d( &self, points: &TensorDesc, template: &[[f32; 2]], ) -> Result<Arc<PreparedModel>>

Prepare FP32 similarity fitting for [batch,points,2]. Positive non-overlapping strides allow direct landmark views of detection rows. Template coordinates are immutable shape-plan data (2..=64 points). Outputs: forward [batch,2,3], inverse [batch,2,3], status I32 [batch]. Status is zero for success and one for invalid/degenerate geometry; both matrices are NaN on failure. Consumers must preserve/check status, not treat a black crop from invalid geometry as a successful alignment.

Source

pub fn similarity_2d_fragment( &self, points: &TensorDesc, template: &[[f32; 2]], ) -> Result<ModelFragment>

Recordable fit producing forward matrices, inverse matrices and status.

Source

pub fn similarity_2d( &self, points: &DeviceTensor, template: &[[f32; 2]], ) -> Result<Inference>

Fit resident landmarks; no landmark or matrix readback is performed.

Source§

impl ImageOps

Source

pub fn prepare_encode_rgb_views( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<Arc<PreparedModel>>

Split packed U8 NHWC into interleaved F32 NCHW views. A factor of f produces f² views per image: view (dy,dx) samples image[yf+dy,xf+dx]. This is a lossless layout permutation before the selected normalization, not a resize. Both spatial dimensions must divide the factor.

Source

pub fn prepare_decode_rgb_views( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<Arc<PreparedModel>>

Reassemble interleaved F32 NCHW views as F32 NHWC byte-level RGB. The view batch must be a multiple of factor². Unit values retain the network’s fractional output; Symmetric values use the documented clamp.

Source

pub fn encode_rgb_views_fragment( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<ModelFragment>

Record RGB view encoding with directly bound input pixels.

Source

pub fn decode_rgb_views_fragment( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<ModelFragment>

Record RGB view decoding with directly bound model output.

Source

pub fn encode_rgb_views( &self, input: &DeviceTensor, factor: usize, encoding: RgbEncoding, ) -> Result<Inference>

Encode resident pixels without a host boundary.

Source

pub fn decode_rgb_views( &self, input: &DeviceTensor, factor: usize, encoding: RgbEncoding, ) -> Result<Inference>

Decode resident model views without a host boundary.

Source§

impl ImageOps

Source

pub fn new(context: &ModelContext, cache_capacity: usize) -> Result<Self>

Create a bounded shape cache. Preparation is lazy, never per warm request.

Source

pub fn prepare_patchify( &self, input: &TensorDesc, patch: usize, ) -> Result<Arc<PreparedModel>>

Prepare NCHW f32 patchification to [batch, patches, channels*p*p]. Within a patch, values are in channel, row, column order. No arithmetic changes the values, including non-finite payloads. Both axes must divide p.

Source

pub fn patchify_fragment( &self, input: &TensorDesc, patch: usize, ) -> Result<ModelFragment>

Recordable patchification for direct composition with a model graph.

Source

pub fn patchify(&self, input: &DeviceTensor, patch: usize) -> Result<Inference>

Patchify a resident image batch without a host wait or readback.

Auto Trait Implementations§

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<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more