sourceChannelCount
TypeScriptget sourceChannelCount(): numberSwift declarationlet sourceChannelCount: IntThe number of source channels.
struct · iOS 16.0+ · SDK 27.1
struct MultidimensionalLookupTableA multidimensional lookup table. Use a multidimensional lookup table to transform the colors in an image. The lookup table defines an output color based on the input color values. The vImage multidimensional lookup table provides interpolation to compute output color values that don't have an explicit entry in the table for a given input color. `MultidimensionalLookupTable` applies transforms to 32-bit planar pixel buffers. There are pixel buffer functions available to convert between bit depths and interleaved to planar buffers. The following is an example of a simple lookup table that implements the Rec. 709 luma coefficients to convert from a 3-channel RGB image to a single-channel grayscale image. The lookup table is a 3D cube with 32 entries per channel. ``` let entriesPerChannel = UInt8(32) let srcChannelCount = 3 let destChannelCount = 1 let lookupTableElementCount = Int(pow(Float(entriesPerChannel), Float(srcChannelCount))) * Int(destChannelCount) let tableData = [UInt16](unsafeUninitializedCapacity: lookupTableElementCount) { buffer, count in let multiplier = Float(UInt16.max) var bufferIndex = 0 for red in ( 0 ..< entriesPerChannel) { for green in ( 0 ..< entriesPerChannel) { for blue in ( 0 ..< entriesPerChannel) { let normalizedRed = Float(red) / Float(entriesPerChannel - 1) let normalizedGreen = Float(green) / Float(entriesPerChannel - 1) let normalizedBlue = Float(blue) / Float(entriesPerChannel - 1) let gray = (normalizedRed * 0.2126) + (normalizedGreen * 0.7152) + (normalizedBlue * 0.0722) buffer[ bufferIndex ] = UInt16(gray * multiplier) bufferIndex += 1 } } } count = lookupTableElementCount } ``` Use the lookup table data to create a `MultidimensionalLookupTable`. ``` let entryCountPerSourceChannel = [UInt8](repeating: entriesPerChannel, count: srcChannelCount) let lookupTable = vImage.MultidimensionalLookupTable( entryCountPerSourceChannel: entryCountPerSourceChannel, destinationChannelCount: destChannelCount, data: tableData) ``` Call the `apply` function to transform a 3-channel RGB image to a grayscale image. In this example, the source is interleaved. The code demonstrates calling `planarBuffers()` to deinterleave the source. ``` let src = vImage.PixelBuffer<vImage.InterleavedFx3>( ... ) let planarSources = src.planarBuffers() let dest = vImage.PixelBuffer<vImage.PlanarF>(size: src.size) lookupTable.apply(sources: planarSources, destinations: [dest], interpolation: .none) ``` On return, `dest` contains a grayscale representation of the soufce RGB image.
get sourceChannelCount(): numberSwift declarationlet sourceChannelCount: IntThe number of source channels.
get destinationChannelCount(): numberSwift declarationlet destinationChannelCount: IntThe number of destination channels.
static init(entryCountPerSourceChannel: Array<number>, destinationChannelCount: number, data: Array<number>): vImage_MultidimensionalLookupTableSwift declarationinit<T>(entryCountPerSourceChannel: [UInt8], destinationChannelCount: Int, data: T) where T : AccelerateBuffer, T.Element == UInt16Returns a new multidimensional lookup table. - Parameter entryCountPerSourceChannel: An array that contains the number of table entries for each dimension of the lookup table. - Parameter destinationChannelCount: The number of destination channels. - Parameter data: The lookup table data. The lookup table must contain the product of the values in `destinationChannelCount` multiplied by `destinationChannelCount`. - Precondition: `entryCountPerSourceChannel` must contain at least one item. - Precondition: The lookup table must contain the product of the values in `entryCountPerSourceChannel` multiplied by `destinationChannelCount`. - Precondition: `destinationChannelCount` must be greater than `0`. You supply the values in `data` in the range `0 ... 65535`, the function interprets the values as `0 ... 1` by dividing by `65535`. See [Applying Color Transforms to Images with a Multidimensional Lookup Table](https://developer.apple.com/documentation/accelerate/applying_color_transforms_to_images_with_a_multidimensional_lookup_table) for an example of how to create a multidimensional lookup table to convert RGB images to CMYK.
get entryCountPerSourceChannel(): Array<number>Swift declarationlet entryCountPerSourceChannel: [UInt8]An array that contains the number of table entries for each dimension of the lookup table.
apply(sources: Array<vImage_PixelBuffer<vImage_PlanarF>>, destinations: Array<vImage_PixelBuffer<vImage_PlanarF>>, interpolation: vImage_MultidimensionalLookupTable_InterpolationMethod): voidSwift declarationfunc apply(sources: [vImage.PixelBuffer<vImage.PlanarF>], destinations: [vImage.PixelBuffer<vImage.PlanarF>], interpolation: vImage.MultidimensionalLookupTable.InterpolationMethod)Transforms the image in `sources` using the multidimensional lookup table and writes the result to `destinations`. - Parameter sources: An array that contains `sourceChannelCount` `PlanarF` buffers. - Parameter destinations: An array that contains `destinationChannelCount` `PlanarF` buffers. - Precondition: `sources` must contain `sourceChannelCount` buffers. - Precondition: `destinations` must contain `destinationChannelCount` buffers.
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
vImage.MultidimensionalLookupTable.apply(source:destination:interpolation:)
This declaration needs Swift generic type arguments. (no canonical witness for SrcFormat)