<!--
{
  "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/generateScaledMask(for:scaledToImageFrom:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision23InstanceMaskObservationV014generateScaledC03for17scaledToImageFromSo11CVBufferRefa10Foundation8IndexSetV_AA0J14RequestHandlerCtKF"
  },
  "title" : "generateScaledMask(for:scaledToImageFrom:)"
}
-->

# generateScaledMask(for:scaledToImageFrom:)

Creates a high-resolution mask representing a combination of the instances you specify.

```
func generateScaledMask(for instances: IndexSet, scaledToImageFrom requestHandler: ImageRequestHandler) throws -> CVPixelBuffer
```

## Parameters

`instances`

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

`requestHandler`

A request handler containing an image to be masked.

## Return Value

The pixel buffer that contains the mask.

## Discussion

---

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)