Skip to content

HMath.Image.Spatial

Module index · Numerical conventions

Description

2D resampling/warps, ND binary topology, and exact bounded distance queries.

On this page

API Purpose
Interpolation Image resampling interpolation mode, choosing nearest,bilinear,bicubic,or Lanczos kernels.
Nearest Declaration and type contract below.
Bilinear Declaration and type contract below.
Bicubic Declaration and type contract below.
Lanczos Declaration and type contract below.
resize 2D resize uses pixel-center mapping (i+0.5)*old/new-0.5, independently per channel, without antialiasing.
warp Forward 3x3 homogeneous transform acts on [x(column),y(row),1].
translate Translation in pixel columns/rows; output dimensions equal input.
rotate Angle in radians, clockwise on row-down image coordinates; rotate about the center pixel coordinate while preserving the input canvas dimensions.
Connectivity Spatial connected-component adjacency: axis neighbors or all surrounding neighbors.
AxisConnected Declaration and type contract below.
FullyConnected Declaration and type contract below.
connectedComponents Nonzero is foreground.
distanceTransform Exact brute-force Euclidean distance to the nearest zero-valued spatial sample, with strictly positive per-axis spacing.

Documentation

Interpolation

data Interpolation Source #

Image resampling interpolation mode, choosing nearest,bilinear,bicubic,or Lanczos kernels.

Constructors

Nearest 
Bilinear 
Bicubic 
Lanczos 

Instances

Instances details
Show Interpolation Source # 
Instance details

Defined in HMath.Image.Spatial

Eq Interpolation Source # 
Instance details

Defined in HMath.Image.Spatial

resize

resize :: Interpolation -> Boundary -> (Int, Int) -> Image -> Either MathError Image Source #

2D resize uses pixel-center mapping (i+0.5)*old/new-0.5, independently per channel, without antialiasing. Bicubic is Keys a=-0.5; Lanczos has radius three. Downsampling callers can explicitly prefilter first.

warp

warp :: Interpolation -> Boundary -> (Int, Int) -> [[Double]] -> Image -> Either MathError Image Source #

Forward 3x3 homogeneous transform acts on [x(column),y(row),1]. The matrix is inverted once for output-to-input sampling. Points at projective infinity or with magnitude over 1e9 are errors, even with constant padding.

translate

translate :: Interpolation -> Boundary -> Double -> Double -> Image -> Either MathError Image Source #

Translation in pixel columns/rows; output dimensions equal input.

rotate

rotate :: Interpolation -> Boundary -> Double -> Image -> Either MathError Image Source #

Angle in radians, clockwise on row-down image coordinates; rotate about the center pixel coordinate while preserving the input canvas dimensions.

Connectivity

data Connectivity Source #

Spatial connected-component adjacency: axis neighbors or all surrounding neighbors.

Instances

Instances details
Show Connectivity Source # 
Instance details

Defined in HMath.Image.Spatial

Eq Connectivity Source # 
Instance details

Defined in HMath.Image.Spatial

connectedComponents

connectedComponents :: Connectivity -> Image -> Either MathError (Image, [Int]) Source #

Nonzero is foreground. Label zero is background; component labels start at one in first-pixel row-major order. Returns labels as exact Doubles and component sizes in that same order. Connectivity has no wraparound.

distanceTransform

distanceTransform :: [Double] -> Image -> Either MathError Image Source #

Exact brute-force Euclidean distance to the nearest zero-valued spatial sample, with strictly positive per-axis spacing. No implicit outside zeros; an all-foreground image has no finite answer and returns DomainError.