ZP / ContributionsEarlier PR #2378 ↗

Contribution lab / Pixel display

When bright
values wrap.

A large input can accidentally choose the darkest entry in a display table. Play the example, then move the values yourself to see how a safe index preserves the endpoint.

Current status: SID-6921’s #2382 merged on 14 October 2026 and covers the common lookup-table failures. My earlier #2378 and #2379 remain open. The animation below models the earlier proposal; it does not execute current pydicom.

Paused · ready to play
0:00 / 0:24
Display lookup tableSynthetic values · height = intensity

Loading the 3D table. The arithmetic and controls work without it.

Input 2 · Before 30 → After 30

Baseline routeSafe model route

Select a bar or an index button to inspect its mapping.

01 / Read the table

One input. One table entry.

The first mapped input is 0. Input 2 selects index 2, whose output is 30. Both paths agree.

Input value2First mapped input 0

Baseline · 8-bit index

30Index 2

Safe model · index

30Index 2

Both select the same table entry.

Follow the arithmetic

Baseline2 − 0 = 2 → uint8: 2 → clip: 2 → LUT[2] = 30

Safe model0 ≤ 2 < 4 → 2 − 0 = 2 → LUT[2] = 30

Explore the boundary

Changing a control pauses the guided example.

2
0

Why the change matters

The index needs its own width.

An 8-bit output does not require an 8-bit lookup index. In the reported example, converting offset 256 to an 8-bit index makes it 0 before clipping can help. The result is 10 instead of 40.

The earlier proposal models integer indices as uint16, selects the endpoints for out-of-range inputs, and subtracts in int32 only for in-range inputs. That proposal also includes larger-table and integer-extreme tests and leaves floating-input behavior unchanged. The merged #2382 uses a different implementation: it clips before narrowing the index dtype.

Inspect the earlier proposal and regression tests ↗