Skip to content

Solarize

Fact Value
Also called Solarization, Sabattier effect
Status Implemented and tested
Family Artistic and geometric effects
Engine Browser
Type Nonlinear, point, partial negative transfer
Output Image
Operator shown as point-transfer (exact)
Support radius 0
Code web/src/core/filters/enhancement/point-ops.ts, solarizeFilter
Operator code web/src/core/filters/enhancement/point-ops.ts, solarizeTransfer
Channels RGB, Brightness only

Overview

Solarize keeps the values below a threshold and inverts the values at or above it. The bright parts turn into a negative while the dark parts stay, which imitates a partly reversed photographic print.

A plot of output value against input value. Each curve follows the straight line of no change up to its threshold, then falls to 0 at 255. A plot of output value against input value. Each curve follows the straight line of no change up to its threshold, then falls to 0 at 255.
Solarize curves with thresholds 128 and 64.

How it works

  1. Compare each value with the threshold.
  2. Keep the values below it.
  3. Replace the values at or above it with 255 minus the value.

Mathematical foundation

\[ I_{\text{out}} = \begin{cases} I & I < t \\ 255 - I & I \ge t \end{cases}, \qquad t = 128 \]

The formula shows the default parameter values.

where

  • \(I\): Input value from 0 to 255
  • \(t\): The threshold

Values below the threshold stay. Values at or above it are mirrored, as in the image negative. This is the rule of Pillow's ImageOps.solarize. In film photography, solarization and the Sabattier effect reverse tones by overexposure or by a second exposure during development. This filter only imitates the look.

The curve is the identity below the threshold and the negative above it. It is not monotonic: brighter input can give darker output. So the order of tones flips in the bright part of the image.

Kernel or operator

The Inspector draws the transfer curve for the current settings, with the input value on the horizontal axis and the output on the vertical axis. The Point-op curve in the Learn panel draws the same curve with the histograms of the open image before and after.

Algorithm

  1. Build the 256-entry table, inverting the levels at or above the threshold.
  2. Look up every pixel value in the table.

Parameters

Parameter Default Values Meaning
Threshold threshold 128 0 to 256 Values at or above this level are inverted.
Channels channelScope RGB RGB, Brightness only Which part of the color image the filter changes.

Implementation

solarizeFilter in web/src/core/filters/enhancement/point-ops.ts uses solarizeTransfer. The filter is a point filter: the runner builds a table of 256 outputs once and looks up each pixel. Values between two levels, as luma often is, go through the curve directly.

Worked example

Input 0 64 127 128 192 255
threshold 128 0 64 127 127 63 0
Pixel 0 64 127 127 63 0

Values up to 127 stay. From 128 on, the curve falls: 128 becomes 127 and 255 becomes 0.

Complexity

  • Time: \(O(N)\)
  • Memory: \(O(1)\)

N is the number of pixels. The 256-entry table makes each pixel a single lookup.

Artifacts and limitations

Limitations

  • The curve jumps at the threshold, so a smooth gradient through it breaks.

Artifacts

  • A sharp contour where values cross the threshold.

Tests

The reference writes the same curve with NumPy and applies it to the random test plane. Before the cases are written, the curve is checked against Pillow's ImageOps.solarize at four thresholds.

References