Table of Contents

Interface IWarp

Namespace
Egami.Operations
Assembly
Egami.dll

A general warp: a mapping from each output pixel back to the source point it shows. Egami samples the points with the same sampler as Transform(Homography, TransformOptions?), so every warp gets antialiasing where it shrinks the image, and edge modes. Positions are in pixels with the origin at the top-left corner of the top-left pixel, so pixel centers sit at +0.5.

public interface IWarp

Examples

// Any mapping from output points back to source points; the sampler antialiases wherever it shrinks the image.
IWarp ripple = Warp.FromFunction(p => new Vector2(p.X + (6 * MathF.Sin(p.Y / 15)), p.Y));
using Raster rippled = photo.Derive(ops => ops.Warp(ripple, new SamplingOptions { Edges = EdgeMode.Mirror }), Ct);

// The same as an IWarp, mapping a whole row per call: no per-pixel delegate, so it is faster.
using Raster again = photo.Derive(ops => ops.Warp(new Ripple(6, 15), new SamplingOptions { Edges = EdgeMode.Mirror }), Ct);

Remarks

Map(int, Size, Span<Vector2>) is called for every output row, from several threads at once, so an implementation must be stateless or immutable. The sampler finds each pixel's footprint from the points its neighbours map to, so a warp only maps points, never derivatives.

Methods

Map(int, Size, Span<Vector2>)

Fills source with the source point of every output pixel center in row y: element x is where output point (x + 0.5, y + 0.5) comes from. A NaN coordinate marks a pixel with no source, which shows the background.

void Map(int y, Size input, Span<Vector2> source)

Parameters

y int

The output row.

input Size

The input size.

source Span<Vector2>

One point per output column.

OutputSize(Size)

Returns the size of the warped image for an input of input.

Size OutputSize(Size input)

Parameters

input Size

The input size.

Returns

Size

The output size; return input for a warp that keeps the size.