ZP / Contributionspydicom 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 the proposed correction.

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 routeProposed 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

Proposed · safe index

30Index 2

Both select the same table entry.

Follow the arithmetic

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

Proposed0 ≤ 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 proposed integer path stores indices as uint16, selects the endpoints for out-of-range inputs, and subtracts in int32 only for in-range inputs. The PR also covers larger tables and integer extremes; floating-input behavior is unchanged.

Inspect the implementation and regression tests ↗