# Adjust Levels for Numeric Samples

Apply a Photoshop/GIMP-style Levels transfer curve to numeric samples: set input black/white points, midtone gamma, and output black/white levels.

## Run it

- **CLI:** `gizza tool levels-adjust "0, 64, 128, 192, 255"`
- **Web:** https://gizza.ai/tools/levels-adjust/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/levels-adjust/tool.json

## Inputs

- `values` — Values _(field)_
- `input_black` — Input black point _(field)_
- `input_white` — Input white point _(field)_
- `gamma` — Gamma / midtone _(field)_
- `output_black` — Output black level _(field)_
- `output_white` — Output white level _(field)_
- `clamp` — Clamp out-of-range values to the output endpoints _(field)_

## Output

- Adjusted values (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `values` — Values
- `input_black` — Input black point
- `input_white` — Input white point
- `gamma` — Gamma / midtone
- `output_black` — Output black level
- `output_white` — Output white level
- `clamp` — Clamp out-of-range values to the output endpoints

Example: `https://gizza.ai/tools/levels-adjust/?values=0%2C%2064%2C%20128%2C%20192%2C%20255&input_black=0&input_white=255&gamma=1&output_black=0&output_white=255&clamp=true`

---

## About this tool

Levels adjustment is the classic black-point, white-point, and gamma transfer
curve used in photo editors. This tool applies that same deterministic math to a
list of numeric samples rather than to a raster image. Paste tone values, luma
samples, sensor readings, or any other finite numbers, then choose the input
range that should become the output range.

The formula is:

1. Normalize: `(value - input_black) / (input_white - input_black)`.
2. If **Clamp** is on, clamp that normalized value to `[0, 1]`.
3. Apply midtone gamma as `normalized^(1 / gamma)`.
4. Remap to `output_black + gamma_value * (output_white - output_black)`.

### Worked example

Input values:

```text
64, 128, 192
```

With `input_black=64`, `input_white=192`, `gamma=1`, `output_black=0`, and
`output_white=255`, the output is:

```text
levels: input 64–192, gamma 1, output 0–255

0
127.5
255
```

Use gamma above `1` to brighten midtones, below `1` to darken midtones, and swap
`output_black` / `output_white` to invert values. This is a numeric transfer
function; it does not inspect image pixels, draw histograms, or auto-pick black
and white points.

## FAQ

<details>
<summary>Is this an image editor?</summary>

No. It implements the Levels transfer math for numeric lists. If you already
have pixel channel values or measurements, paste them here. Raster-image features
such as histograms, eyedroppers, and per-channel previews are outside this pure
numeric model.

</details>

<details>
<summary>What does gamma do?</summary>

Gamma controls the midtones after the input range is normalized. Values greater
than `1` brighten midtones; values between `0` and `1` darken them. The black and
white endpoints stay fixed when clamping is enabled.

</details>

<details>
<summary>What happens outside the input black and white points?</summary>

With **Clamp** enabled, values below the input black point become the output
black level, and values above the input white point become the output white
level. Disable **Clamp** to extrapolate beyond those endpoints instead.

</details>

<details>
<summary>Can I invert the values?</summary>

Yes. Set `output_black` higher than `output_white`, for example `255` and `0`.
The input black point then maps to `255`, input white maps to `0`, and the values
between them are inverted along the same gamma curve.

</details>

## Related tools

- [Base Decoder](https://gizza.ai/tools/base-decoder/): Auto-detect and decode Base16, Base32, Base45, Base58, Base64, and Base85 text, including nested layers, locally in your browser.
- [Before / after image slider generator](https://gizza.ai/tools/before-after-slider/): Turn two images into an interactive before/after comparison slider: one self-contained HTML file with inline CSS + JS, no libraries.
- [BSON Inspector](https://gizza.ai/tools/bson-inspector/): Paste BSON bytes as base64 or hex and inspect a typed tree or canonical MongoDB Extended JSON v2 with ObjectId, dates, binary, and int64 preserved.
- [Preview a Bulk File Rename](https://gizza.ai/tools/bulk-file-renamer/): Preview old-to-new filename mappings with find/replace, regex, numbering, case conversion, prefix/suffix, and collision warnings.
- [Decode/Transform Recipe Pipeline](https://gizza.ai/tools/cyberchef-pipeline/): Chain byte-level decode/transform steps — Base64, hex, URL, gzip/zlib, XOR, ROT13 — into one recipe, applied top to bottom. Free, private, runs entirely in your browser.
