<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/VNInstanceMaskObservation/generateScaledMaskForImage(forInstances:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "c:objc(cs)VNInstanceMaskObservation(im)generateScaledMaskForImageForInstances:fromRequestHandler:error:"
  },
  "title" : "generateScaledMaskForImage(forInstances:from:)"
}
-->

# generateScaledMaskForImage(forInstances:from:)

Creates a high-resolution mask where everything becomes transparent black, except for the instances you specify.

```
func generateScaledMaskForImage(forInstances instances: IndexSet, from requestHandler: VNImageRequestHandler) throws -> CVPixelBuffer
```

## Parameters

`instances`

The collection of instances.

`requestHandler`

The image request callback.

## Return Value

The pixel buffer that contains the image.

## 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)