Skip to content

HMath.Image.Measure

Module index · Numerical conventions

Description

Image measurements use caller-declared intensity ranges and explicit local windows. All images must share shape/channel count for comparisons.

On this page

API Purpose
TemplateMetric Template matching score: squared difference or normalized correlation.
SquaredDifference Declaration and type contract below.
NormalizedCorrelation Declaration and type contract below.
templateMatch Valid 2D, one-channel matching.
rawMoment Raw M_pq=sum(row^pcolumn^qintensity), orders 0..8 each.
centralMoment Given row exponent p,column exponent q,then scalar 2D image, compute the unnormalized intensity-weighted central moment around its centroid.
imageCentroid Intensity-weighted (row,column) centroid.
integralImage Padded 2D summed-area image, per channel: output shape (height+1,width+1) has a leading zero row/column.
rectangleSum Given (row,column) origin,(height,width) extent,then padded integralImage output, return per-channel sum of the half-open rectangle.
meanSquaredError Given two images of equal spatial shape and channels, return average squared sample difference.
peakSignalToNoise PSNR in decibels.
structuralSimilarity Mean local SSIM with uniform valid windows and population covariance.

Documentation

TemplateMetric

data TemplateMetric Source #

Template matching score: squared difference or normalized correlation. Interpret whether smaller/larger values are better according to the metric.

Instances

Instances details
Show TemplateMetric Source # 
Instance details

Defined in HMath.Image.Measure

Eq TemplateMetric Source # 
Instance details

Defined in HMath.Image.Measure

templateMatch

templateMatch :: TemplateMetric -> Image -> Image -> Either MathError Image Source #

Valid 2D, one-channel matching. Each output is one template origin. NCC centers both patches and divides by their energies; constant templates or candidate patches have undefined correlation and return MathError.

rawMoment

rawMoment :: Int -> Int -> Image -> Either MathError Double Source #

Raw M_pq=sum(row^p*column^q*intensity), orders 0..8 each.

centralMoment

centralMoment :: Int -> Int -> Image -> Either MathError Double Source #

Given row exponent p,column exponent q,then scalar 2D image, compute the unnormalized intensity-weighted central moment around its centroid. Require orders in [0,8]; invalid image/zero mass or non-finite result fails.

imageCentroid

imageCentroid :: Image -> Either MathError (Double, Double) Source #

Intensity-weighted (row,column) centroid. Signed intensities are allowed; a zero total mass is undefined and reported explicitly.

integralImage

integralImage :: Image -> Either MathError Image Source #

Padded 2D summed-area image, per channel: output shape (height+1,width+1) has a leading zero row/column. Rectangle queries use half-open bounds.

rectangleSum

rectangleSum :: (Int, Int) -> (Int, Int) -> Image -> Either MathError [Double] Source #

Given (row,column) origin,(height,width) extent,then padded integralImage output, return per-channel sum of the half-open rectangle. Reject invalid/out-of-range bounds; zero extents are allowed.

meanSquaredError

meanSquaredError :: Image -> Image -> Either MathError Double Source #

Given two images of equal spatial shape and channels, return average squared sample difference. Shape mismatch or non-finite arithmetic returns Left MathError.

peakSignalToNoise

peakSignalToNoise :: Double -> Image -> Image -> Either MathError Double Source #

PSNR in decibels. Exactly identical images return positive infinity by definition; this is the sole intentional nonfinite measurement result.

structuralSimilarity

structuralSimilarity :: Double -> Int -> Image -> Image -> Either MathError Double Source #

Mean local SSIM with uniform valid windows and population covariance. C1=(0.01*range)^2, C2=(0.03*range)^2; all channels are measured separately. Windows do not include padding and both spatial extents must fit the window. Wang et al., Image Quality Assessment: From Error Visibility to Structural Similarity (2004), https://ece.uwaterloo.ca/~z70wang/publications/ssim.html .