---
title: vImage.PixelBuffer
framework: accelerate
role: symbol
role_heading: Structure
path: accelerate/vimage/pixelbuffer
---

# vImage.PixelBuffer

An image buffer that stores an image’s pixel data, dimensions, bit depth, and number of channels.

## Declaration

```swift
struct PixelBuffer<Format> where Format : PixelFormat
```

## Mentioned in

Enhancing image contrast with histogram manipulation Applying vImage operations to regions of interest Building a basic image conversion workflow Applying color transforms to images with a multidimensional lookup table Converting bitmap data between Core Graphics images and vImage buffers Converting chroma-subsampled images Optimizing image-processing performance

## Overview

Overview Use a vImage.PixelBuffer to represent an image from a CGImage instance, a CVPixelBuffer structure, or a collection of raw pixel values. Pixel buffers are typed by their bits per channel and number of channels. For example, vImage.Interleaved8x4 indicates a 4-channel, 8-bit-per-channel pixel buffer that contains image data such as RGBA or CMYK. Pixel buffers expose methods that are available for the buffer’s pixel format. For example, the fast box convolution functions are only available for one- and four-channel 8-bit per channel buffers:  let src = vImage.PixelBuffer<vImage.Interleaved8x4>(cgImage: cgImage,                                                      cgImageFormat: &cgImageFormat)  let dest = vImage.PixelBuffer<vImage.Interleaved8x4>(src.size)

src.boxConvolve(kernelSize: vImage.Size(width: 64, height: 64),                  edgeMode: .truncateKernel,                  destination: dest) Typed pixel buffers provide a simple API to convert between pixel formats. For example, the following code converts 8-bit unsigned integer pixels to 32-bit floating point pixels:  let src = vImage.PixelBuffer<vImage.Interleaved8x4>(cgImage: cgImage,                                                      cgImageFormat: &cgImageFormat)  let dest = vImage.PixelBuffer<vImage.InterleavedFx4>(size: src.size)

src.convert(to: dest) vImage pixel buffers manage their memory, therefore, you don’t need to call deallocate() when you’re finished with the buffer.

## Topics

### Pixel buffer essentials

- [Creating vImage pixel buffers](accelerate/creating-vimage-pixel-buffers.md)
- [Pixel formats](accelerate/pixel-formats.md)
- [Working with underlying data](accelerate/working-with-underlying-data.md)

### Inspecting a pixel buffer

- [width](accelerate/vimage/pixelbuffer/width.md)
- [height](accelerate/vimage/pixelbuffer/height.md)
- [size](accelerate/vimage/pixelbuffer/size.md)
- [channelCount](accelerate/vimage/pixelbuffer/channelcount.md)
- [rowStride](accelerate/vimage/pixelbuffer/rowstride.md)
- [byteCountPerPixel](accelerate/vimage/pixelbuffer/bytecountperpixel.md)
- [count](accelerate/vimage/pixelbuffer/count.md)
- [array](accelerate/vimage/pixelbuffer/array.md)

### Pixel buffer methods

- [copy(to:)](accelerate/vimage/pixelbuffer/copy(to:).md)
- [copy(to:cvImageFormat:cgImageFormat:)](accelerate/vimage/pixelbuffer/copy(to:cvimageformat:cgimageformat:).md)
- [makeCGImage(cgImageFormat:)](accelerate/vimage/pixelbuffer/makecgimage(cgimageformat:).md)
- [withCVPixelBuffer(readOnly:body:)](accelerate/vimage/pixelbuffer/withcvpixelbuffer(readonly:body:).md)

### Pixel buffer operations

- [Applying geometric operations to pixel buffers](accelerate/applying-geometric-operations-to-pixel-buffers.md)
- [Applying color transforms to pixel buffers](accelerate/applying-color-transforms-to-pixel-buffers.md)
- [Blending and compositing pixel buffers](accelerate/blending-and-compositing-pixel-buffers.md)
- [Convolving and applying morphology](accelerate/convolving-and-applying-morphology.md)
- [Thresholding and clipping pixel buffer values](accelerate/thresholding-and-clipping-pixel-buffer-values.md)
- [Calculating and transforming histograms](accelerate/calculating-and-transforming-histograms.md)
- [Converting pixel buffers](accelerate/converting-pixel-buffers.md)
- [Interleaving and deinterleaving pixel buffers](accelerate/interleaving-and-deinterleaving-pixel-buffers.md)
- [Cropping and working with regions of interest](accelerate/cropping-and-working-with-regions-of-interest.md)
- [Applying channel operations](accelerate/applying-channel-operations.md)
- [Applying arithmetic operations](accelerate/applying-arithmetic-operations.md)

### Instance Properties

- [bytesPerRow](accelerate/vimage/pixelbuffer/bytesperrow.md)

### Instance Methods

- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-3yi7i.md)
- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-6498m.md)
- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-715aw.md)
- [applyMorphology(operation:destination:)](accelerate/vimage/pixelbuffer/applymorphology(operation:destination:)-1aqer.md)
- [applyMorphology(operation:destination:)](accelerate/vimage/pixelbuffer/applymorphology(operation:destination:)-5al25.md)
- [convolve(with:bias:edgeMode:destination:)](accelerate/vimage/pixelbuffer/convolve(with:bias:edgemode:destination:)-7no5n.md)
- [separableConvolve(horizontalKernel:verticalKernel:bias:edgeMode:destination:)](accelerate/vimage/pixelbuffer/separableconvolve(horizontalkernel:verticalkernel:bias:edgemode:destination:)-15dhm.md)
- [withBNNSTensor(_:)](accelerate/vimage/pixelbuffer/withbnnstensor(_:).md)

### Default Implementations

- [AccelerateBuffer Implementations](accelerate/vimage/pixelbuffer/acceleratebuffer-implementations.md)
- [AccelerateMatrixBuffer Implementations](accelerate/vimage/pixelbuffer/acceleratematrixbuffer-implementations.md)
- [AccelerateMutableMatrixBuffer Implementations](accelerate/vimage/pixelbuffer/acceleratemutablematrixbuffer-implementations.md)

## Relationships

### Conforms To

- [AccelerateBuffer](accelerate/acceleratebuffer.md)
- [AccelerateMatrixBuffer](accelerate/acceleratematrixbuffer.md)
- [AccelerateMutableBuffer](accelerate/acceleratemutablebuffer.md)
- [AccelerateMutableMatrixBuffer](accelerate/acceleratemutablematrixbuffer.md)
- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)

## See Also

### vImage Pixel Buffers

- [Using vImage pixel buffers to generate video effects](accelerate/using-vimage-pixel-buffers-to-generate-video-effects.md)
- [Applying tone curve adjustments to images](accelerate/applying-tone-curve-adjustments-to-images.md)
- [Adjusting the brightness and contrast of an image](accelerate/adjusting-the-brightness-and-contrast-of-an-image.md)
- [Adjusting the hue of an image](accelerate/adjusting-the-hue-of-an-image.md)
- [Sharing texture data between the Model I/O framework and the vImage library](accelerate/sharing-texture-data-between-the-model-io-framework-and-the-vimage-library.md)
- [Calculating the dominant colors in an image](accelerate/calculating-the-dominant-colors-in-an-image.md)
