Image Processing (vImage)

AppleAccelerate.jl wraps a large, idiomatic subset of Apple's vImage image-processing subframework — geometry (scale/rotate/reflect/affine/perspective/ shear), convolution & morphology, histogram operations, alpha compositing, colour transforms, and format/bit-depth conversion. Roughly 390 of vImage's ~480 operation functions are exposed (>80% coverage), generated by hand directly against the Accelerate binary (the vImage headers cannot be processed by Clang.jl).

Representing images

vImage is row-major and describes a buffer by {data, height, width, rowBytes}, while Julia is column-major. The wrappers map an image onto a Julia array so the in-memory byte order matches vImage's exactly — no transpose is needed:

Image kindJulia arrayvImage widthvImage heightrowBytes
Planar (1 channel)Matrix{T} sized (width, height)size(A,1)size(A,2)size(A,1)*sizeof(T)
Interleaved (N channels)Array{T,3} sized (channels, width, height)size(A,2)size(A,3)size(A,1)*size(A,2)*sizeof(T)

So a w×h Julia Matrix is a w-wide, h-tall vImage image, and an interleaved ARGB8888 image is an Array{UInt8,3} whose first dimension is 4. The pixel format is encoded in each function's name suffix (Planar8, PlanarF, ARGB8888, ARGBFFFF, ARGB16U, CbCr16F, …), following the C API.

Build a raw descriptor with vimage_buffer.

API conventions

  • Each operation has an allocating form foo(src, …) returning a fresh array and a mutating form foo!(dest, src, …) writing into a caller-provided dest. Format conversions whose destination type differs from the source expose only the mutating foo! form (allocate the correctly-typed dest yourself).
  • Options are keyword arguments; flags accepts the kvImage* flag constants (e.g. kvImageEdgeExtend, kvImageBackgroundColorFill, kvImageDoNotTile).
  • Every wrapper is GC-safe (GC.@preserve roots all backing arrays across the ccall) and checks the returned vImage_Error, throwing vImageError on failure.
using AppleAccelerate
const V = AppleAccelerate

img = rand(Float32, 640, 480)                 # a 640×480 planar image
small = V.scale_PlanarF(img, 320, 240)        # resize
blur  = V.tentConvolve_Planar8(rand(UInt8, 640, 480), 5, 5)

argb = rand(UInt8, 4, 640, 480)               # interleaved ARGB
pm   = V.premultiplyData_ARGB8888(argb)       # premultiply by alpha
bgr  = V.permuteChannels_ARGB8888(argb, UInt8[3,2,1,0])   # reverse channels

Types and helpers

AppleAccelerate.vImage_BufferType
vImage_Buffer

Mirror of the C vImage_Buffer descriptor: data::Ptr{Cvoid}, height, width, rowBytes (all Csize_t). Built from a Julia array by vimage_buffer and passed to vImage functions by Ref. The struct only borrows the array's pointer, so the backing array must be kept alive (GC.@preserve) for the duration of any call.

source
AppleAccelerate.vimage_bufferFunction
vimage_buffer(A) -> vImage_Buffer

Build a vImage_Buffer descriptor that borrows the memory of Julia array A.

  • A::AbstractMatrix is treated as a planar (single-channel) image of size (width, height) == (size(A,1), size(A,2)).
  • A::AbstractArray{T,3} is treated as an interleaved image whose first dimension is the channel count, i.e. size (channels, width, height).

The descriptor only stores a raw pointer; keep A alive with GC.@preserve while the descriptor (or any Ref of it) is in use. See the layout note at the top of vimage.jl.

source

Geometry

Resize, rotate, reflect, affine/perspective warp and shear. Available across the planar and interleaved 8-/16-/float formats.

AppleAccelerate.scale_Planar8Function
scale_Planar8(src, width, height; flags=kvImageNoFlags) -> Matrix
scale_ARGB8888(src, width, height; flags=kvImageNoFlags) -> Array

Resample planar/interleaved image src to a new width × height (in vImage pixels), allocating and returning the destination. Mutating scale_*!(dest, src) variants scale into a caller-provided dest of the desired size. Available for formats Planar8/16S/16U/16F/F, ARGB8888/16U/16S/16F/FFFF, CbCr8/16U/16F.

source
AppleAccelerate.horizontalReflect_Planar8Function
horizontalReflect_Planar8(src; flags=kvImageNoFlags)
verticalReflect_ARGB8888(src; flags=kvImageNoFlags)

Mirror an image across the vertical (horizontalReflect_*) or horizontal (verticalReflect_*) axis. Allocating and ! mutating variants; formats Planar8/16U/16F/F, ARGB8888/16U/16S/16F/FFFF, CbCr16F.

source
AppleAccelerate.rotate90_Planar8Function
rotate90_Planar8(src, rotationConstant; backColor, flags) -> array

Rotate by rotationConstant * 90° counter-clockwise (rotationConstant ∈ 0:3). The allocating variant returns a correctly-shaped destination (dimensions swap for 90°/270°); rotate90_*!(dest, src, rotationConstant) rotates into dest. backColor is a scalar for planar formats or a length-4 vector for interleaved formats.

source
AppleAccelerate.rotate_Planar8Function
rotate_Planar8(src, angleInRadians; backColor, flags) -> array

Rotate src counter-clockwise by angleInRadians about the image centre, filling exposed corners with backColor. Allocating (same-size canvas) and ! mutating variants. Formats Planar8/16F/F, ARGB8888/16U/16S/16F/FFFF, CbCr16F.

source
AppleAccelerate.affineWarp_Planar8Function
affineWarp_Planar8(src, transform::vImage_AffineTransform; backColor, flags) -> array
affineWarpD_ARGB8888(src, transform::vImage_AffineTransform_Double; ...) -> array

Apply an affine warp. affineWarp_* uses a single-precision vImage_AffineTransform; affineWarpD_* uses the double-precision vImage_AffineTransform_Double. The identity transform reproduces the input. Allocating (same-size) and ! variants.

source
AppleAccelerate.affineWarpCG_ARGB8888Function
affineWarpCG_ARGB8888(src, transform::vImage_AffineTransform_Double; backColor, flags)

Affine warp using a CoreGraphics-compatible (vImage_CGAffineTransform, double precision) transform. Formats Planar8/F, ARGB8888/16U/16S/FFFF.

source
AppleAccelerate.perspectiveWarp_Planar8Function
perspectiveWarp_Planar8(src, transform::vImage_PerspectiveTransform; interpolation=1, backColor, flags)

Apply a projective (perspective) warp. interpolation selects nearest (0) or linear (1). Formats Planar8/16U/16F, ARGB8888/16U/16F.

source
AppleAccelerate.horizontalShear_Planar8Function
horizontalShear_Planar8(src, xTranslate, shearSlope; backColor, flags)
verticalShearD_ARGB8888(src, yTranslate, shearSlope; ...)

Shear an image using the default (Lanczos) resampling filter. *Shear* take a single-precision translate/slope; the *ShearD* forms take double precision. Allocating (same-size) and ! mutating variants.

source

Convolution

General, separable, box and tent convolution with integer or float kernels.

AppleAccelerate.convolve_Planar8Function
convolve_Planar8(src, kernel::Matrix{<:Integer}; divisor=1, backColor, flags) -> array
convolve_ARGBFFFF(src, kernel::Matrix{<:Real}; backColor, flags) -> array

General 2-D convolution. Integer-pixel formats (Planar8, ARGB8888) take an integer kernel and an integer divisor (output = Σ(kernel .* window) / divisor); floating-point formats (PlanarF, Planar16F, ARGBFFFF, ARGB16F) take a real kernel. kernel is (kernel_height, kernel_width). Allocating and ! variants.

source
AppleAccelerate.convolveWithBias_Planar8Function
convolveWithBias_Planar8(src, kernel; divisor=1, bias=0, backColor, flags) -> array

Like convolve_Planar8 but adds bias to the (divided) accumulator before storing. Allocating and ! variants for Planar8, ARGB8888, PlanarF, Planar16F, ARGBFFFF, ARGB16F.

source
AppleAccelerate.sepConvolve_PlanarFFunction
sepConvolve_PlanarF(src, kernelX, kernelY; bias=0, backColor, flags)

Separable convolution: convolve rows by kernelX and columns by kernelY. Cheaper than a full 2-D kernel when the kernel is separable. Formats Planar8/16U/16F/F, ARGB8888. Allocating and ! variants.

source
AppleAccelerate.boxConvolve_Planar8Function
boxConvolve_Planar8(src, kernelHeight, kernelWidth; backColor, flags) -> array
tentConvolve_ARGB8888(src, kernelHeight, kernelWidth; backColor, flags) -> array

Fast box (uniform average) and tent (triangular/linear) blur over a kernelHeight × kernelWidth window. Convolving a constant image reproduces the constant. Allocating and ! variants for Planar8, ARGB8888.

source

Morphology

Grayscale dilation/erosion with an arbitrary structuring element, and fast rectangular max/min filters.

AppleAccelerate.dilate_Planar8Function
dilate_Planar8(src, kernel::Matrix{UInt8}; flags) -> array
erode_ARGB8888(src, kernel::Matrix{UInt8}; flags) -> array

Grayscale morphological dilation / erosion with an arbitrary kernel (structuring element). kernel size is (kernel_height, kernel_width). Allocating and ! variants. Formats Planar8/F, ARGB8888/FFFF.

source
AppleAccelerate.max_Planar8Function
max_Planar8(src, kernelHeight, kernelWidth; flags) -> array
min_ARGB8888(src, kernelHeight, kernelWidth; flags) -> array

Rectangular maximum / minimum filter (dilation / erosion by a solid kernelHeight × kernelWidth rectangle). Allocating and ! variants; formats Planar8/F, ARGB8888/FFFF.

source

Histogram

AppleAccelerate.equalization_Planar8Function
equalization_Planar8(src; flags) -> array
contrastStretch_ARGBFFFF(src; entries=4096, minVal=0, maxVal=1, flags) -> array

Histogram equalization / linear contrast stretch. Integer formats (Planar8, ARGB8888) take no extra arguments; float formats (PlanarF, ARGBFFFF) take histogram entries and the value range [minVal, maxVal]. Allocating and ! variants.

source
AppleAccelerate.endsInContrastStretch_Planar8Function
endsInContrastStretch_Planar8(src; percentLow=0, percentHigh=0, flags) -> array

Ends-in contrast stretch of an 8-bit planar image: clip percentLow% of the darkest and percentHigh% of the brightest pixels, then rescale. Allocating and ! variants.

source
AppleAccelerate.endsInContrastStretch_ARGB8888Function
endsInContrastStretch_ARGB8888(src; percentLow, percentHigh, flags) -> array

Per-channel ends-in contrast stretch of an ARGB8888 image; percentLow/percentHigh are length-4 collections. Allocating and ! variants.

source

Alpha & compositing

Premultiply / un-premultiply, source-over and named blend modes, and planar alpha blending.

AppleAccelerate.premultiplyData_ARGB8888Function
premultiplyData_ARGB8888(src; flags) -> array
unpremultiplyData_ARGBFFFF(src; flags) -> array
premultiplyData_Planar8(src, alpha; flags) -> array

Premultiply / un-premultiply colour channels by alpha. Interleaved formats (ARGB8888/FFFF/16U/16Q12, RGBA8888/FFFF/16F/16U/16Q12) carry alpha inside the pixel; planar formats (Planar8, PlanarF) take a separate alpha plane. premultiply then unpremultiply round-trips (within rounding). Allocating and ! variants. See also clipToAlpha_ARGB8888.

source
AppleAccelerate.clipToAlpha_ARGB8888Function
clipToAlpha_ARGB8888(src; flags) -> array

Clamp each colour channel to not exceed its alpha (produces valid premultiplied data). Allocating and ! variants; interleaved ARGB8888/FFFF, RGBA8888/FFFF, and planar Planar8/F (which take a separate alpha plane).

source
AppleAccelerate.premultipliedAlphaBlend_ARGB8888Function
premultipliedAlphaBlend_ARGB8888(srcTop, srcBottom; flags) -> array

Composite premultiplied srcTop over srcBottom (source-over). Named Porter–Duff / blend-mode variants are also available: premultipliedAlphaBlendMultiply_RGBA8888, …Screen…, …Darken…, …Lighten…, plus alphaBlend_ARGB8888 (non-premultiplied over) and alphaBlend_NonpremultipliedToPremultiplied_ARGB8888. Allocating and ! variants.

source
AppleAccelerate.alphaBlend_Planar8Function
alphaBlend_Planar8(srcTop, srcTopAlpha, srcBottom, srcBottomAlpha, alpha; flags) -> array

Non-premultiplied planar alpha blend of two images given their alpha planes and an overall blend alpha plane. Allocating and ! variants.

source

Colour transforms

Colour-matrix multiply, piecewise gamma, lookup tables and flood fill.

AppleAccelerate.matrixMultiply_ARGB8888Function
matrixMultiply_ARGB8888(src, matrix::Matrix{<:Integer}; divisor=256, preBias, postBias, flags) -> array

Apply a 4×4 colour matrix to every ARGB8888 pixel: out = (matrix*(in+preBias))/divisor + postBias. matrix is given in natural (row-per-output-channel) order. Allocating and ! variants.

source
AppleAccelerate.matrixMultiply_ARGBFFFFFunction
matrixMultiply_ARGBFFFF(src, matrix::Matrix{<:Real}; preBias, postBias, flags) -> array

Floating-point 4×4 colour-matrix multiply of an ARGBFFFF image. Allocating and ! variants.

source
AppleAccelerate.matrixMultiply_ARGB8888ToPlanar8!Function
matrixMultiply_ARGB8888ToPlanar8!(dest, src, matrix; divisor=256, preBias, postBias, flags) -> dest

Reduce a 4-channel image to one planar channel via a length-4 dot-product matrix (e.g. RGB→luminance). !-only; matrixMultiply_ARGBFFFFToPlanarF! is the float form.

source
AppleAccelerate.piecewiseGamma_PlanarFFunction
piecewiseGamma_PlanarF(src; exponentialCoeffs, gamma, linearCoeffs, boundary, flags) -> array

Apply a piecewise gamma curve: for x ≥ boundary, out = (a·x + b)^gamma + c with exponentialCoeffs = (a, b, c); below the boundary a linear segment linearCoeffs = (d, e) (out = d·x + e) is used. Allocating and ! variants for Planar8, PlanarF, Planar16Q12.

source
AppleAccelerate.symmetricPiecewiseGamma_PlanarF!Function
symmetricPiecewiseGamma_PlanarF!(dest, src; exponentialCoeffs, gamma, linearCoeffs, boundary, flags)

Symmetric piecewise gamma (odd-symmetric about 0), plus cross-type piecewise gamma mutating variants piecewiseGamma_Planar8toPlanarF!, …Planar8toPlanar16Q12!, …Planar16Q12toPlanar8!, …PlanarFtoPlanar8!.

source
AppleAccelerate.lookupTable_Planar8toPlanarF!Function
lookupTable_Planar8toPlanarF(dest, src, table) -> dest

Map each 8-bit source pixel through a 256-entry table. Mutating variants for Planar8toPlanar16 (UInt16 table/output) and Planar8toPlanarF (Float32).

source
AppleAccelerate.lookupTable_Planar16!Function
lookupTable_Planar16!(dest, src, table) -> dest

Additional lookup-table mappings: lookupTable_8to64U! (256-entry UInt64 table), lookupTable_PlanarFtoPlanar8! (4096-entry UInt8 table over [0,1]), and lookupTable_Planar16! (65536-entry UInt16 table).

source
AppleAccelerate.floodFill_Planar8!Function
floodFill_Planar8!(srcDest, seedX, seedY, newValue; connectivity=4, flags)

Flood-fill (in place) the connected region of srcDest containing pixel (seedX, seedY) (0-based, vImage coordinates) with newValue. connectivity is 4 or

  1. Variants for Planar8, Planar16U, ARGB8888, ARGB16U (interleaved take a

length-4 newValue).

source

Channel manipulation & conversion

Permute/extract/overwrite/select channels, fill, table lookup, flatten over a background, (de)interleave planes, and a broad set of format / bit-depth conversions.

AppleAccelerate.permuteChannels_ARGB8888Function
permuteChannels_ARGB8888(src, permuteMap; flags) -> array

Reorder the channels of an interleaved image. permuteMap (0-based, length 4 for ARGB formats or 3 for RGB888) gives, for each destination channel, the source channel index. Allocating and ! variants for ARGB8888/16U/16F/FFFF and RGB888.

source
AppleAccelerate.permuteChannelsWithMaskedInsert_ARGB8888Function
permuteChannelsWithMaskedInsert_ARGB8888(src, permuteMap, copyMask; backgroundColor, flags) -> array

Permute channels per permuteMap, but for channels selected by copyMask insert the constant backgroundColor instead. Formats ARGB8888/16U/FFFF.

source
AppleAccelerate.extractChannel_ARGB8888Function
extractChannel_ARGB8888(src, channelIndex; flags) -> Matrix

Extract one channel (0-based channelIndex) of an interleaved image into a planar buffer. Allocating and ! variants for ARGB8888, ARGB16U, ARGBFFFF.

source
AppleAccelerate.bufferFill_ARGB8888!Function
bufferFill_ARGB8888!(dest, color; flags) -> dest

Fill every pixel of interleaved dest with the constant color (a length-channels collection). Variants for ARGB8888/16U/16S/FFFF and CbCr8/16U/16S.

source
AppleAccelerate.overwriteChannels_ARGB8888Function
overwriteChannels_ARGB8888(newSrc, origSrc, copyMask; flags) -> array
selectChannels_ARGBFFFF(newSrc, origSrc, copyMask; flags) -> array

Copy the channels selected by the bitmask copyMask from newSrc, and the rest from origSrc, into the destination. Formats ARGB8888, ARGBFFFF.

source
AppleAccelerate.overwriteChannelsWithPixel_ARGB8888Function
overwriteChannelsWithPixel_ARGB8888(src, pixel, copyMask; flags) -> array

Replace the channels selected by copyMask with the constant value from pixel (length-4), copying the rest from src. Formats ARGB8888/16U/FFFF.

source
AppleAccelerate.tableLookUp_ARGB8888Function
tableLookUp_ARGB8888(src, alphaTable, redTable, greenTable, blueTable; flags) -> array

Independently remap each channel of an ARGB8888 image through its own 256-entry table. Allocating and ! variants.

source
AppleAccelerate.flatten_ARGB8888ToRGB888!Function
flatten_ARGB8888ToRGB888!(dest, src, backgroundColor; isImagePremultiplied=true, flags) -> dest

Composite a 4-channel image over an opaque backgroundColor (length-4 collection), producing a 3-channel RGB image. Mutating variants for ARGB/RGBA/BGRA × 8888/FFFF.

source
AppleAccelerate.flatten_ARGB8888Function
flatten_ARGB8888(src, backgroundColor; isImagePremultiplied=true, flags) -> array

Composite a 4-channel image over an opaque backgroundColor (length-4), keeping the 4-channel layout. Formats ARGB/RGBA × 8888/16U/16Q12/FFFF. Allocating and ! variants.

source
AppleAccelerate.copyBuffer!Function
copyBuffer!(dest, src; pixelSize, flags) -> dest

Copy src to dest accounting for rowBytes padding. pixelSize is the size of one pixel in bytes.

source
AppleAccelerate.convert_ARGB8888toPlanar8Function
convert_ARGB8888toPlanar8(src, destA, destR, destG, destB) -> (destA,destR,destG,destB)
convert_Planar8toARGB8888(dest, srcA, srcR, srcG, srcB) -> dest

Deinterleave an interleaved image into four planar channel buffers, or interleave four planes into one buffer. Also available for the float variants convert_ARGBFFFFtoPlanarF / convert_PlanarFtoARGBFFFF.

source
AppleAccelerate.convert_Planar8toRGB888Function
convert_Planar8toRGB888(dest, red, green, blue) -> dest
convert_RGB888toPlanar8(src, red, green, blue) -> (red, green, blue)

Interleave three planar channels into an RGB image, or split an RGB image into planes. Variants for Planar8/RGB888, PlanarF/RGBFFF, Planar16U/RGB16U, plus 4-plane convert_Planar16UtoARGB16U / convert_ARGB16UtoPlanar16U.

source
AppleAccelerate.convert_ARGB8888toPlanarFFunction
convert_ARGB8888toPlanarF(src, a, r, g, b; maxFloat, minFloat, flags) -> (a,r,g,b)

Deinterleave an ARGB8888 image into four float planes, mapping [0,255] to [minFloat, maxFloat] per channel (length-4 collections).

source
AppleAccelerate.convert_16UToPlanar8!Function
convert_16UToPlanar8!(dest, src; flags) -> dest
convert_ARGB8888toRGB888!(dest, src; flags) -> dest

Format / bit-depth conversions with the shape (src, dest, flags). Because the destination pixel format differs from the source, only the mutating foo!(dest, src) form is provided — allocate a correctly-typed dest and pass it in. See the vImage docs page for the full list of wrapped conversions.

source
AppleAccelerate.convert_Planar8toPlanarF!Function
convert_Planar8toPlanarF!(dest, src; maxFloat=1, minFloat=0, flags) -> dest
convert_PlanarFtoPlanar8!(dest, src; maxFloat=1, minFloat=0, flags) -> dest
clip_PlanarF!(dest, src; maxFloat=1, minFloat=0, flags) -> dest

Planar 8-bit ↔ float conversion mapping [0,255] ↔ [minFloat, maxFloat], and float clamping (clip_PlanarF!). Also provided allocating: convert_Planar8toPlanarF(src) returns a Matrix{Float32}; convert_PlanarFtoPlanar8(src) returns Matrix{UInt8}.

source
AppleAccelerate.convert_16UToF!Function
convert_16UToF!(dest, src; offset=0, scale=1, flags) -> dest

Integer ↔ float planar conversions with an affine map out = (in - offset)/scale (or its inverse). Mutating variants for 16SToF, 16UToF, FTo16S, FTo16U.

source
AppleAccelerate.convert_RGB888toARGB8888!Function
convert_RGB888toARGB8888!(dest, rgbSrc; alpha=1, alphaPlane=nothing, premultiply=false, flags)
convert_RGB565toARGB8888!(dest, src; alpha=255, flags)

Add an alpha channel to a 3-channel image, producing a 4-channel result. A constant alpha (or an alphaPlane) is inserted; premultiply optionally premultiplies. !-only.

source
AppleAccelerate.convert_ARGB16UToARGB8888!Function
convert_ARGB16UToARGB8888!(dest, src; permuteMap=(0,1,2,3), copyMask=0, backgroundColor, flags)

Bit-depth conversion between 8- and 16-bit interleaved 4-channel formats with optional channel permutation and masked background insertion. !-only variants convert_ARGB16UToARGB8888!, convert_ARGB8888ToARGB16U!, convert_RGB16UToARGB8888!.

source
AppleAccelerate.convert_ARGB8888ToARGB2101010!Function
convert_ARGB8888ToARGB2101010!(dest, src; rangeMin=0, rangeMax=1023, permuteMap=(0,1,2,3), flags) -> dest

Conversions to/from packed 2101010 (10-bit-per-channel, 32-bit) pixel formats. Packed buffers are represented as a planar Matrix{UInt32}. rangeMin/rangeMax set the integer range mapping to [0,1] for the 10-bit channels; permuteMap reorders channels. Mutating variants only. See the docs page for the full list.

source
AppleAccelerate.convert_XRGB2101010ToARGB8888!Function
convert_XRGB2101010ToARGB8888!(dest, src; alpha=0, rangeMin=0, rangeMax=1023, permuteMap, flags)

Expand a packed XRGB2101010 image (planar Matrix{UInt32}) into a 4-channel image, supplying the alpha channel from the scalar alpha. !-only.

source

Y′CbCr ⇄ ARGB conversion

Convert between RGB/ARGB and 4:4:4 Y′CbCr chroma layouts (8- and 16-bit). A conversion matrix, a pixelRange, and the input/output format codes are baked once into a reusable opaque info blob by a GenerateConversion call, then handed to the per-image convert routines. Standard ITU-R BT.601-4 / BT.709-2 matrices are provided as constants.

AppleAccelerate.vImage_YpCbCrPixelRangeType
vImage_YpCbCrPixelRange(Yp_bias, CbCr_bias, YpRangeMax, CbCrRangeMax, YpMax, YpMin, CbCrMax, CbCrMin)

Range and clamping information for a Y'CbCr pixel format (8 × Int32). Handy presets: kvImageYpCbCrPixelRange_VideoRange_8bit_Clamped, kvImageYpCbCrPixelRange_FullRange_8bit_Clamped.

source
AppleAccelerate.convert_YpCbCrToARGB_GenerateConversionFunction
convert_YpCbCrToARGB_GenerateConversion(matrix, pixelRange, ypCbCrType, argbType; flags) -> vImage_YpCbCrToARGB

Bake a matrix::vImage_YpCbCrToARGBMatrix + pixelRange::vImage_YpCbCrPixelRange and the input ypCbCrType / output argbType format codes into a reusable vImage_YpCbCrToARGB info blob for the convert_*ToARGB* routines. Reuse the returned info across many conversions rather than regenerating it.

source
AppleAccelerate.convert_444CrYpCb8ToARGB8888!Function
convert_444CrYpCb8ToARGB8888!(dest, src, info; permuteMap=(0,1,2,3), alpha=0, flags)
convert_ARGB8888To444CrYpCb8!(dest, src, info; permuteMap=(0,1,2,3), flags)

4:4:4 Y'CbCr ⇄ ARGB conversions. Build info once with convert_YpCbCrToARGB_GenerateConversion (for *ToARGB*) or convert_ARGBToYpCbCr_GenerateConversion (for ARGB*To444*), then reuse it. Images are interleaved Array{T,3} sized (channels, width, height): 3-channel v308 (444CrYpCb8), 4-channel v408/y408 (444CbYpCrA8 / 444AYpCbCr8) and 4-channel 16-bit y416 (444AYpCbCr16). permuteMap reorders the ARGB channels; alpha supplies the constant alpha when the Y'CbCr side has none. !-only. Wrapped: convert_444AYpCbCr8ToARGB8888!, convert_444CbYpCrA8ToARGB8888!, convert_444CrYpCb8ToARGB8888!, convert_444AYpCbCr16ToARGB8888!, convert_444AYpCbCr16ToARGB16U!, and the five convert_ARGB*To444*! inverses.

source

Multi-kernel & float-kernel convolution

Convolution with a separate kernel per channel, and single-kernel float convolution of an 8-bit image.

AppleAccelerate.convolveMultiKernel_ARGB8888!Function
convolveMultiKernel_ARGB8888!(dest, src, kernels; divisors, biases, backgroundColor,
                              srcOffsetX=0, srcOffsetY=0, flags=kvImageEdgeExtend) -> dest

Convolve a 4-channel ARGB8888 image applying a separate integer kernel to each channel. kernels is a length-4 collection of equal-size (kernelHeight, kernelWidth) integer matrices (both dims odd); divisors and biases are length-4. One edging-mode flag is required (kvImageEdgeExtend, kvImageBackgroundColorFill, kvImageCopyInPlace or kvImageTruncateKernel). Allocating and ! variants. With four identical kernels this matches convolve_Planar8.

source
AppleAccelerate.convolveMultiKernel_ARGBFFFF!Function
convolveMultiKernel_ARGBFFFF!(dest, src, kernels; biases, backgroundColor,
                              srcOffsetX=0, srcOffsetY=0, flags=kvImageEdgeExtend) -> dest

Float per-channel convolution of an ARGBFFFF image: kernels is a length-4 collection of equal-size float matrices, biases length-4 (no divisor). See convolveMultiKernel_ARGB8888!. Allocating and ! variants.

source
AppleAccelerate.convolveFloatKernel_ARGB8888!Function
convolveFloatKernel_ARGB8888!(dest, src, kernel; bias=0, backColor=(0,0,0,0),
                              srcOffsetX=0, srcOffsetY=0, flags) -> dest

Convolve an ARGB8888 image with a single floating-point kernel (higher precision than the integer-kernel convolve_Planar8). kernel is (kernelHeight, kernelWidth). Allocating and ! variants.

source

Multi-plane matrix multiply

Multiply M source planes by an M×N matrix to produce N destination planes.

AppleAccelerate.matrixMultiply_Planar8Function
matrixMultiply_Planar8(srcs, dests, matrix; divisor=1, preBias, postBias, flags) -> dests
matrixMultiply_PlanarF(srcs, dests, matrix; preBias, postBias, flags) -> dests

Multiply the M source planes by an M×N matrix to produce the N destination planes: out[j] = Σ_i (in[i]+preBias[i])·matrix[i,j] (then +postBias[j], and /divisor for the integer forms Planar8/Planar16S). srcs/dests are vectors of equally-sized planar matrices. Writes into dests.

source

Additional compositing, histogram and conversion

Extra alpha-compositing operators, float/interleaved histogram specification and ends-in contrast stretch, plane⇄interleaved conversions and Planar16Q12 fixed-point conversions.

AppleAccelerate.premultipliedAlphaBlend_Planar8Function
premultipliedAlphaBlend_Planar8(srcTop, srcTopAlpha, srcBottom; flags) -> plane
premultipliedConstAlphaBlend_ARGB8888(srcTop, constAlpha, srcBottom; flags) -> array

Additional alpha-compositing operators. premultipliedAlphaBlend_Planar8/PlanarF blend a premultiplied planar top (with its alpha plane) over a premultiplied bottom; alphaBlend_NonpremultipliedToPremultiplied_Planar8/PlanarF do the same from a non-premultiplied top; premultipliedConstAlphaBlend_* scale the top's alpha by a scalar constAlpha (planar forms take a separate srcTopAlpha plane, interleaved ARGB8888/FFFF forms use the in-pixel alpha). Allocating and ! variants.

source
AppleAccelerate.premultipliedAlphaBlendWithPermute_ARGB8888Function
premultipliedAlphaBlendWithPermute_ARGB8888(srcTop, srcBottom; permuteMap=(0,1,2,3),
                                            makeDestAlphaOpaque=false, flags) -> array

Source-over premultiplied blend that first permutes the top image's channels by permuteMap; set makeDestAlphaOpaque to force the result alpha to opaque. Variants for ARGB8888 and RGBA8888. Allocating and ! variants.

source
AppleAccelerate.histogramSpecification_PlanarFFunction
histogramSpecification_PlanarF(src, desiredHistogram; entries, minVal=0, maxVal=1, flags) -> plane
histogramSpecification_ARGB8888(src, desiredHistogram; flags) -> array

Remap an image so its histogram matches desiredHistogram. PlanarF/ARGBFFFF take the histogram bin count entries and value range [minVal, maxVal] (the ARGB* forms take a length-4 collection of per-channel histograms). Allocating and ! variants; see also histogramSpecification_Planar8.

source
AppleAccelerate.endsInContrastStretch_PlanarFFunction
endsInContrastStretch_PlanarF(src; percentLow=0, percentHigh=0, entries=4096, minVal, maxVal, flags) -> plane

Float ends-in contrast stretch (clip percentLow%/percentHigh% of the darkest/brightest pixels, then rescale). endsInContrastStretch_ARGBFFFF takes length-4 percentages. See the integer endsInContrastStretch_Planar8. Allocating and ! variants.

source
AppleAccelerate.convert_XRGB8888ToPlanar8Function
convert_XRGB8888ToPlanar8(src, red, green, blue) -> (red, green, blue)
convert_BGRX8888ToPlanar8(src, blue, green, red) -> (blue, green, red)

Deinterleave a 4-channel image into three planes, discarding the padding (X) channel. XRGB* writes planes in r,g,b order, BGRX* in b,g,r order (Planar8/PlanarF).

source
AppleAccelerate.convert_Planar8ToARGBFFFF!Function
convert_Planar8ToARGBFFFF!(dest, alpha, red, green, blue; maxFloat, minFloat, flags) -> dest
convert_PlanarFToARGB8888!(dest, alpha, red, green, blue; maxFloat, minFloat, flags) -> dest

Interleave four planes (alpha, red, green, blue) into a 4-channel image, rescaling each channel between minFloat and maxFloat (length-4 collections). Planar8ToARGBFFFF produces float output from 8-bit planes; PlanarFToARGB8888 produces 8-bit output from float planes. !-only.

source
AppleAccelerate.convert_Planar16Q12toARGB8888!Function
convert_Planar16Q12toARGB8888!(dest, alpha, red, green, blue) -> dest
convert_ARGB8888toPlanar16Q12!(alpha, red, green, blue, src) -> (alpha,red,green,blue)

Convert between 8-bit interleaved images and Planar16Q12 (signed Q4.12 fixed-point, where 4096 == 1.0) held as separate Int16 planes. !-only; the RGB888 variants omit the alpha plane.

source