friday-0.2.3.1: A functional image processing library for Haskell.

Safe HaskellNone
LanguageHaskell2010

Vision.Image.Threshold

Contents

Synopsis

Simple threshold

data ThresholdType src res where Source #

Specifies what to do with pixels matching the threshold predicate.

BinaryThreshold a b will replace matching pixels by a and non-matchings pixels by b.

Truncate a will replace matching pixels by a.

TruncateInv a will replace non-matching pixels by a.

Constructors

BinaryThreshold :: res -> res -> ThresholdType src res 
Truncate :: src -> ThresholdType src src 
TruncateInv :: src -> ThresholdType src src 

thresholdType :: ThresholdType src res -> Bool -> src -> res Source #

Given the thresholding method, a boolean indicating if the pixel match the thresholding condition and the pixel, returns the new pixel value.

threshold :: FunctorImage src res => (ImagePixel src -> Bool) -> ThresholdType (ImagePixel src) (ImagePixel res) -> src -> res Source #

Applies the given predicate and threshold policy on the image.

Adaptive threshold

data AdaptiveThresholdKernel acc where Source #

Defines how pixels of the kernel of the adaptive threshold will be weighted.

With MeanKernel, pixels of the kernel have the same weight.

With GaussianKernel sigma, pixels are weighted according to their distance from the thresholded pixel using a Gaussian function parametred by sigma. See gaussianBlur for details.

type AdaptiveThreshold src acc res = SeparableFilter src () acc res Source #

adaptiveThreshold Source #

Arguments

:: (Image src, Integral (ImagePixel src), Ord (ImagePixel src), FromFunction res, Integral (FromFunctionPixel res), Storable acc, SeparatelyFiltrable src res acc) 
=> AdaptiveThresholdKernel acc 
-> Int

Kernel radius.

-> ImagePixel src

Minimum difference between the pixel and the kernel average. The pixel is thresholded if pixel_value - kernel_mean > difference where difference is this number. Can be negative.

-> ThresholdType (ImagePixel src) (FromFunctionPixel res) 
-> src 
-> res 

Compares every pixel to its surrounding ones in the kernel of the given radius.

adaptiveThresholdFilter Source #

Arguments

:: (Integral src, Ord src, Storable acc) 
=> AdaptiveThresholdKernel acc 
-> Int

Kernel radius.

-> src

Minimum difference between the pixel and the kernel average. The pixel is thresholded if pixel_value - kernel_mean > difference where difference is this number. Can be negative.

-> ThresholdType src res 
-> AdaptiveThreshold src acc res 

Creates an adaptive thresholding filter to be used with apply.

Use adaptiveThreshold if you only want to apply the filter on the image.

Compares every pixel to its surrounding ones in the kernel of the given radius.

Other methods

otsu :: (HistogramShape (PixelValueSpace (ImagePixel src)), ToHistogram (ImagePixel src), FunctorImage src res, Ord (ImagePixel src), Num (ImagePixel src), Enum (ImagePixel src)) => ThresholdType (ImagePixel src) (ImagePixel res) -> src -> res Source #

Applies a clustering-based image thresholding using the Otsu's method.

See https://en.wikipedia.org/wiki/Otsu's_method.

scw :: (Image src, Integral (ImagePixel src), FromFunction dst, Floating stdev, Fractional stdev, Ord stdev, Storable stdev) => Size -> Size -> stdev -> ThresholdType (ImagePixel src) (FromFunctionPixel dst) -> src -> dst Source #

This is a sliding concentric window filter (SCW) that uses the ratio of the standard deviations of two sliding windows centered on a same point to detect regions of interest (ROI).

scw sizeWindowA sizeWindowB beta thresType img

Let σA be the standard deviation of a fist window around a pixel and σB be the standard deviation of another window around the same pixel. Then the pixel will match the threshold if σB / σA >= beta, and will be thresholded according to the given ThresholdType.

See http://www.academypublisher.com/jcp/vol04/no08/jcp0408771777.pdf.