<!--
{
  "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/MPSImageThresholdTruncate",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageThresholdTruncate"
  },
  "title" : "MPSImageThresholdTruncate"
}
-->

# MPSImageThresholdTruncate

A filter that clamps the return value to an upper specified value.

```
class MPSImageThresholdTruncate
```

## Overview

An [`MPSImageThresholdTruncate`](/documentation/MetalPerformanceShaders/MPSImageThresholdTruncate) 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 truncate function.

Listing 1. Threshold truncate function

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

## Topics

### Initializers

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

### Methods

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

Initializes the kernel.

### Properties

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

The threshold value used to initialize the threshold filter.

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

The color transform used to initialize the threshold filter.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

[`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)