<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSImage/init(texture:featureChannels:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImage(im)initWithTexture:featureChannels:"
  },
  "title" : "init(texture:featureChannels:)"
}
-->

# init(texture:featureChannels:)

Initializes an image from a texture. The user-allocated texture has been created for a specific number of feature channels and number of images.

```
convenience init(texture: any MTLTexture, featureChannels: Int)
```

## Parameters

`texture`

The texture allocated by the user to be used as a backing storage for the image.

`featureChannels`

The number of feature channels the texture contains.

## Return Value

A valid [`MPSImage`](/documentation/MetalPerformanceShaders/MPSImage) object or `nil`, if failure.

## Discussion

In a memory-intensive app, you can save memory (and allocation/deallocation time) by using an [`MPSTemporaryImage`](/documentation/MetalPerformanceShaders/MPSTemporaryImage) object, where the framework aggressively reuses underlying texture memory within the same command buffer. However, in certain cases, you may want more control on the allocation, placement, reuse, and recycling of memory-backing textures used in your app by using the Metal Resource Heaps API. In this case, an app can create an [`MPSImage`](/documentation/MetalPerformanceShaders/MPSImage) object from a pre-allocated texture by calling this method.

The <doc://com.apple.documentation/documentation/Metal/MTLTexture/textureType> property of the given texture can be of type <doc://com.apple.documentation/documentation/Metal/MTLTextureType/type2D> *only* if `featureChannels<=4` (meaning that `numberOfImages=1`). Otherwise, the texture type should be <doc://com.apple.documentation/documentation/Metal/MTLTextureType/type2DArray> with the <doc://com.apple.documentation/documentation/Metal/MTLTexture/arrayLength> property of the given texture being equal to `numberOfImages*((featureChannels+3)/4)`.

For textures containing typical image data, the `featureChannels` parameter should be set to the number of valid color channels (e.g. for RGB data, even though the pixel format is a form of `MTLPixelFormatRGBA`, `featureChannels` should be set to 3.).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)