<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSImageThresholdToZero",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageThresholdToZero"
  },
  "title" : "MPSImageThresholdToZero"
}
-->

# MPSImageThresholdToZero

A filter that returns the original value for each pixel with a value greater than a specified threshold or 0 otherwise.

```
class MPSImageThresholdToZero
```

## Overview

An [`MPSImageThresholdToZero`](/documentation/MetalPerformanceShaders/MPSImageThresholdToZero) filter converts a single channel image to a binary image. If the input image is not a single channel image, the function first converts the input image into a single channel luminance image using the linear gray color transform, and then it applies the threshold.

The following listing shows the threshold to zero function.

Listing 1. Threshold to zero function

```other
destinationPixelValue = sourcePixelValue > thresholdValue ? sourcePixelValue : 0
```

## Topics

### Initializers

[`-  initWithCoder:device:`](/documentation/MetalPerformanceShaders/MPSImageThresholdToZero/init(coder:device:))

### Methods

[`-  initWithDevice:thresholdValue:linearGrayColorTransform:`](/documentation/MetalPerformanceShaders/MPSImageThresholdToZero/init(device:thresholdValue:linearGrayColorTransform:))

Initializes the kernel.

### Properties

[`thresholdValue`](/documentation/MetalPerformanceShaders/MPSImageThresholdToZero/thresholdValue)

The threshold value used to initialize the threshold filter.

[`transform`](/documentation/MetalPerformanceShaders/MPSImageThresholdToZero/transform)

The color transform used to initialize the threshold filter.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

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

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

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSCoding`](/documentation/Foundation/NSCoding)

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

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

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

### Inherits From

[`MPSUnaryImageKernel`](/documentation/MetalPerformanceShaders/MPSUnaryImageKernel)

---

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)