Utilora

Image Histogram & Levels

Image Tools

What is Image Histogram & Levels?

WebGPU Image Histogram & Levels gives researchers and photographers a fast, browser-native way to inspect tonal distribution and adjust black point, white point, and gamma. The histogram is computed with a WebGPU compute shader using atomic counters — fast even on full-resolution images. The levels controls re-apply with each slider drag, so you can see exactly how a tonal stretch affects the distribution before exporting.

How it works

A WebGPU compute shader runs one workgroup per 8×8 tile of the input texture, sampling each pixel and atomically incrementing four 256-bin counters: R, G, B, and luminance. The result buffer is mapped back to JavaScript, rendered into an SVG-style filled curve on a 2D canvas. The levels fragment shader applies (v − black) / (white − black), gamma-corrects with pow(·, 1/gamma), and clamps; a channel selector decides whether the curve runs on all three channels or just one.

Features & Benefits

  • Per-channel histogram computed on the GPU using atomic counters in a compute shader
  • Levels adjustment (black point, white point, gamma) in a single fragment pass
  • Choose to apply the levels curve to RGB jointly or to a single channel
  • Visual sanity-check for scientific images, micrographs, or scans before downstream processing

Frequently Asked Questions

Why a compute shader instead of CPU code?

A 12-megapixel image is 12M pixels. Counting bins on the CPU takes hundreds of milliseconds; the compute shader does it in a frame.

Is luminance Rec. 709?

Yes. The luminance histogram uses the standard Rec. 709 weights (0.2126, 0.7152, 0.0722).

Can I undo the levels adjustment?

Reset returns the sliders to defaults (0, 1, 1). The original image is kept in memory so re-rendering is instant.

Is the image uploaded?

No. All GPU work happens on your device; nothing is sent off-device.

Related Tools

Popular Utilities