Copyright | David Johnson (c) 2019-2020 |
---|---|
License | BSD 3 |
Maintainer | David Johnson <djohnson.m@gmail.com> |
Stability | Experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- gradient :: Array a -> (Array a, Array a)
- loadImage :: String -> Bool -> IO (Array a)
- saveImage :: Array a -> String -> IO ()
- loadImageNative :: String -> IO (Array a)
- saveImageNative :: Array a -> String -> IO ()
- isImageIOAvailable :: IO Bool
- resize :: Array a -> Int -> Int -> InterpType -> Array a
- transform :: Array a -> Array a -> Int -> Int -> InterpType -> Bool -> Array a
- transformCoordinates :: Array a -> Float -> Float -> Array a
- rotate :: Array a -> Float -> Bool -> InterpType -> Array a
- translate :: Array a -> Float -> Float -> Int -> Int -> InterpType -> Array a
- scale :: Array a -> Float -> Float -> Int -> Int -> InterpType -> Array a
- skew :: Array a -> Float -> Float -> Int -> Int -> InterpType -> Bool -> Array a
- histogram :: AFType a => Array a -> Int -> Double -> Double -> Array Word32
- dilate :: Array a -> Array a -> Array a
- dilate3 :: Array a -> Array a -> Array a
- erode :: Array a -> Array a -> Array a
- erode3 :: Array a -> Array a -> Array a
- bilateral :: Array a -> Float -> Float -> Bool -> Array a
- meanShift :: Array a -> Float -> Float -> Int -> Bool -> Array a
- minFilt :: Array a -> Int -> Int -> BorderType -> Array a
- maxFilt :: Array a -> Int -> Int -> BorderType -> Array a
- regions :: forall a. AFType a => Array a -> Connectivity -> Array a
- sobel_operator :: Array a -> Int -> (Array a, Array a)
- rgb2gray :: Array a -> Float -> Float -> Float -> Array a
- gray2rgb :: Array a -> Float -> Float -> Float -> Array a
- histEqual :: Array a -> Array a -> Array a
- gaussianKernel :: Int -> Int -> Double -> Double -> Array a
- hsv2rgb :: Array a -> Array a
- rgb2hsv :: Array a -> Array a
- colorSpace :: Array a -> CSpace -> CSpace -> Array a
- unwrap :: Array a -> Int -> Int -> Int -> Int -> Int -> Int -> Bool -> Array a
- wrap :: Array a -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Bool -> Array a
- sat :: Array a -> Array a
- ycbcr2rgb :: Array a -> YccStd -> Array a
- rgb2ycbcr :: Array a -> YccStd -> Array a
- moments :: Array a -> MomentType -> Array a
- momentsAll :: Array a -> MomentType -> Double
- canny :: Array a -> CannyThreshold -> Float -> Float -> Int -> Bool -> Array a
- anisotropicDiffusion :: Array a -> Float -> Float -> Int -> FluxFunction -> DiffusionEq -> Array a
Documentation
gradient :: Array a -> (Array a, Array a) Source #
Calculates the gradient of an image
>>> print (gradient image)
:: 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
:: 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.
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.
:: 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.
The transform function uses an affine or perspective transform matrix to tranform an input image into a new one.
:: 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.
C Interface for transforming an image C++ Interface for transforming coordinates.
:: 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.
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.
:: 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.
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.
:: 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.
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.
:: 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.
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.
:: 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.
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.
Dilation(morphological operator) for images.
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
Dilation (morphological operator) for volumes.
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.
:: Array a |
|
-> Array a | (mask) is the neighborhood window |
-> Array a |
|
Erosion (morphological operator) for volumes.
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
:: Array a |
|
-> Array a | (mask) is the neighborhood delta volume |
-> Array a |
|
Erosion (morphological operator) for volumes.
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.
:: Array a |
|
-> 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 |
|
Bilateral Filter.
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.
:: Array a |
|
-> 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 |
|
Meanshift Filter.
A meanshift filter is an edge-preserving smoothing filter commonly used in object tracking and image segmentation.
:: Array a |
|
-> 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 |
|
Find minimum value from a window.
minfilt finds the smallest value from a 2D window and assigns it to the current pixel.
:: Array a |
|
-> 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 |
|
Find maximum value from a window.
maxFilt
finds the smallest value from a 2D window and assigns it to the current pixel.
:: 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.
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**
:: 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.
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.
:: 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.
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.
:: 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.
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
:: 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.
Histogram equalization is a method in image processing of contrast adjustment using the image's histogram.
:: 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.
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.
HSV to RGB colorspace converter.
C Interface for converting HSV to RGB.
- Note* input must be three dimensional
RGB to HSV colorspace converter.
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.
:: Array a | the input |
-> 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).
C Interface for rearranging windowed sections of an input into columns (or rows)
:: Array a | the input |
-> 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.
Summed Area Tables.
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
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.
:: 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 |
RGB to YCbCr colorspace converter.
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.
:: 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.
C Interface for calculating image moment(s) of a single image.
:: 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.
C Interface for calculating image moment(s) of a single image.
:: 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
The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images.
:: 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 |