imagefilters-0.1: Image Filters (contrast, brightness, gaussian blur, etc)

Graphics.Filters.GD

Contents

Synopsis

Filters

brightness :: Image -> Int -> IO ()Source

Applies the supplied brightness adjustment to the image. The range of the brightness argument is -255 to +255

colorize :: Image -> RGBA -> IO ()Source

Applies the supplied color transformation to the image. The range of the passed RGB values are -255 to +255, and the range of the A value is -127 to +127.

contrast :: Image -> Int -> IO ()Source

Applies the supplied contrast adjustment to the image. The range of the contrast argument is -100 to +100, with -100 being maximum contrast, and +100 being minimum contrast

gaussianBlur :: Image -> IO ()Source

Applies Gaussian blur to the image

grayscale :: Image -> IO ()Source

Converts an image to grayscale

edgeDetect :: Image -> IO ()Source

Applies Edge Detection to the image

emboss :: Image -> IO ()Source

Applies an Emboss effect to the image

meanRemoval :: Image -> IO ()Source

Applies a Mean Removal effect to the image

negative :: Image -> IO ()Source

Inverts the image's color.

smoothing :: Image -> Float -> IO ()Source

Applies weighted Smoothing to the image. The smoothing amount is technically unbounded, but larger values produce a less noticeable result

Pixel transformation functions

pixelTransformSource

Arguments

:: Image 
-> (RGBA -> RGBA)

Transform function to be performed on each pixel

-> IO () 

Performs the supplied transform function on every pixel of the image. The transform function should take as it's argument a quadruple of Ints (RGBA) and returns a new RGBA quadruple which is will be the new RGBA values of the the pixel.

For example, the colorize filter's inner workings are implemented with this as the transform function:

      (\(r,g,b,a) -> let
            nr = clamp 0 255 (r+ar)
            ng = clamp 0 255 (g+ag)
            nb = clamp 0 255 (b+ab)
            na = clamp 0 127 (a+aa)
        in (nr,ng,nb,na))

convoluteSource

Arguments

:: Image 
-> [[Float]]

Convolution matrix

-> Float

Divisor

-> Float

Offset

-> IO () 

Performs the convolution matrix on each pixel of the original image. After the matrix has been applied, the resulting RGBA value has each of it's elements divided by the Divisor argument and then the Offset argument is added to each element

For example, the emboss filter is implemented with the following convolution:

   emboss img = convolute img [[1.5,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,-1.5]] 1 127