<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/InstanceMaskObservation/generateMask(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision23InstanceMaskObservationV08generateC03forSo11CVBufferRefa10Foundation8IndexSetV_tKF"
  },
  "title" : "generateMask(for:)"
}
-->

# generateMask(for:)

Creates a low-resolution mask from the instances you specify.

```
func generateMask(for instances: IndexSet) throws -> CVPixelBuffer
```

## Parameters

`instances`

An indexed set of selected instances, where `0` is the background.

## Return Value

The pixel buffer that contains the mask.

---

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)