---
title: "vImageExtractChannel_ARGB16U(_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimageextractchannel_argb16u(_:_:_:_:)"
---

# vImageExtractChannel_ARGB16U(_:_:_:_:)

Extracts a single channel from an unsigned 16-bit-per-channel, 4-channel interleaved buffer and writes the result to an unsigned 16-bit planar buffer.

## Declaration

```swift
func vImageExtractChannel_ARGB16U(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ channelIndex: Int, _ flags: vImage_Flags) -> vImage_Error
```

## Parameters

- `src`: The source vImage buffer.
- `dest`: A pointer to the destination vImage buffer structure. You’re responsible for filling out the doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/height, doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/width, and doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer/rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, deallocate the memory to prevent memory leaks.
- `channelIndex`: The index of the channel that the function extracts.
- `flags`: The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile; otherwise, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageNoFlags.

## Return Value

Return Value kvImageNoError; otherwise, one of the error codes in Data Types and Constants.

## Discussion

Discussion The following code extracts channel 1 from the source buffer and writes the result to the destination buffer: let source = vImage.PixelBuffer<vImage.Interleaved16Ux4>(     pixelValues: [10, 20, 30, 40,                   50, 60, 70, 80],     size: .init(width: 1, height: 2))

let destination = vImage.PixelBuffer<vImage.Planar16U>(     size: source.size )

source.withUnsafePointerToVImageBuffer { src in     destination.withUnsafePointerToVImageBuffer { dst in         _ = vImageExtractChannel_ARGB16U(src,                                           dst,                                           1,                                           vImage_Flags(kvImageNoFlags))     } }

// Prints: //      "[20, //        60]" print(destination.array)

## See Also

### Extracting channels

- [vImageExtractChannel_ARGB8888(_:_:_:_:)](accelerate/vimageextractchannel_argb8888(_:_:_:_:).md)
- [vImageExtractChannel_ARGBFFFF(_:_:_:_:)](accelerate/vimageextractchannel_argbffff(_:_:_:_:).md)
