arrayfire-0.4.0.0: Haskell bindings to the ArrayFire general-purpose GPU library

CopyrightDavid Johnson (c) 2019-2020
LicenseBSD 3
MaintainerDavid Johnson <djohnson.m@gmail.com>
StabilityExperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

ArrayFire.Image

Description

 
Synopsis

Documentation

gradient :: Array a -> (Array a, Array a) Source #

Calculates the gradient of an image

>>> print (gradient image)

loadImage Source #

Arguments

:: String

File path

-> Bool

Is color image (boolean denoting if the image should be loaded as 1 channel or 3 channel)

-> IO (Array a) 

Loads an image from disk

>>> image <- loadImage "image.png" True

saveImage :: Array a -> String -> IO () Source #

Saves an image to disk

>>> saveImage image "image.png"

loadImageNative :: String -> IO (Array a) Source #

Loads an image natively

>>> image <- loadImageNative "image.png"

saveImageNative :: Array a -> String -> IO () Source #

Saves an image natively

>>> saveImageNative image "image.png"

isImageIOAvailable :: IO Bool Source #

Returns true if ArrayFire was compiled with ImageIO (FreeImage) support

>>> print =<< isImageIOAvailable

resize Source #

Arguments

:: Array a

input image

-> Int

is the size for the first output dimension

-> Int

is the size for the second output dimension

-> InterpType

is the interpolation type (Nearest by default)

-> Array a

will contain the resized image of specified by odim0 and odim1

Resize an input image.

ArrayFire Docs

Resizing an input image can be done using either AF_INTERP_NEAREST, AF_INTERP_BILINEAR or AF_INTERP_LOWER, interpolations. Nearest interpolation will pick the nearest value to the location, bilinear interpolation will do a weighted interpolation for calculate the new size and lower interpolation is similar to the nearest, except it will use the floor function to get the lower neighbor.

transform Source #

Arguments

:: Array a

is input image

-> Array a

is transformation matrix

-> Int

is the first output dimension

-> Int

is the second output dimension

-> InterpType

is the interpolation type (Nearest by default)

-> Bool

if true applies inverse transform, if false applies forward transoform

-> Array a

will contain the transformed image

Transform an input image.

ArrayFire Docs

The transform function uses an affine or perspective transform matrix to tranform an input image into a new one.

transformCoordinates Source #

Arguments

:: Array a

is transformation matrix

-> Float

is the first input dimension

-> Float

is the second input dimension

-> Array a

the transformed coordinates

Transform input coordinates.

ArrayFire Docs

C Interface for transforming an image C++ Interface for transforming coordinates.

rotate Source #

Arguments

:: Array a

is input image

-> Float

is the degree (in radians) by which the input is rotated

-> Bool

if true the output is cropped original dimensions. If false the output dimensions scale based on theta

-> InterpType

is the interpolation type (Nearest by default)

-> Array a

will contain the image in rotated by theta

Rotate an input image.

ArrayFire Docs

Rotating an input image can be done using AF_INTERP_NEAREST, AF_INTERP_BILINEAR or AF_INTERP_LOWER interpolations. Nearest interpolation will pick the nearest value to the location, whereas bilinear interpolation will do a weighted interpolation for calculate the new size.

translate Source #

Arguments

:: Array a

is input image

-> Float

is amount by which the first dimension is translated

-> Float

is amount by which the second dimension is translated

-> Int

is the first output dimension

-> Int

is the second output dimension

-> InterpType

is the interpolation type (Nearest by default)

-> Array a

will contain the translated image

Translate an input image.

ArrayFire Docs

Translating an image is moving it along 1st and 2nd dimensions by trans0 and trans1. Positive values of these will move the data towards negative x and negative y whereas negative values of these will move the positive right and positive down. See the example below for more.

scale Source #

Arguments

:: Array a

is input image

-> Float

is amount by which the first dimension is scaled

-> Float

is amount by which the second dimension is scaled

-> Int

is the first output dimension

-> Int

is the second output dimension

-> InterpType

is the interpolation type (Nearest by default)

-> Array a

will contain the scaled image

Scale an input image.

ArrayFire Docs

Scale is the same functionality as af::resize except that the scale function uses the transform kernels. The other difference is that scale does not set boundary values to be the boundary of the input array. Instead these are set to 0.

skew Source #

Arguments

:: Array a

is input image

-> Float

is amount by which the first dimension is skewed

-> Float

is amount by which the second dimension is skewed

-> Int

is the first output dimension

-> Int

is the second output dimension

-> InterpType

if true applies inverse transform, if false applies forward transoform

-> Bool

is the interpolation type (Nearest by default)

-> Array a

will contain the skewed image

Skew an input image.

ArrayFire Docs

Skew function skews the input array along dim0 by skew0 and along dim1 by skew1. The skew areguments are in radians. Skewing the data means the data remains parallel along 1 dimensions but the other dimensions gets moved along based on the angle. If both skew0 and skew1 are specified, then the data will be skewed along both directions.

histogram Source #

Arguments

:: AFType a 
=> Array a

the input array

-> Int

Number of bins to populate between min and max

-> Double

minimum bin value (accumulates -inf to min)

-> Double

minimum bin value (accumulates max to +inf)

-> Array Word32

(type u32) is the histogram for input array in

Histogram of input data.

ArrayFire Docs

A histogram is a representation of the distribution of given data. This representation is essentially a graph consisting of the data range or domain on one axis and frequency of occurence on the other axis. All the data in the domain is counted in the appropriate bin. The total number of elements belonging to each bin is known as the bin's frequency.

dilate Source #

Arguments

:: Array a

the input image

-> Array a

the neighborhood window

-> Array a

the dilated image

Dilation(morphological operator) for images.

ArrayFire Docs

The dilation function takes two pieces of data as inputs. The first is the input image to be morphed, and the second is the mask indicating the neighborhood around each pixel to match.

  • Note* if mask is all ones, this function behaves like max filter

dilate3 Source #

Arguments

:: Array a

the input volume

-> Array a

the neighborhood delta volume

-> Array a

the dilated volume

Dilation (morphological operator) for volumes.

ArrayFire Docs

Dilation for a volume is similar to the way dilation works on an image. Only difference is that the masking operation is performed on a volume instead of a rectangular region.

erode Source #

Arguments

:: Array a

Array is the input image

-> Array a

(mask) is the neighborhood window

-> Array a

Array is the eroded image

Erosion (morphological operator) for volumes.

ArrayFire Docs

The erosion function is a morphological transformation on an image that requires two inputs. The first is the image to be morphed, and the second is the mask indicating neighborhood that must be white in order to preserve each pixel.

  • Note* if mask is all ones, this function behaves like min filter

erode3 Source #

Arguments

:: Array a

Array is the input volume

-> Array a

(mask) is the neighborhood delta volume

-> Array a

Array is the eroded volume

Erosion (morphological operator) for volumes.

ArrayFire Docs

Erosion for a volume is similar to the way erosion works on an image. Only difference is that the masking operation is performed on a volume instead of a rectangular region.

bilateral Source #

Arguments

:: Array a

Array is the input image

-> Float

is the spatial variance parameter that decides the filter window

-> Float

is the chromatic variance parameter

-> Bool

indicates if the input in is color image or grayscale

-> Array a

Array is the processed image

Bilateral Filter.

ArrayFire Docs

A bilateral filter is a edge-preserving filter that reduces noise in an image. The intensity of each pixel is replaced by a weighted average of the intensities of nearby pixels. The weights follow a Gaussian distribution and depend on the distance as well as the color distance.

meanShift Source #

Arguments

:: Array a

Array is the input image

-> Float

is the spatial variance parameter that decides the filter window

-> Float

is the chromatic variance parameter

-> Int

is the number of iterations filter operation is performed

-> Bool

indicates if the input in is color image or grayscale

-> Array a

Array is the processed image

Meanshift Filter.

ArrayFire Docs

A meanshift filter is an edge-preserving smoothing filter commonly used in object tracking and image segmentation.

minFilt Source #

Arguments

:: Array a

Array is the input image

-> Int

is the kernel height

-> Int

is the kernel width

-> BorderType

value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

-> Array a

Array is the processed image

Find minimum value from a window.

ArrayFire Docs

minfilt finds the smallest value from a 2D window and assigns it to the current pixel.

maxFilt Source #

Arguments

:: Array a

Array is the input image

-> Int

is the kernel height

-> Int

is the kernel width

-> BorderType

value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

-> Array a

Array is the processed image

Find maximum value from a window.

ArrayFire Docs

maxFilt finds the smallest value from a 2D window and assigns it to the current pixel.

regions Source #

Arguments

:: AFType a 
=> Array a

array should be binary image of type CBool

-> Connectivity 
-> Array a

array will have labels indicating different regions

Find blobs in given image.

ArrayFire Docs

Given a binary image (with zero representing background pixels), regions computes a floating point image where each connected component is labeled from 1 to N, the total number of components in the image. ** FIX ME**

sobel_operator Source #

Arguments

:: Array a

is an array with image data

-> Int

sobel kernel size or window size

-> (Array a, Array a)

Derivative along the horizontal and vertical directions

Sobel Operators.

ArrayFire Docs

Sobel operators perform a 2-D spatial gradient measurement on an image to emphasize the regions of high spatial frequency, namely edges

  • Note* If img is 3d array, a batch operation will be performed.

rgb2gray Source #

Arguments

:: Array a

is an array in the RGB color space

-> Float

is percentage of red channel value contributing to grayscale intensity

-> Float

is percentage of green channel value contributing to grayscale intensity

-> Float

is percentage of blue channel value contributing to grayscale intensity

-> Array a

is an array in target color space

RGB to Grayscale colorspace converter.

ArrayFire Docs

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB stores individual values for red, green and blue, and hence the 3 values per pixel. A combination of these three values produces the gamut of unique colors.

gray2rgb Source #

Arguments

:: Array a

is an array in the Grayscale color space

-> Float

is percentage of intensity value contributing to red channel

-> Float

is percentage of intensity value contributing to green channel

-> Float

is percentage of intensity value contributing to blue channel

-> Array a

is an array in target color space

Grayscale to RGB colorspace converter.

ArrayFire Docs

Grayscale is a single channel color space where pixel value ranges from 0 to 1. Zero represents black, one represent white and any value between zero & one is a gray value

histEqual Source #

Arguments

:: Array a

is the input array, non-normalized input (!! assumes values [0-255] !!)

-> Array a

target histogram to approximate in output (based on number of bins)

-> Array a

is an array with data that has histogram approximately equal to histogram

Histogram equalization of input image.

ArrayFire Docs

Histogram equalization is a method in image processing of contrast adjustment using the image's histogram.

gaussianKernel Source #

Arguments

:: Int

number of rows of the gaussian kernel

-> Int

number of columns of the gaussian kernel

-> Double

(default 0) (calculated internally as 0.25 * rows + 0.75)

-> Double

(default 0) (calculated internally as 0.25 * cols + 0.75)

-> Array a

is an array with values generated using gaussian function

Creates a Gaussian Kernel.

ArrayFire Docs

This function creates a kernel of a specified size that contains a Gaussian distribution. This distribution is normalized to one. This is most commonly used when performing a Gaussian blur on an image. The function takes two sets of arguments, the size of the kernel (width and height in pixels) and the sigma parameters (for row and column) which effect the distribution of the weights in the y and x directions, respectively.

hsv2rgb Source #

Arguments

:: Array a

is an array in the HSV color space

-> Array a

is an array in the RGB color space

HSV to RGB colorspace converter.

ArrayFire Docs

C Interface for converting HSV to RGB.

  • Note* input must be three dimensional

rgb2hsv Source #

Arguments

:: Array a

is an array in the RGB color space

-> Array a

is an array in the HSV color space

RGB to HSV colorspace converter.

ArrayFire Docs

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB stores individual values for red, green and blue, and hence the 3 values per pixel. A combination of these three values produces the gamut of unique colors.

colorSpace Source #

Arguments

:: Array a

is the input array

-> CSpace

is the target array color space

-> CSpace

is the input array color space

-> Array a

is an array in target color space

Colorspace conversion function.

ArrayFire Docs

C Interface wrapper for color space conversion.

unwrap Source #

Arguments

:: Array a

the input Array

-> Int

is the window size along dimension 0

-> Int

is the window size along dimension 1

-> Int

is the stride along dimension 0

-> Int

is the stride along dimension 1

-> Int

is the padding along dimension 0

-> Int

is the padding along dimension 1

-> Bool

determines whether an output patch is formed from a column (if true) or a row (if false)

-> Array a

an array with the input's sections rearraged as columns (or rows)

Rearrange windowed sections of an array into columns (or rows).

ArrayFire Docs

C Interface for rearranging windowed sections of an input into columns (or rows)

wrap Source #

Arguments

:: Array a

the input Array

-> Int

is the output's dimension 0 size

-> Int

is the output's dimension 1 size

-> Int

is the window size along dimension 0

-> Int

is the window size along dimension 1

-> Int

is the stride along dimension 0

-> Int

is the stride along dimension 1

-> Int

is the padding along dimension 0

-> Int

is the padding along dimension 1

-> Bool

determines whether an output patch is formed from a column (if true) or a row (if false)

-> Array a

is an array with the input's columns (or rows) reshaped as patches

Performs the opposite of unwrap.

ArrayFire Docs

sat Source #

Arguments

:: Array a

the input Array

-> Array a

is the summed area table on input image(s)

Summed Area Tables.

ArrayFire Docs

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB stores individual values for red, green and blue, and hence the 3 values per pixel. A combination of these three values produces the gamut of unique colors.

ycbcr2rgb :: Array a -> YccStd -> Array a Source #

YCbCr to RGB colorspace converter

ArrayFire Docs

YCbCr is a family of color spaces used as a part of the color image pipeline in video and digital photography systems where Y is luma component and Cb & Cr are the blue-difference and red-difference chroma components.

rgb2ycbcr Source #

Arguments

:: Array a

is an array in the RGB color space

-> YccStd

specifies the ITU-R BT "xyz" standard which determines the Kb, Kr values used in colorspace conversion equation

-> Array a

is an Array in the YCbCr color space

RGB to YCbCr colorspace converter.

ArrayFire Docs

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB stores individual values for red, green and blue, and hence the 3 values per pixel. A combination of these three values produces the gamut of unique colors.

moments Source #

Arguments

:: Array a

is an array of image(s)

-> MomentType

is moment(s) to calculate

-> Array a

is an array containing the calculated moments

Finding different properties of image regions.

ArrayFire Docs

C Interface for calculating image moment(s) of a single image.

momentsAll Source #

Arguments

:: Array a

is the input image

-> MomentType

is moment(s) to calculate

-> Double

is a pointer to a pre-allocated array where the calculated moment(s) will be placed. User is responsible for ensuring enough space to hold all requested moments

Finding different properties of image regions.

ArrayFire Docs

C Interface for calculating image moment(s) of a single image.

canny Source #

Arguments

:: Array a

the input image

-> CannyThreshold

determines if user set high threshold is to be used or not.

-> Float

is the lower threshold % of the maximum or auto-derived high threshold

-> Float

is the higher threshold % of maximum value in gradient image used in hysteresis procedure. This value is ignored if AF_CANNY_THRESHOLD_AUTO_OTSU is chosen as af_canny_threshold

-> Int

is the window size of sobel kernel for computing gradient direction and magnitude

-> Bool

indicates if L1 norm(faster but less accurate) is used to compute image gradient magnitude instead of L2 norm.

-> Array a

is an binary array containing edges

Canny Edge Detector

ArrayFire Docs

The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images.

anisotropicDiffusion Source #

Arguments

:: Array a

is the input image, expects non-integral (float/double) typed af_array

-> Float

is the time step used in solving the diffusion equation.

-> Float

parameter controls the sensitivity of conductance in diffusion equation.

-> Int

is the number of times the diffusion step is performed.

-> FluxFunction

indicates whether quadratic or exponential flux function is used by algorithm.

-> DiffusionEq

will let the user choose what kind of diffusion method to perform.

-> Array a

is an Array containing anisotropically smoothed image pixel values

Anisotropic Smoothing Filter.

ArrayFire Docs

C Interface for anisotropic diffusion.