extractChannel(at:destination:)
Extracts a single channel from an 32-bit-per-channel, 4-channel interleaved pixel buffer.
Declaration
func extractChannel(at channelIndex: Int, destination: vImage.PixelBuffer<vImage.PlanarF>)Parameters
- channelIndex:
The index of the channel that the function extracts.
- destination:
The destination pixel buffer.
Discussion
For example, the following code extracts channel `2` from a four-channel pixel buffer.
let src = vImage.PixelBuffer<vImage.InterleavedFx4>(
pixelValues: [0.10, 0.11, 0.12, 0.13,
0.20, 0.21, 0.22, 0.23,
0.30, 0.31, 0.32, 0.33],
size: vImage.Size(width: 1, height: 3))
let dest = vImage.PixelBuffer<vImage.PlanarF>(
size: src.size)
src.extractChannel(at: 2,
destination: dest)
// Prints "[0.12, 0.22, 0.32]"
print(dest.array)