Skip to content

HMath.Image.Filter

Module index · Numerical conventions

Description

Direct ND reference filtering and 2D edge detection. Kernel centers are at floor(size/2); odd extents are required. All boundary policies are explicit. Work is limited before neighborhood expansion or output allocation.

On this page

API Purpose
convolve Given boundary,kernel dimensions,flat weights,then image, reverse all kernel axes and correlate.
correlate Correlation uses sample(ix+kernelOffset-center).
gaussianBlur Separable Gaussian, truncated at an explicitly supplied integer radius.
boxBlur Given boundary,radius,then image, average a centered full-dimensional box neighborhood independently per channel.
medianBlur Given boundary,radius,then image, choose the median of each centered odd-sized neighborhood independently per channel.
bilateralBlur Per-channel bilateral filtering: spatial and range Gaussian weights are multiplied, normalized locally, and computed relative to the center sample.
sharpen Unsharp mask x+amount*(x-Gaussian(x)); no implicit range clipping.
GradientOperator Image gradient stencil selector, choosing Sobel,Prewitt,or Scharr.
Sobel Declaration and type contract below.
Prewitt Declaration and type contract below.
Scharr Declaration and type contract below.
gradient Returns row derivative, column derivative, magnitude, and atan2(row,col) direction in radians.
laplacian Given boundary then one-channel 2D image, apply the four-neighbor 3-by-3 Laplacian [0,1,0;1,-4,1;0,1,0].
canny Canny: Gaussian smoothing, Sobel gradient, four-direction nonmaximum suppression, and 8-connected hysteresis. low/high are absolute normalized gradient magnitudes, not quantiles.
Morphology Grayscale footprint operation selector: erosion,dilation,opening,or closing.
Erosion Declaration and type contract below.
Dilation Declaration and type contract below.
Opening Declaration and type contract below.
Closing Declaration and type contract below.
morphology Flat grayscale morphology with an explicit odd-rank Boolean footprint.
morphologicalGradient Given boundary,footprint dimensions,Bool footprint,then image, return dilation minus erosion.
validateBoundary Validate Constant boundary value as finite; Clamp,Reflect,Wrap are always valid.
scalar2D Require a two-dimensional one-channel image and return (height,width).
windowOffsets Given radius then image, enumerate centered neighborhood offsets.

Documentation

convolve

convolve :: Boundary -> [Int] -> [Double] -> Image -> Either MathError Image Source #

Given boundary,kernel dimensions,flat weights,then image, reverse all kernel axes and correlate. Channels are filtered independently; require odd extents<=65, matching rankcount, <=4096 weights and <=20000000 sample operations. Invalidnon-finite input/result fails.

correlate

correlate :: Boundary -> [Int] -> [Double] -> Image -> Either MathError Image Source #

Correlation uses sample(ix+kernelOffset-center). Convolution reverses all kernel axes; channels are filtered independently without channel mixing.

gaussianBlur

gaussianBlur :: Boundary -> Double -> Int -> Image -> Either MathError Image Source #

Separable Gaussian, truncated at an explicitly supplied integer radius.

boxBlur

boxBlur :: Boundary -> Int -> Image -> Either MathError Image Source #

Given boundary,radius,then image, average a centered full-dimensional box neighborhood independently per channel. Neighborhood/work bounds and boundary finiteness are checked; invalid/non-finite output fails.

medianBlur

medianBlur :: Boundary -> Int -> Image -> Either MathError Image Source #

Given boundary,radius,then image, choose the median of each centered odd-sized neighborhood independently per channel. Invalid boundaryneighborhoodwork bounds fail.

bilateralBlur

bilateralBlur :: Boundary -> Double -> Double -> Int -> Image -> Either MathError Image Source #

Per-channel bilateral filtering: spatial and range Gaussian weights are multiplied, normalized locally, and computed relative to the center sample.

sharpen

sharpen :: Boundary -> Double -> Double -> Int -> Image -> Either MathError Image Source #

Unsharp mask x+amount*(x-Gaussian(x)); no implicit range clipping.

GradientOperator

data GradientOperator Source #

Image gradient stencil selector, choosing Sobel,Prewitt,or Scharr.

Constructors

Sobel 
Prewitt 
Scharr 

gradient

gradient :: GradientOperator -> Boundary -> Image -> Either MathError (Image, Image, Image, Image) Source #

Returns row derivative, column derivative, magnitude, and atan2(row,col) direction in radians. Smoothing/derivative kernels are normalized so an interior unit ramp has derivative one.

laplacian

laplacian :: Boundary -> Image -> Either MathError Image Source #

Given boundary then one-channel 2D image, apply the four-neighbor 3-by-3 Laplacian [0,1,0;1,-4,1;0,1,0]. Invalid image/boundary or non-finite output fails.

canny

canny :: Boundary -> Double -> Int -> Double -> Double -> Image -> Either MathError Image Source #

Canny: Gaussian smoothing, Sobel gradient, four-direction nonmaximum suppression, and 8-connected hysteresis. low/high are absolute normalized gradient magnitudes, not quantiles. Output is exactly zero or one.

Morphology

data Morphology Source #

Grayscale footprint operation selector: erosion,dilation,opening,or closing.

Constructors

Erosion 
Dilation 
Opening 
Closing 

Instances

Instances details
Show Morphology Source # 
Instance details

Defined in HMath.Image.Filter

Eq Morphology Source # 
Instance details

Defined in HMath.Image.Filter

morphology

morphology :: Morphology -> Boundary -> [Int] -> [Bool] -> Image -> Either MathError Image Source #

Flat grayscale morphology with an explicit odd-rank Boolean footprint. Erosion samples x+offset; dilation samples x-offset (reflected footprint), so asymmetric footprints obey the usual adjunction. Opening/closing compose these operators under the same caller-selected boundary extension.

morphologicalGradient

morphologicalGradient :: Boundary -> [Int] -> [Bool] -> Image -> Either MathError Image Source #

Given boundary,footprint dimensions,Bool footprint,then image, return dilation minus erosion. Shapefootprintwork/boundary validation and finite output checks propagate from morphology.

validateBoundary

validateBoundary :: Boundary -> Either MathError () Source #

Validate Constant boundary value as finite; Clamp,Reflect,Wrap are always valid. Non-finite constant returns Left InvalidArgument.

scalar2D

scalar2D :: Image -> Either MathError (Int, Int) Source #

Require a two-dimensional one-channel image and return (height,width). Other spatial/channel layouts return Left InvalidArgument.

windowOffsets

windowOffsets :: Int -> Image -> Either MathError [[Int]] Source #

Given radius then image, enumerate centered neighborhood offsets. Require radius in [0,16], <=4096 neighbors and <=20000000 sample operations; otherwise fail.