Levels & Auto-Contrast
Set the black point, white point and gamma of a photo, or let Auto contrast find them from the histogram. The curve, the histogram and one pixel are worked through with real numbers.
How to Use
- Drop an image on the box, click to browse, or paste one. TIFF, PSD, HEIC, TGA and camera RAW files open too. A built-in sample is loaded so you can try the presets straight away.
- Click Auto contrast to set the black and white points from the image itself, or set them by hand: values at or below the black point become black, values at or above the white point become white.
- Move Gamma to brighten (above 1) or darken (below 1) the midtones without moving black or white. Output black and white limit the final range, for a matte look.
- Watch the histogram: the blue, grey and red lines are the black, midtone and white points, and the orange curve is the mapping. Click the picture to follow one pixel in Show Work.
- Save the result in any format from the Save panel. Large photos are previewed smaller, then processed again at full size when you save.
Worked Example
A hazy scan whose values only run from 30 to 225. Set black 30, white 225 and gamma 1.5. A mid-grey 128 sits at t = (128 − 30) ÷ 195 = 0.5026 of the way up; t^(1 ÷ 1.5) = 0.6321, and 0.6321 × 255 = 161.2, saved as 161. A shadow at 20 is below the black point and becomes 0, a highlight at 240 becomes 255, and the midtone point is 30 + 195 × 0.5^1.5 = 98.9.
Darker midtones and a matte finish. With gamma 0.7 the same 128 gives 0.5026^(1 ÷ 0.7) = 0.3742, or 95. Leave the input points at 0 and 255 and set output 40 to 235 instead, and 0 becomes 40, 255 becomes 235 and 128 becomes 40 + 195 × 0.502 = 137.9, saved as 138.
The common mistake: turning gamma the wrong way. Here, as in the Levels dialogs of most photo editors, gamma above 1 brightens: 128 becomes 161 at 1.5. Some formulas raise the value to the power gamma instead of 1 ÷ gamma, where 1.5 darkens. Typing 0.67 here to brighten a photo gives 91 instead of 161.
Show Work
Formulas
W = highest v with more than 0.5% ≥ v
Histograms, Contrast Stretching and Gamma
An image histogram counts how many pixels have each value from 0 to 255. A faded scan or a photo taken through haze shows up as a histogram that stops short of both ends: the darkest pixel might be 30 and the brightest 225, so only 196 of the 256 available levels are used. Mapping that range back onto 0 to 255 is called contrast stretching, a kind of normalisation, and it is exactly what the black and white points do.
The middle control is a power-law curve, the same family as the gamma correction used to encode brightness in video and image files. Raising t to the power 1 ÷ γ keeps 0 and 1 fixed and bends everything between, so midtones move while the ends do not. Because the curve is computed once for all 256 possible values and then looked up for each channel of each pixel, even a 50-megapixel photo is processed quickly.
About This Tool
This tool applies input black and white points, gamma and output levels to red, green and blue, finds the points automatically from the histogram, draws the curve over the before and after histograms, reports how many pixels clip at each end, and works through any pixel you click. Settings can be put in the page address, for example ?ib=30&iw=225&gamma=1.5.
Images are decoded and saved in your browser by the engine behind the Universal Image Converter, so TIFF, PSD, HEIC, TGA and RAW files work too. Nothing is uploaded.
Related tools: Image Histogram Viewer, Image Adjustments, and Posterize (Color Levels).
Frequently Asked Questions
What does the gamma value do?
It bends the curve between the black and white points: each value becomes t^(1 ÷ gamma), where t is its position between them from 0 to 1. Gamma 1.5 lifts a 25% grey (64) to 101 and mid-grey 128 to 161, while 0 and 255 stay put. Gamma 1 is a straight line and below 1 darkens.
How does Auto contrast choose the points?
It counts every red, green and blue value in the picture, lets 0.5% of them clip at each end, and uses the darkest and lightest values left as the black and white points, with gamma 1. A flat scan whose values run from 30 to 225 is stretched to the full 0 to 255.
What is the difference between input and output levels?
Input black and white choose which values become the darkest and lightest. Output black and white set what those become. Output 40 to 235 maps 0 to 40, 255 to 235 and 128 to 138, a soft matte look with no pure black or white.
Does Levels change the colours?
The same curve is applied to red, green and blue, so neutral greys stay neutral. A curve that is not a straight line does shift saturation a little: with gamma 1.5 a brick red (180, 60, 40) becomes (202, 97, 74), slightly paler, because the dark channels are lifted more than the bright one. Transparency is never changed.
Why are parts of my picture flat black or white?
That is clipping. Every value at or below the black point becomes the same output black, and every value at or above the white point the same output white, so detail there is gone in the saved file. The Shadows and Highlights Clipped readouts show the share of pixels affected.
How do I use the Levels & Auto-Contrast?
Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Does it cost anything or need an account?
No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.
Is anything I type uploaded?
No. The tool works entirely on your device, so the values you enter never leave your browser.
Common Use Cases
Restore a faded scan
Black 30 and white 225 stretch a grey, washed-out scan that only used values 30 to 225 back to the full 0 to 255.
Open up dark shadows
Gamma 1.5 lifts a shadow at 64 to 101 while white stays at 255, so nothing bright is blown out.
Matte, faded-film look
Output levels 40 to 235 lift the blacks and soften the whites, the look of an old print.
Quick fix for a flat photo
Auto contrast clips 0.5% of values at each end and stretches the rest across the full range in one click.
Last updated: