<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision23InstanceMaskObservationV"
  },
  "title" : "InstanceMaskObservation"
}
-->

# InstanceMaskObservation

An observation that contains an instance mask that labels instances in the mask.

```
struct InstanceMaskObservation
```

## Topics

### Creating an observation

[`init?(VNInstanceMaskObservation)`](/documentation/Vision/InstanceMaskObservation/init(_:))

Creates an instance mask observation.

### Inspecting an observation

[`enum RequestDescriptor`](/documentation/Vision/RequestDescriptor)

A type that describes the request and revision combination.

### Generating a mask

[`func generateMask(for: IndexSet) throws -> CVPixelBuffer`](/documentation/Vision/InstanceMaskObservation/generateMask(for:))

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

[`func generateMaskedImage(for: IndexSet, imageFrom: ImageRequestHandler, croppedToInstancesExtent: Bool) throws -> CVPixelBuffer`](/documentation/Vision/InstanceMaskObservation/generateMaskedImage(for:imageFrom:croppedToInstancesExtent:))

Creates a high-resolution image with everything except for the instances you specify masked out.

[`func generateScaledMask(for: IndexSet, scaledToImageFrom: ImageRequestHandler) throws -> CVPixelBuffer`](/documentation/Vision/InstanceMaskObservation/generateScaledMask(for:scaledToImageFrom:))

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

### Getting instances

[`func instanceAtPoint(NormalizedPoint) -> IndexSet`](/documentation/Vision/InstanceMaskObservation/instanceAtPoint(_:))

Returns an instance at the point you specify.

[`let allInstances: IndexSet`](/documentation/Vision/InstanceMaskObservation/allInstances)

The collection that contains all instances, excluding the background.

[`let allInstancesMask: PixelBufferObservation`](/documentation/Vision/InstanceMaskObservation/allInstancesMask)

The resulting mask that represents all instances.

[`struct PixelBufferObservation`](/documentation/Vision/PixelBufferObservation)

An object that represents an image that an image-analysis request produces.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Escapable`](/documentation/Swift/Escapable)

[`Hashable`](/documentation/Swift/Hashable)

[`Copyable`](/documentation/Swift/Copyable)

[`Encodable`](/documentation/Swift/Encodable)

[`Decodable`](/documentation/Swift/Decodable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`VisionObservation`](/documentation/Vision/VisionObservation)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)