---
title: MPSImageCopyToMatrix
framework: metalperformanceshaders
role: symbol
role_heading: Class
path: metalperformanceshaders/mpsimagecopytomatrix
---

# MPSImageCopyToMatrix

A class that copies image data to a matrix.

## Declaration

```swift
class MPSImageCopyToMatrix
```

## Overview

Overview This kernel copies image data to a MPSMatrix object. The image data is stored in a row of a matrix.  The dataLayout specifies the order in which the feature channels in the image get stored in the matrix.  If the MPSImage stores a batch of images, the images are copied into multiple rows, one row per image. The number of elements in a row in the matrix must be greater than the image width multiplied its height multiplied by the number of featureChannels in the image.

## Topics

### Initializers

- [init(coder:device:)](metalperformanceshaders/mpsimagecopytomatrix/init(coder:device:).md)
- [init(device:dataLayout:)](metalperformanceshaders/mpsimagecopytomatrix/init(device:datalayout:).md)

### Instance Properties

- [dataLayout](metalperformanceshaders/mpsimagecopytomatrix/datalayout.md)
- [destinationMatrixBatchIndex](metalperformanceshaders/mpsimagecopytomatrix/destinationmatrixbatchindex.md)
- [destinationMatrixOrigin](metalperformanceshaders/mpsimagecopytomatrix/destinationmatrixorigin.md)

### Instance Methods

- [encode(commandBuffer:sourceImage:destinationMatrix:)](metalperformanceshaders/mpsimagecopytomatrix/encode(commandbuffer:sourceimage:destinationmatrix:).md)
- [encodeBatch(commandBuffer:sourceImages:destinationMatrix:)](metalperformanceshaders/mpsimagecopytomatrix/encodebatch(commandbuffer:sourceimages:destinationmatrix:).md)

## Relationships

### Inherits From

- [MPSKernel](metalperformanceshaders/mpskernel.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Matrix Copying Operations

- [MPSMatrixCopy](metalperformanceshaders/mpsmatrixcopy.md)
- [MPSMatrixCopyToImage](metalperformanceshaders/mpsmatrixcopytoimage.md)
- [MPSMatrixCopyDescriptor](metalperformanceshaders/mpsmatrixcopydescriptor.md)
