{"course":{"slug":"image-editing","title":"Editing an Image","url":"https://addaly.com/learn/image-editing","level":"beginner","track":"create"},"lesson":{"slug":"gamma-and-linear-light","title":"Mid-grey is not half the light","url":"https://addaly.com/learn/image-editing/gamma-and-linear-light","position":4,"of":78,"minutes":10,"answer":"Stored pixel values are spaced to match your eye, not the light, so any operation that averages or adds pixels (resizing, blurring, transparency, compositing) is arithmetically wrong unless it is done in linear light.","keyIdea":"Stored pixel values are spaced to match your eye, not the light, so any operation that averages or adds pixels (resizing, blurring, transparency, compositing) is arithmetically wrong unless it is done in linear light."},"body":{"format":"markdown","text":"## The number 128 is a lie you need\n\nTake a pixel at RGB 255 and a pixel at RGB 128. The second one looks roughly half as bright. It is emitting about **22 per cent** of the light of the first.\n\nThis is not an error. Image files are stored with a **transfer function** applied: in sRGB, close to raising the value to the power 2.2 on the way to the display and the inverse on the way in. The reason is efficiency. Human vision is roughly logarithmic: you can tell 1 unit of light from 2 units easily, and 100 from 101 not at all. If 8-bit files stored light proportionally, almost all 256 codes would be spent on bright tones nobody can distinguish, and the shadows (where the eye is most sensitive to steps) would band horribly. Encoding perceptually spends the codes where your eye can use them.\n\nSo the numbers in an ordinary image file are **perceptually spaced**, not **physically proportional**. That single fact explains a family of bugs that otherwise look like software defects.\n\n> Figure: What a stored 8-bit value is actually emitting. Line chart of Per cent of full light against Stored value, 0 to 255: What the screen actually emits (0, 0) (32, 1) (64, 5) (96, 12) (128, 22) (160, 36) (192, 54) (224, 75) (255, 100); What the number looks like it means (0, 0) (255, 100). Mid-grey, 128, looks about half as bright and emits about 22 per cent of the light. That gap is why averaging two stored numbers is not averaging light: a checkerboard of 0 and 255 reduced by half should come back at about 188, and software that averages the encoded values hands you 128.\n\n## Where it goes visibly wrong\n\n**Resizing.** Take a fine checkerboard of pure white (255) and pure black (0) and scale it down until each new pixel covers one white and one black square. Physically, half the light is gone, so the correct answer is about 187 in sRGB. Software that averages the stored numbers gives you 128. The shrunken checkerboard comes out noticeably darker than the original, and a photograph of a distant railing or a striped shirt darkens the same way.\n\n**Blur and glow.** Blurring a bright highlight across a dark background in gamma space produces a dim, grey smear rather than a spreading glow. Compositing a bright light source over a night scene is the case where this is impossible to ignore.\n\n**Alpha blending and semi-transparent edges.** A 50 per cent opaque white over black should read as 187, not 128. Anti-aliased white text over a dark background, blended in gamma space, looks thinner and weaker than it should. This is the mechanism behind text that looks fine as black-on-white and spindly as white-on-black.\n\n**Saturated colour fringes.** Scaling down a red-and-green pattern in gamma space can produce a dark muddy band along the boundary rather than a clean yellow-ish mix.\n\n## Doing it correctly\n\nThe fix is to convert to **linear light**, do the arithmetic, convert back. Most tools can:\n\n- **Photoshop**: *Edit > Colour Settings > More Options* has **Blend RGB Colours Using Gamma 1.00**. It is off by default for a good reason: see the limit below.\n- **GIMP 2.10 and later** works internally in 32-bit linear light for many operations and lets you choose per-operation in several dialogues. This is one of the genuine technical advantages of the free tool.\n- **Krita** can set a document to 32-bit float linear, which is the standard for anyone compositing with rendered 3D.\n- **ImageMagick** on the command line: `magick in.png -colorspace RGB -resize 25% -colorspace sRGB out.png`. Here `RGB` means linear and `sRGB` means encoded, which is confusing and correct.\n- **Raw developers** (darktable, RawTherapee) work in linear scene data for the early part of the pipeline by design, which is one of the reasons starting from raw gives cleaner results.\n\n## When to care, and when not to\n\nFor an ordinary photograph of an ordinary scene, gamma-space resizing is usually fine. Real photographs are full of mid-tones with soft transitions, and the error is small enough to be invisible. This is why the industry got away with it for twenty years.\n\nCare when you have **extreme brightness ranges next to each other**: a lamp at night, a window in a dark room, stars, specular highlights on chrome. Care with **graphics**: logos, flat saturated colours, thin lines, text, anything with a hard black-white boundary being scaled. Care when **compositing** semi-transparent elements, smoke, glass or rendered output. Care with **HDR and exposure blending**, where you are literally adding light values together.\n\n## The honest cost of switching it on\n\nTurning on linear blending in Photoshop changes the result of every blend mode and every partially transparent layer in every file you open, including files a colleague made with it off. A document that looked right yesterday will look different today, and a layered file exchanged between two people with different settings will not match. That is why Adobe left it off: correctness was traded for compatibility with a decade of existing documents, deliberately.\n\nSo the sensible practice is not to flip a global switch. It is to know which operations are sensitive, handle those explicitly (a linear-light resize in ImageMagick, a 32-bit float document for a composite with real light in it) and leave the rest alone.\n\nOne genuine unresolved corner: not every operation has an obviously \"correct\" space. Sharpening in linear light exaggerates highlights unpleasantly, and most photographers prefer it done on encoded values even though the arithmetic is arguably wrong. \"Physically correct\" and \"looks right\" are not always the same target, and where they differ, photography has generally chosen the second."},"check":{"question":"A designer scales a logo made of thin pure-black lines on pure white down to a quarter size, and the lines come out heavier and darker than expected. What is the mechanism?","options":[{"text":"The resampling filter used too wide a kernel, and switching from bicubic to bilinear would give correctly weighted lines.","correct":false,"tempting":"Blames kernel width for a space error: every kernel averages the same encoded values, so all of them darken the mix in the same direction."},{"text":"Averaging perceptually encoded values understates the light in the mix, so a half-black, half-white pixel lands near 128 instead of the roughly 187 that half the light corresponds to.","correct":true},{"text":"Black lines gain weight at every reduction because black is stored as zero and zero dominates any average.","correct":false,"tempting":"Mistakes a numeric coincidence for a rule: zero has no special weight in an average, and the same darkening happens between any two very different values."},{"text":"The file was in the wrong colour profile, so the black point was mapped below zero during the resize.","correct":false,"tempting":"Reaches for profiles when the problem occurs identically within a single correctly tagged sRGB file."}]},"prev":{"slug":"bit-depth-and-banding","title":"Why the sky turns into stripes","url":"https://addaly.com/learn/image-editing/bit-depth-and-banding"},"next":{"slug":"alpha-and-the-fourth-channel","title":"Transparency is a number, and it carries a colour with it","url":"https://addaly.com/learn/image-editing/alpha-and-the-fourth-channel"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Mid-grey is not half the light', in Editing an Image. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/image-editing/gamma-and-linear-light (Accessed: 13 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Mid-grey is not half the light","courseTitle":"Editing an Image","module":{"index":1,"slug":"what-an-image-is-made-of","title":"What an image is made of"},"answer":null,"keyIdea":"Stored pixel values are spaced to match your eye, not the light, so any operation that averages or adds pixels (resizing, blurring, transparency, compositing) is arithmetically wrong unless it is done in linear light.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"type":"line","title":"What a stored 8-bit value is actually emitting","series":[{"label":"What the screen actually emits","points":[[0,0],[32,1],[64,5],[96,12],[128,22],[160,36],[192,54],[224,75],[255,100]]},{"label":"What the number looks like it means","points":[[0,0],[255,100]]}],"xLabel":"Stored value, 0 to 255","yLabel":"Per cent of full light","caption":"Mid-grey, 128, looks about half as bright and emits about 22 per cent of the light. That gap is why averaging two stored numbers is not averaging light: a checkerboard of 0 and 255 reduced by half should come back at about 188, and software that averages the encoded values hands you 128."},"alt":"Figure: What a stored 8-bit value is actually emitting. Line chart of Per cent of full light against Stored value, 0 to 255: What the screen actually emits (0, 0) (32, 1) (64, 5) (96, 12) (128, 22) (160, 36) (192, 54) (224, 75) (255, 100); What the number looks like it means (0, 0) (255, 100). Mid-grey, 128, looks about half as bright and emits about 22 per cent of the light. That gap is why averaging two stored numbers is not averaging light: a checkerboard of 0 and 255 reduced by half should come back at about 188, and software that averages the encoded values hands you 128."}},"blocks":[{"t":"h2","id":"the-number-128-is-a-lie-you-need","runs":[{"text":"The number 128 is a lie you need"}]},{"t":"p","runs":[{"text":"Take a pixel at RGB 255 and a pixel at RGB 128. The second one looks roughly half as bright. It is emitting about "},{"text":"22 per cent","b":true},{"text":" of the light of the first."}]},{"t":"p","runs":[{"text":"This is not an error. Image files are stored with a "},{"text":"transfer function","b":true},{"text":" applied: in sRGB, close to raising the value to the power 2.2 on the way to the display and the inverse on the way in. The reason is efficiency. Human vision is roughly logarithmic: you can tell 1 unit of light from 2 units easily, and 100 from 101 not at all. If 8-bit files stored light proportionally, almost all 256 codes would be spent on bright tones nobody can distinguish, and the shadows (where the eye is most sensitive to steps) would band horribly. Encoding perceptually spends the codes where your eye can use them."}]},{"t":"p","runs":[{"text":"So the numbers in an ordinary image file are "},{"text":"perceptually spaced","b":true},{"text":", not "},{"text":"physically proportional","b":true},{"text":". That single fact explains a family of bugs that otherwise look like software defects."}]},{"t":"h2","id":"where-it-goes-visibly-wrong","runs":[{"text":"Where it goes visibly wrong"}]},{"t":"p","runs":[{"text":"Resizing.","b":true},{"text":" Take a fine checkerboard of pure white (255) and pure black (0) and scale it down until each new pixel covers one white and one black square. Physically, half the light is gone, so the correct answer is about 187 in sRGB. Software that averages the stored numbers gives you 128. The shrunken checkerboard comes out noticeably darker than the original, and a photograph of a distant railing or a striped shirt darkens the same way."}]},{"t":"p","runs":[{"text":"Blur and glow.","b":true},{"text":" Blurring a bright highlight across a dark background in gamma space produces a dim, grey smear rather than a spreading glow. Compositing a bright light source over a night scene is the case where this is impossible to ignore."}]},{"t":"p","runs":[{"text":"Alpha blending and semi-transparent edges.","b":true},{"text":" A 50 per cent opaque white over black should read as 187, not 128. Anti-aliased white text over a dark background, blended in gamma space, looks thinner and weaker than it should. This is the mechanism behind text that looks fine as black-on-white and spindly as white-on-black."}]},{"t":"p","runs":[{"text":"Saturated colour fringes.","b":true},{"text":" Scaling down a red-and-green pattern in gamma space can produce a dark muddy band along the boundary rather than a clean yellow-ish mix."}]},{"t":"h2","id":"doing-it-correctly","runs":[{"text":"Doing it correctly"}]},{"t":"p","runs":[{"text":"The fix is to convert to "},{"text":"linear light","b":true},{"text":", do the arithmetic, convert back. Most tools can:"}]},{"t":"ul","items":[[{"text":"Photoshop","b":true},{"text":": "},{"text":"Edit > Colour Settings > More Options","i":true},{"text":" has "},{"text":"Blend RGB Colours Using Gamma 1.00","b":true},{"text":". It is off by default for a good reason: see the limit below."}],[{"text":"GIMP 2.10 and later","b":true},{"text":" works internally in 32-bit linear light for many operations and lets you choose per-operation in several dialogues. This is one of the genuine technical advantages of the free tool."}],[{"text":"Krita","b":true},{"text":" can set a document to 32-bit float linear, which is the standard for anyone compositing with rendered 3D."}],[{"text":"ImageMagick","b":true},{"text":" on the command line: "},{"text":"magick in.png -colorspace RGB -resize 25% -colorspace sRGB out.png","code":true},{"text":". Here "},{"text":"RGB","code":true},{"text":" means linear and "},{"text":"sRGB","code":true},{"text":" means encoded, which is confusing and correct."}],[{"text":"Raw developers","b":true},{"text":" (darktable, RawTherapee) work in linear scene data for the early part of the pipeline by design, which is one of the reasons starting from raw gives cleaner results."}]]},{"t":"h2","id":"when-to-care-and-when-not-to","runs":[{"text":"When to care, and when not to"}]},{"t":"p","runs":[{"text":"For an ordinary photograph of an ordinary scene, gamma-space resizing is usually fine. Real photographs are full of mid-tones with soft transitions, and the error is small enough to be invisible. This is why the industry got away with it for twenty years."}]},{"t":"p","runs":[{"text":"Care when you have "},{"text":"extreme brightness ranges next to each other","b":true},{"text":": a lamp at night, a window in a dark room, stars, specular highlights on chrome. Care with "},{"text":"graphics","b":true},{"text":": logos, flat saturated colours, thin lines, text, anything with a hard black-white boundary being scaled. Care when "},{"text":"compositing","b":true},{"text":" semi-transparent elements, smoke, glass or rendered output. Care with "},{"text":"HDR and exposure blending","b":true},{"text":", where you are literally adding light values together."}]},{"t":"h2","id":"the-honest-cost-of-switching-it-on","runs":[{"text":"The honest cost of switching it on"}]},{"t":"p","runs":[{"text":"Turning on linear blending in Photoshop changes the result of every blend mode and every partially transparent layer in every file you open, including files a colleague made with it off. A document that looked right yesterday will look different today, and a layered file exchanged between two people with different settings will not match. That is why Adobe left it off: correctness was traded for compatibility with a decade of existing documents, deliberately."}]},{"t":"p","runs":[{"text":"So the sensible practice is not to flip a global switch. It is to know which operations are sensitive, handle those explicitly (a linear-light resize in ImageMagick, a 32-bit float document for a composite with real light in it) and leave the rest alone."}]},{"t":"p","runs":[{"text":"One genuine unresolved corner: not every operation has an obviously “correct” space. Sharpening in linear light exaggerates highlights unpleasantly, and most photographers prefer it done on encoded values even though the arithmetic is arguably wrong. “Physically correct” and “looks right” are not always the same target, and where they differ, photography has generally chosen the second."}]}],"check":{"question":[{"text":"A designer scales a logo made of thin pure-black lines on pure white down to a quarter size, and the lines come out heavier and darker than expected. What is the mechanism?"}],"options":[{"text":[{"text":"The resampling filter used too wide a kernel, and switching from bicubic to bilinear would give correctly weighted lines."}],"correct":false,"tempting":[{"text":"Blames kernel width for a space error: every kernel averages the same encoded values, so all of them darken the mix in the same direction."}]},{"text":[{"text":"Averaging perceptually encoded values understates the light in the mix, so a half-black, half-white pixel lands near 128 instead of the roughly 187 that half the light corresponds to."}],"correct":true,"tempting":null},{"text":[{"text":"Black lines gain weight at every reduction because black is stored as zero and zero dominates any average."}],"correct":false,"tempting":[{"text":"Mistakes a numeric coincidence for a rule: zero has no special weight in an average, and the same darkening happens between any two very different values."}]},{"text":[{"text":"The file was in the wrong colour profile, so the black point was mapped below zero during the resize."}],"correct":false,"tempting":[{"text":"Reaches for profiles when the problem occurs identically within a single correctly tagged sRGB file."}]}],"order":[0,3,1,2],"why":null},"prev":{"slug":"bit-depth-and-banding","title":"Why the sky turns into stripes","minutes":9},"next":{"slug":"alpha-and-the-fourth-channel","title":"Transparency is a number, and it carries a colour with it","minutes":9}}}