---
title: MPSCNNLocalContrastNormalization
framework: metalperformanceshaders
role: symbol
role_heading: Class
path: metalperformanceshaders/mpscnnlocalcontrastnormalization
---

# MPSCNNLocalContrastNormalization

A local-contrast normalization kernel.

## Declaration

```swift
class MPSCNNLocalContrastNormalization
```

## Overview

Overview The local contrast normalization kernel is quite similar to the spatial normalization kernel, described in the MPSCNNSpatialNormalization class, in that it applies the kernel over local regions which extend spatially, but are in separate feature channels (i.e., they have the shape 1 x kernel width x kernel height). However, instead of dividing by the local “energy” of the feature, the denominator uses the local variance of the feature - effectively the mean value of the feature is subtracted from the signal. For each feature channel, the function computes the variance VAR(i,j) and mean M(i,j) of X(i,j) inside each rectangle around the spatial point (i,j). Then the result is computed for each element of X as follows:

Where kw and kh are the values of the kernelWidth and the kernelHeight properties, respectively, and the values of the pm, ps, and p0 properties can be used to offset and scale the result in various ways. For example setting pm=0, ps=1, p0=1, delta=0, alpha=1.0 and beta=0.5 scales input data so that the result has unit variance and zero mean, provided that input variance is positive. It is your responsibility to ensure that the combination of the values of the delta and alpha properties does not result in a situation where the denominator becomes zero - in such situations the resulting pixel-value is undefined. A good way to guard against tiny variances is to regulate the expression with a small delta value, for example delta=1/1024. tip: The encoding methods in the MPSUnaryImageKernel class can be used to encode an MPSCNNLocalContrastNormalization object to a MTLCommandBuffer object.

## Topics

### Initializers

- [init(coder:device:)](metalperformanceshaders/mpscnnlocalcontrastnormalization/init(coder:device:).md)
- [init(device:kernelWidth:kernelHeight:)](metalperformanceshaders/mpscnnlocalcontrastnormalization/init(device:kernelwidth:kernelheight:).md)

### Instance Properties

- [alpha](metalperformanceshaders/mpscnnlocalcontrastnormalization/alpha.md)
- [beta](metalperformanceshaders/mpscnnlocalcontrastnormalization/beta.md)
- [delta](metalperformanceshaders/mpscnnlocalcontrastnormalization/delta.md)
- [p0](metalperformanceshaders/mpscnnlocalcontrastnormalization/p0.md)
- [pm](metalperformanceshaders/mpscnnlocalcontrastnormalization/pm.md)
- [ps](metalperformanceshaders/mpscnnlocalcontrastnormalization/ps.md)

### Instance Methods

- [init(device:kernelWidth:kernelHeight:)](metalperformanceshaders/mpscnnlocalcontrastnormalization/init(device:kernelwidth:kernelheight:).md)

## Relationships

### Inherits From

- [MPSCNNKernel](metalperformanceshaders/mpscnnkernel.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Normalization Layers

- [MPSCNNCrossChannelNormalization](metalperformanceshaders/mpscnncrosschannelnormalization.md)
- [MPSCNNCrossChannelNormalizationGradient](metalperformanceshaders/mpscnncrosschannelnormalizationgradient.md)
- [MPSCNNLocalContrastNormalizationGradient](metalperformanceshaders/mpscnnlocalcontrastnormalizationgradient.md)
- [MPSCNNSpatialNormalization](metalperformanceshaders/mpscnnspatialnormalization.md)
- [MPSCNNSpatialNormalizationGradient](metalperformanceshaders/mpscnnspatialnormalizationgradient.md)
- [MPSCNNBatchNormalization](metalperformanceshaders/mpscnnbatchnormalization.md)
- [MPSCNNBatchNormalizationGradient](metalperformanceshaders/mpscnnbatchnormalizationgradient.md)
- [MPSCNNBatchNormalizationState](metalperformanceshaders/mpscnnbatchnormalizationstate.md)
- [MPSCNNNormalizationMeanAndVarianceState](metalperformanceshaders/mpscnnnormalizationmeanandvariancestate.md)
- [MPSCNNBatchNormalizationStatistics](metalperformanceshaders/mpscnnbatchnormalizationstatistics.md)
- [MPSCNNBatchNormalizationStatisticsGradient](metalperformanceshaders/mpscnnbatchnormalizationstatisticsgradient.md)
- [MPSCNNInstanceNormalization](metalperformanceshaders/mpscnninstancenormalization.md)
- [MPSCNNInstanceNormalizationGradient](metalperformanceshaders/mpscnninstancenormalizationgradient.md)
- [MPSCNNInstanceNormalizationGradientState](metalperformanceshaders/mpscnninstancenormalizationgradientstate.md)
- [MPSCNNNormalizationGammaAndBetaState](metalperformanceshaders/mpscnnnormalizationgammaandbetastate.md)
