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 kind | Julia array | vImage width | vImage height | rowBytes |
|---|---|---|---|---|
| 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 formfoo!(dest, src, …)writing into a caller-provideddest. Format conversions whose destination type differs from the source expose only the mutatingfoo!form (allocate the correctly-typeddestyourself). - Options are keyword arguments;
flagsaccepts thekvImage*flag constants (e.g.kvImageEdgeExtend,kvImageBackgroundColorFill,kvImageDoNotTile). - Every wrapper is GC-safe (
GC.@preserveroots all backing arrays across theccall) and checks the returnedvImage_Error, throwingvImageErroron 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 channelsTypes and helpers
AppleAccelerate.vImage_Buffer — Type
vImage_BufferMirror 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.
AppleAccelerate.vimage_buffer — Function
vimage_buffer(A) -> vImage_BufferBuild a vImage_Buffer descriptor that borrows the memory of Julia array A.
A::AbstractMatrixis 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.
AppleAccelerate.vImage_AffineTransform — Type
vImage_AffineTransformSingle-precision 3×2 affine transform (a b; c d; tx ty) used by affineWarp_* geometry functions. See also vImage_AffineTransform_Double.
AppleAccelerate.vImage_AffineTransform_Double — Type
vImage_AffineTransform_DoubleDouble-precision variant of vImage_AffineTransform, used by the affineWarpD_* functions.
AppleAccelerate.vImage_PerspectiveTransform — Type
vImage_PerspectiveTransformSingle-precision 3×3 projective transform used by perspectiveWarp_* functions.
AppleAccelerate.vImageError — Type
vImageError <: ExceptionThrown when a vImage function returns a negative vImage_Error. Carries the numeric code and the C function name fn; see vimage_error_string for the human-readable meaning.
AppleAccelerate.vimage_error_string — Function
vimage_error_string(code) -> StringHuman-readable description of a vImage error code (a negative vImage_Error).
Geometry
Resize, rotate, reflect, affine/perspective warp and shear. Available across the planar and interleaved 8-/16-/float formats.
AppleAccelerate.scale_Planar8 — Function
scale_Planar8(src, width, height; flags=kvImageNoFlags) -> Matrix
scale_ARGB8888(src, width, height; flags=kvImageNoFlags) -> ArrayResample 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.
AppleAccelerate.horizontalReflect_Planar8 — Function
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.
AppleAccelerate.rotate90_Planar8 — Function
rotate90_Planar8(src, rotationConstant; backColor, flags) -> arrayRotate 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.
AppleAccelerate.rotate_Planar8 — Function
rotate_Planar8(src, angleInRadians; backColor, flags) -> arrayRotate 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.
AppleAccelerate.affineWarp_Planar8 — Function
affineWarp_Planar8(src, transform::vImage_AffineTransform; backColor, flags) -> array
affineWarpD_ARGB8888(src, transform::vImage_AffineTransform_Double; ...) -> arrayApply 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.
AppleAccelerate.affineWarpCG_ARGB8888 — Function
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.
AppleAccelerate.perspectiveWarp_Planar8 — Function
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.
AppleAccelerate.horizontalShear_Planar8 — Function
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.
Convolution
General, separable, box and tent convolution with integer or float kernels.
AppleAccelerate.convolve_Planar8 — Function
convolve_Planar8(src, kernel::Matrix{<:Integer}; divisor=1, backColor, flags) -> array
convolve_ARGBFFFF(src, kernel::Matrix{<:Real}; backColor, flags) -> arrayGeneral 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.
AppleAccelerate.convolveWithBias_Planar8 — Function
convolveWithBias_Planar8(src, kernel; divisor=1, bias=0, backColor, flags) -> arrayLike convolve_Planar8 but adds bias to the (divided) accumulator before storing. Allocating and ! variants for Planar8, ARGB8888, PlanarF, Planar16F, ARGBFFFF, ARGB16F.
AppleAccelerate.sepConvolve_PlanarF — Function
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.
AppleAccelerate.boxConvolve_Planar8 — Function
boxConvolve_Planar8(src, kernelHeight, kernelWidth; backColor, flags) -> array
tentConvolve_ARGB8888(src, kernelHeight, kernelWidth; backColor, flags) -> arrayFast 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.
Morphology
Grayscale dilation/erosion with an arbitrary structuring element, and fast rectangular max/min filters.
AppleAccelerate.dilate_Planar8 — Function
dilate_Planar8(src, kernel::Matrix{UInt8}; flags) -> array
erode_ARGB8888(src, kernel::Matrix{UInt8}; flags) -> arrayGrayscale morphological dilation / erosion with an arbitrary kernel (structuring element). kernel size is (kernel_height, kernel_width). Allocating and ! variants. Formats Planar8/F, ARGB8888/FFFF.
AppleAccelerate.max_Planar8 — Function
max_Planar8(src, kernelHeight, kernelWidth; flags) -> array
min_ARGB8888(src, kernelHeight, kernelWidth; flags) -> arrayRectangular maximum / minimum filter (dilation / erosion by a solid kernelHeight × kernelWidth rectangle). Allocating and ! variants; formats Planar8/F, ARGB8888/FFFF.
Histogram
AppleAccelerate.histogramCalculation_Planar8 — Function
histogramCalculation_Planar8(src) -> Vector{Int} # length 256Compute the 256-bin histogram of an 8-bit planar image.
AppleAccelerate.histogramCalculation_PlanarF — Function
histogramCalculation_PlanarF(src, entries, minVal, maxVal) -> Vector{Int}Compute an entries-bin histogram of a float planar image over [minVal, maxVal].
AppleAccelerate.histogramCalculation_ARGB8888 — Function
histogramCalculation_ARGB8888(src) -> Matrix{Int} # 256 × 4 (columns A,R,G,B)Compute per-channel 256-bin histograms of an 8-bit interleaved 4-channel image.
AppleAccelerate.histogramCalculation_ARGBFFFF — Function
histogramCalculation_ARGBFFFF(src, entries, minVal, maxVal) -> Matrix{Int} # entries × 4Per-channel histograms of a float interleaved 4-channel image over [minVal, maxVal].
AppleAccelerate.equalization_Planar8 — Function
equalization_Planar8(src; flags) -> array
contrastStretch_ARGBFFFF(src; entries=4096, minVal=0, maxVal=1, flags) -> arrayHistogram 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.
AppleAccelerate.endsInContrastStretch_Planar8 — Function
endsInContrastStretch_Planar8(src; percentLow=0, percentHigh=0, flags) -> arrayEnds-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.
AppleAccelerate.endsInContrastStretch_ARGB8888 — Function
endsInContrastStretch_ARGB8888(src; percentLow, percentHigh, flags) -> arrayPer-channel ends-in contrast stretch of an ARGB8888 image; percentLow/percentHigh are length-4 collections. Allocating and ! variants.
AppleAccelerate.histogramSpecification_Planar8 — Function
histogramSpecification_Planar8(src, desiredHistogram; flags) -> arrayRemap an 8-bit planar image so its histogram matches desiredHistogram (256 entries). Allocating and ! variants.
Alpha & compositing
Premultiply / un-premultiply, source-over and named blend modes, and planar alpha blending.
AppleAccelerate.premultiplyData_ARGB8888 — Function
premultiplyData_ARGB8888(src; flags) -> array
unpremultiplyData_ARGBFFFF(src; flags) -> array
premultiplyData_Planar8(src, alpha; flags) -> arrayPremultiply / 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.
AppleAccelerate.clipToAlpha_ARGB8888 — Function
clipToAlpha_ARGB8888(src; flags) -> arrayClamp 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).
AppleAccelerate.premultipliedAlphaBlend_ARGB8888 — Function
premultipliedAlphaBlend_ARGB8888(srcTop, srcBottom; flags) -> arrayComposite 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.
AppleAccelerate.alphaBlend_Planar8 — Function
alphaBlend_Planar8(srcTop, srcTopAlpha, srcBottom, srcBottomAlpha, alpha; flags) -> arrayNon-premultiplied planar alpha blend of two images given their alpha planes and an overall blend alpha plane. Allocating and ! variants.
Colour transforms
Colour-matrix multiply, piecewise gamma, lookup tables and flood fill.
AppleAccelerate.matrixMultiply_ARGB8888 — Function
matrixMultiply_ARGB8888(src, matrix::Matrix{<:Integer}; divisor=256, preBias, postBias, flags) -> arrayApply 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.
AppleAccelerate.matrixMultiply_ARGBFFFF — Function
matrixMultiply_ARGBFFFF(src, matrix::Matrix{<:Real}; preBias, postBias, flags) -> arrayFloating-point 4×4 colour-matrix multiply of an ARGBFFFF image. Allocating and ! variants.
AppleAccelerate.matrixMultiply_ARGB8888ToPlanar8! — Function
matrixMultiply_ARGB8888ToPlanar8!(dest, src, matrix; divisor=256, preBias, postBias, flags) -> destReduce 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.
AppleAccelerate.piecewiseGamma_PlanarF — Function
piecewiseGamma_PlanarF(src; exponentialCoeffs, gamma, linearCoeffs, boundary, flags) -> arrayApply 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.
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!.
AppleAccelerate.lookupTable_Planar8toPlanarF! — Function
lookupTable_Planar8toPlanarF(dest, src, table) -> destMap each 8-bit source pixel through a 256-entry table. Mutating variants for Planar8toPlanar16 (UInt16 table/output) and Planar8toPlanarF (Float32).
AppleAccelerate.lookupTable_Planar16! — Function
lookupTable_Planar16!(dest, src, table) -> destAdditional 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).
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
- Variants for
Planar8,Planar16U,ARGB8888,ARGB16U(interleaved take a
length-4 newValue).
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_ARGB8888 — Function
permuteChannels_ARGB8888(src, permuteMap; flags) -> arrayReorder 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.
AppleAccelerate.permuteChannelsWithMaskedInsert_ARGB8888 — Function
permuteChannelsWithMaskedInsert_ARGB8888(src, permuteMap, copyMask; backgroundColor, flags) -> arrayPermute channels per permuteMap, but for channels selected by copyMask insert the constant backgroundColor instead. Formats ARGB8888/16U/FFFF.
AppleAccelerate.extractChannel_ARGB8888 — Function
extractChannel_ARGB8888(src, channelIndex; flags) -> MatrixExtract one channel (0-based channelIndex) of an interleaved image into a planar buffer. Allocating and ! variants for ARGB8888, ARGB16U, ARGBFFFF.
AppleAccelerate.bufferFill_ARGB8888! — Function
bufferFill_ARGB8888!(dest, color; flags) -> destFill every pixel of interleaved dest with the constant color (a length-channels collection). Variants for ARGB8888/16U/16S/FFFF and CbCr8/16U/16S.
AppleAccelerate.overwriteChannels_ARGB8888 — Function
overwriteChannels_ARGB8888(newSrc, origSrc, copyMask; flags) -> array
selectChannels_ARGBFFFF(newSrc, origSrc, copyMask; flags) -> arrayCopy the channels selected by the bitmask copyMask from newSrc, and the rest from origSrc, into the destination. Formats ARGB8888, ARGBFFFF.
AppleAccelerate.overwriteChannelsWithPixel_ARGB8888 — Function
overwriteChannelsWithPixel_ARGB8888(src, pixel, copyMask; flags) -> arrayReplace the channels selected by copyMask with the constant value from pixel (length-4), copying the rest from src. Formats ARGB8888/16U/FFFF.
AppleAccelerate.overwriteChannelsWithScalar_Planar8! — Function
overwriteChannelsWithScalar_Planar8!(dest, scalar; flags) -> destOverwrite an entire planar buffer with a constant scalar. Variants for Planar8/F/16S/16U/16F.
AppleAccelerate.tableLookUp_Planar8 — Function
tableLookUp_Planar8(src, table) -> MatrixMap each 8-bit pixel through a 256-entry table. Allocating and ! variants.
AppleAccelerate.tableLookUp_ARGB8888 — Function
tableLookUp_ARGB8888(src, alphaTable, redTable, greenTable, blueTable; flags) -> arrayIndependently remap each channel of an ARGB8888 image through its own 256-entry table. Allocating and ! variants.
AppleAccelerate.flatten_ARGB8888ToRGB888! — Function
flatten_ARGB8888ToRGB888!(dest, src, backgroundColor; isImagePremultiplied=true, flags) -> destComposite 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.
AppleAccelerate.flatten_ARGB8888 — Function
flatten_ARGB8888(src, backgroundColor; isImagePremultiplied=true, flags) -> arrayComposite 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.
AppleAccelerate.copyBuffer! — Function
copyBuffer!(dest, src; pixelSize, flags) -> destCopy src to dest accounting for rowBytes padding. pixelSize is the size of one pixel in bytes.
AppleAccelerate.convert_ARGB8888toPlanar8 — Function
convert_ARGB8888toPlanar8(src, destA, destR, destG, destB) -> (destA,destR,destG,destB)
convert_Planar8toARGB8888(dest, srcA, srcR, srcG, srcB) -> destDeinterleave 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.
AppleAccelerate.convert_Planar8toRGB888 — Function
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.
AppleAccelerate.convert_ARGB8888toPlanarF — Function
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).
AppleAccelerate.convert_16UToPlanar8! — Function
convert_16UToPlanar8!(dest, src; flags) -> dest
convert_ARGB8888toRGB888!(dest, src; flags) -> destFormat / 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.
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) -> destPlanar 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}.
AppleAccelerate.convert_16UToF! — Function
convert_16UToF!(dest, src; offset=0, scale=1, flags) -> destInteger ↔ float planar conversions with an affine map out = (in - offset)/scale (or its inverse). Mutating variants for 16SToF, 16UToF, FTo16S, FTo16U.
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.
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!.
AppleAccelerate.convert_ARGB8888ToARGB2101010! — Function
convert_ARGB8888ToARGB2101010!(dest, src; rangeMin=0, rangeMax=1023, permuteMap=(0,1,2,3), flags) -> destConversions 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.
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.
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_YpCbCrToARGBMatrix — Type
vImage_YpCbCrToARGBMatrix(Yp, Cr_R, Cr_G, Cb_G, Cb_B)Sparse 3×3 Y'CbCr→RGB conversion matrix (5 non-trivial Float32 coefficients). Feed to convert_YpCbCrToARGB_GenerateConversion. The standard ITU matrices are available as kvImage_YpCbCrToARGBMatrix_ITU_R_601_4 and …_709_2.
AppleAccelerate.vImage_ARGBToYpCbCrMatrix — Type
vImage_ARGBToYpCbCrMatrix(R_Yp, G_Yp, B_Yp, R_Cb, G_Cb, B_Cb_R_Cr, G_Cr, B_Cr)3×3 RGB→Y'CbCr conversion matrix (8 Float32 coefficients). Inverse of vImage_YpCbCrToARGBMatrix. Standard matrices: kvImage_ARGBToYpCbCrMatrix_ITU_R_601_4 and …_709_2.
AppleAccelerate.vImage_YpCbCrPixelRange — Type
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.
AppleAccelerate.vImage_YpCbCrToARGB — Type
vImage_YpCbCrToARGBOpaque 128-byte (16-byte-aligned) info blob produced by convert_YpCbCrToARGB_GenerateConversion and consumed by the convert_*ToARGB* Y'CbCr routines.
AppleAccelerate.vImage_ARGBToYpCbCr — Type
vImage_ARGBToYpCbCrOpaque 128-byte info blob produced by convert_ARGBToYpCbCr_GenerateConversion and consumed by the convert_ARGB*To444* Y'CbCr routines.
AppleAccelerate.kvImage_YpCbCrToARGBMatrix_ITU_R_601_4 — Constant
kvImage_YpCbCrToARGBMatrix_ITU_R_601_4 :: vImage_YpCbCrToARGBMatrixITU-R BT.601-4 Y'CbCr→RGB conversion matrix (standard-definition video). …_709_2 is the BT.709-2 (high-definition) variant.
AppleAccelerate.kvImage_ARGBToYpCbCrMatrix_ITU_R_601_4 — Constant
kvImage_ARGBToYpCbCrMatrix_ITU_R_601_4 :: vImage_ARGBToYpCbCrMatrixITU-R BT.601-4 RGB→Y'CbCr conversion matrix. …_709_2 is the BT.709-2 variant.
AppleAccelerate.convert_YpCbCrToARGB_GenerateConversion — Function
convert_YpCbCrToARGB_GenerateConversion(matrix, pixelRange, ypCbCrType, argbType; flags) -> vImage_YpCbCrToARGBBake 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.
AppleAccelerate.convert_ARGBToYpCbCr_GenerateConversion — Function
convert_ARGBToYpCbCr_GenerateConversion(matrix, pixelRange, argbType, ypCbCrType; flags) -> vImage_ARGBToYpCbCrBake a matrix::vImage_ARGBToYpCbCrMatrix + pixelRange and the input argbType / output ypCbCrType format codes into a reusable vImage_ARGBToYpCbCr info blob for the convert_ARGB*To444* routines.
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.
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) -> destConvolve 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.
AppleAccelerate.convolveMultiKernel_ARGBFFFF! — Function
convolveMultiKernel_ARGBFFFF!(dest, src, kernels; biases, backgroundColor,
srcOffsetX=0, srcOffsetY=0, flags=kvImageEdgeExtend) -> destFloat 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.
AppleAccelerate.convolveFloatKernel_ARGB8888! — Function
convolveFloatKernel_ARGB8888!(dest, src, kernel; bias=0, backColor=(0,0,0,0),
srcOffsetX=0, srcOffsetY=0, flags) -> destConvolve an ARGB8888 image with a single floating-point kernel (higher precision than the integer-kernel convolve_Planar8). kernel is (kernelHeight, kernelWidth). Allocating and ! variants.
Multi-plane matrix multiply
Multiply M source planes by an M×N matrix to produce N destination planes.
AppleAccelerate.matrixMultiply_Planar8 — Function
matrixMultiply_Planar8(srcs, dests, matrix; divisor=1, preBias, postBias, flags) -> dests
matrixMultiply_PlanarF(srcs, dests, matrix; preBias, postBias, flags) -> destsMultiply 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.
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_Planar8 — Function
premultipliedAlphaBlend_Planar8(srcTop, srcTopAlpha, srcBottom; flags) -> plane
premultipliedConstAlphaBlend_ARGB8888(srcTop, constAlpha, srcBottom; flags) -> arrayAdditional 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.
AppleAccelerate.alphaBlend_PlanarF — Function
alphaBlend_PlanarF(srcTop, srcTopAlpha, srcBottom, srcBottomAlpha, alpha; flags) -> planeFloat non-premultiplied planar alpha blend (float analogue of alphaBlend_Planar8). Allocating and ! variants.
AppleAccelerate.premultipliedAlphaBlendWithPermute_ARGB8888 — Function
premultipliedAlphaBlendWithPermute_ARGB8888(srcTop, srcBottom; permuteMap=(0,1,2,3),
makeDestAlphaOpaque=false, flags) -> arraySource-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.
AppleAccelerate.histogramSpecification_PlanarF — Function
histogramSpecification_PlanarF(src, desiredHistogram; entries, minVal=0, maxVal=1, flags) -> plane
histogramSpecification_ARGB8888(src, desiredHistogram; flags) -> arrayRemap 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.
AppleAccelerate.endsInContrastStretch_PlanarF — Function
endsInContrastStretch_PlanarF(src; percentLow=0, percentHigh=0, entries=4096, minVal, maxVal, flags) -> planeFloat 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.
AppleAccelerate.convert_XRGB8888ToPlanar8 — Function
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).
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) -> destInterleave 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.
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.