friday-0.2.3.2: A functional image processing library for Haskell.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Vision.Image.Filter

Description

Provides high level filtering functions for images.

Use Internal if you want to create new image filters.

Filters are operations on images on which the surrounding of each processed pixel is considered according to a kernel.

See http://en.wikipedia.org/wiki/Kernel_(image_processing) for details.

The radius argument of some filters is used to determine the kernel size. A radius as of 1 means a kernel of size 3, 2 a kernel of size 5 and so on.

Note: filters are currently not supported on multi-channel images (RGB, RGBA ...) are currently not supported.

Synopsis

Classes and type

class Filterable src res f Source #

Provides an implementation to execute a type of filter.

src is the original image, res the resulting image and f the filter.

Minimal complete definition

apply

Instances

Instances details
(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res) => Filterable src res (BoxFilter1 src_pix init res_pix) Source #

Box filters initialized using the first pixel of the kernel.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: BoxFilter1 src_pix init res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res, SeparatelyFiltrable src res src_pix) => Filterable src res (SeparableFilter1 src_pix init res_pix) Source #

Separable filters initialized using the first pixel of the kernel.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: SeparableFilter1 src_pix init res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res) => Filterable src res (BoxFilter src_pix init acc res_pix) Source #

Box filters initialized with a given value.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: BoxFilter src_pix init acc res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res, SeparatelyFiltrable src res acc) => Filterable src res (SeparableFilter src_pix init acc res_pix) Source #

Separable filters initialized with a given value.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: SeparableFilter src_pix init acc res_pix -> src -> res Source #

data Filter src kernel init fold acc res Source #

Instances

Instances details
(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res) => Filterable src res (BoxFilter1 src_pix init res_pix) Source #

Box filters initialized using the first pixel of the kernel.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: BoxFilter1 src_pix init res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res, SeparatelyFiltrable src res src_pix) => Filterable src res (SeparableFilter1 src_pix init res_pix) Source #

Separable filters initialized using the first pixel of the kernel.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: SeparableFilter1 src_pix init res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res) => Filterable src res (BoxFilter src_pix init acc res_pix) Source #

Box filters initialized with a given value.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: BoxFilter src_pix init acc res_pix -> src -> res Source #

(Image src, FromFunction res, src_pix ~ ImagePixel src, res_pix ~ FromFunctionPixel res, SeparatelyFiltrable src res acc) => Filterable src res (SeparableFilter src_pix init acc res_pix) Source #

Separable filters initialized with a given value.

Instance details

Defined in Vision.Image.Filter.Internal

Methods

apply :: SeparableFilter src_pix init acc res_pix -> src -> res Source #

class (Image (SeparableFilterAccumulator src res acc), ImagePixel (SeparableFilterAccumulator src res acc) ~ acc, FromFunction (SeparableFilterAccumulator src res acc), FromFunctionPixel (SeparableFilterAccumulator src res acc) ~ acc) => SeparatelyFiltrable src res acc Source #

Used to determine the type of the accumulator image used when computing separable filters.

src and res are respectively the source and the result image types while acc is the pixel type of the accumulator.

Instances

Instances details
Storable acc => SeparatelyFiltrable src (Delayed p) acc Source # 
Instance details

Defined in Vision.Image.Filter.Internal

Associated Types

type SeparableFilterAccumulator src (Delayed p) acc Source #

Storable acc => SeparatelyFiltrable src (Manifest p) acc Source # 
Instance details

Defined in Vision.Image.Filter.Internal

Associated Types

type SeparableFilterAccumulator src (Manifest p) acc Source #

Morphological operators

dilate Source #

Arguments

:: (Image src, Ord (ImagePixel src), FromFunction res, FromFunctionPixel res ~ ImagePixel src, SeparatelyFiltrable src res (ImagePixel src)) 
=> Int

Kernel radius.

-> src 
-> res 

erode Source #

Arguments

:: (Image src, Ord (ImagePixel src), FromFunction res, FromFunctionPixel res ~ ImagePixel src, SeparatelyFiltrable src res (ImagePixel src)) 
=> Int

Kernel radius.

-> src 
-> res 

Blur

blur Source #

Arguments

:: (Image src, Integral (ImagePixel src), FromFunction res, Num (FromFunctionPixel res), SeparatelyFiltrable src res Int32) 
=> Int

Blur radius.

-> src 
-> res 

Blurs the image by averaging the pixel inside the kernel.

Uses an Int32 as accumulator during the averaging operation.

gaussianBlur Source #

Arguments

:: (Image src, Integral (ImagePixel src), FromFunction res, Integral (FromFunctionPixel res), Floating acc, RealFrac acc, Storable acc, SeparatelyFiltrable src res acc) 
=> Int

Blur radius.

-> Maybe acc

Sigma value of the Gaussian function. If not given, will be automatically computed from the radius so that the kernel fits 3σ of the distribution.

-> src 
-> res 

Blurs the image by averaging the pixel inside the kernel using a Gaussian function.

See http://en.wikipedia.org/wiki/Gaussian_blur

Derivation

scharr :: (Image src, Integral (ImagePixel src), FromFunction res, Integral (FromFunctionPixel res), Storable (FromFunctionPixel res), SeparatelyFiltrable src res (FromFunctionPixel res)) => DerivativeType -> src -> res Source #

Estimates the first derivative using the Scharr's 3x3 kernel.

Convolves the following kernel for the X derivative:

 -3   0   3
-10   0  10
 -3   0   3

And this kernel for the Y derivative:

 -3 -10  -3
  0   0   0
  3  10   3

Uses an Int32 as accumulator during kernel application.

sobel Source #

Arguments

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

Kernel radius.

-> DerivativeType 
-> src 
-> res 

Estimates the first derivative using a Sobel's kernel.

Prefer scharr when radius equals 1 as Scharr's kernel is more accurate and is implemented faster.

Uses an Int32 as accumulator during kernel application.

Others

mean :: (Image src, Integral (ImagePixel src), FromFunction res, Fractional (FromFunctionPixel res), SeparatelyFiltrable src res Int32) => Size -> src -> res Source #

Computes the average of a kernel of the given size.

This is similar to blur but with a rectangular kernel and a Fractional result.

Uses an Int32 as accumulator during the averaging operation.