---
title: "generateScaledMaskForImage(forInstances:from:)"
framework: vision
role: symbol
role_heading: Instance Method
path: "vision/vninstancemaskobservation/generatescaledmaskforimage(forinstances:from:)"
---

# generateScaledMaskForImage(forInstances:from:)

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

## Declaration

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

## Parameters

- `instances`: The collection of instances.
- `requestHandler`: The image request callback.

## Return Value

Return Value The pixel buffer that contains the image.

## See Also

### Creating a Mask

- [generateMask(forInstances:)](vision/vninstancemaskobservation/generatemask(forinstances:).md)
- [generateMaskedImage(ofInstances:from:croppedToInstancesExtent:)](vision/vninstancemaskobservation/generatemaskedimage(ofinstances:from:croppedtoinstancesextent:).md)
