Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ThresholdType src res where
- BinaryThreshold :: res -> res -> ThresholdType src res
- Truncate :: src -> ThresholdType src src
- TruncateInv :: src -> ThresholdType src src
- thresholdType :: ThresholdType src res -> Bool -> src -> res
- threshold :: FunctorImage src res => (ImagePixel src -> Bool) -> ThresholdType (ImagePixel src) (ImagePixel res) -> src -> res
- data AdaptiveThresholdKernel acc where
- MeanKernel :: Integral acc => AdaptiveThresholdKernel acc
- GaussianKernel :: (Floating acc, RealFrac acc) => Maybe acc -> AdaptiveThresholdKernel acc
- type AdaptiveThreshold src acc res = SeparableFilter src () acc res
- adaptiveThreshold :: (Image src, Integral (ImagePixel src), Ord (ImagePixel src), FromFunction res, Integral (FromFunctionPixel res), Storable acc, SeparatelyFiltrable src res acc) => AdaptiveThresholdKernel acc -> Int -> ImagePixel src -> ThresholdType (ImagePixel src) (FromFunctionPixel res) -> src -> res
- adaptiveThresholdFilter :: (Integral src, Ord src, Storable acc) => AdaptiveThresholdKernel acc -> Int -> src -> ThresholdType src res -> AdaptiveThreshold src acc res
- 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
- 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
Simple threshold
data ThresholdType src res where Source #
Specifies what to do with pixels matching the threshold predicate.
will replace matching pixels by BinaryThreshold
a ba
and non-matchings
pixels by b
.
will replace matching pixels by Truncate
aa
.
will replace non-matching pixels by TruncateInv
aa
.
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
, pixels are weighted according to their distance
from the thresholded pixel using a Gaussian function parametred by GaussianKernel
sigmasigma
.
See gaussianBlur
for details.
MeanKernel :: Integral acc => AdaptiveThresholdKernel acc | |
GaussianKernel :: (Floating acc, RealFrac acc) => Maybe acc -> AdaptiveThresholdKernel acc |
type AdaptiveThreshold src acc res = SeparableFilter src () acc res Source #
:: (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
|
-> ThresholdType (ImagePixel src) (FromFunctionPixel res) | |
-> src | |
-> res |
Compares every pixel to its surrounding ones in the kernel of the given radius.
adaptiveThresholdFilter Source #
:: (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
|
-> 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.
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.