Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Grayscale
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Image where each pixel's intensity is shown only achromatic values of black, gray, and white}} {{other uses|Grayscale (disambiguation)}} {{More citations needed|date=March 2023}} {{Use American English|date=July 2020}} [[File:Grayscale 8bits palette sample image.png|thumb|right|Grayscale image of a parrot]] {{Color depth}} In [[digital photography]], [[computer-generated imagery]], and [[colorimetry]], a '''greyscale''' (more common in [[Commonwealth English]]) or '''grayscale''' (more common in [[American English]]) [[image]] is one in which the value of each [[pixel]] is a single [[sample (signal)|sample]] representing only an ''amount'' of [[light]]; that is, it carries only [[luminous intensity|intensity]] information. Grayscale images, are [[black-and-white]] or gray [[monochrome]], and composed exclusively of [[shades of gray]]. The [[contrast (vision)|contrast]] ranges from [[black]] at the weakest intensity to [[white]] at the strongest.<ref>{{cite book |last= Johnson |first= Stephen |date= 2006 |title= Stephen Johnson on Digital Photography |publisher= O'Reilly |isbn= 0-596-52370-X |url= https://books.google.com/books?id=0UVRXzF91gcC&q=grayscale+black-and-white-continuous-tone&pg=PA17}}</ref> Grayscale images are distinct from one-bit bi-tonal black-and-white images, which, in the context of computer imaging, are images with only two [[color]]s: black and white (also called ''bilevel'' or ''[[binary image]]s''). Grayscale images have many shades of gray in between. Grayscale images can be the result of measuring the intensity of light at each pixel according to a particular weighted combination of frequencies (or wavelengths), and in such cases they are [[monochromatic light|monochromatic]] proper when only a single [[frequency]] (in practice, a narrow band of frequencies) is captured. The frequencies can in principle be from anywhere in the [[electromagnetic spectrum]] (e.g. [[infrared]], [[visible spectrum|visible light]], [[ultraviolet]], etc.). A [[colorimetry|colorimetric]] (or more specifically [[photometry (optics)|photometric]]) grayscale image is an image that has a defined grayscale [[colorspace]], which maps the stored numeric sample values to the achromatic channel of a standard colorspace, which itself is based on measured properties of [[Visual perception|human vision]]. If the original color image has no defined colorspace, or if the grayscale image is not intended to have the same human-perceived achromatic intensity as the color image, then there is no unique [[Map (mathematics)|mapping]] from such a color image to a grayscale image. == Numerical representations == {| style="margin:0 0 0.5em 1em; border-collapse:collapse; float:right; clear:right;" margin="0" width="5%" |- style="background-color:#FFFFFF;" | |- style="background-color:#EEEEEE;" | |- style="background-color:#DDDDDD;" | |- style="background-color:#CCCCCC;" | |- style="background-color:#BBBBBB;" | |- style="background-color:#AAAAAA;" | |- style="background-color:#999999;" | |- style="background-color:#888888;" | |- style="background-color:#777777;" | |- style="background-color:#666666;" | |- style="background-color:#555555;" | |- style="background-color:#444444;" | |- style="background-color:#333333;" | |- style="background-color:#222222;" | |- style="background-color:#111111;" | |- style="background-color:#000000;" | |} The intensity of a pixel is expressed within a given range between a minimum and a maximum, inclusive. This range is represented in an abstract way as a range from 0 (or 0%) (total absence, black) and 1 (or 100%) (total presence, white), with any fractional values in between. This notation is used in academic papers, but this does not define what "black" or "white" is in terms of [[colorimetry]]. Sometimes the scale is reversed, as in [[printing]] where the numeric intensity denotes how much ink is employed in [[halftoning]], with 0% representing the paper white (no ink) and 100% being a solid black (full ink). In computing, although the grayscale can be computed through [[rational numbers]], image pixels are usually [[Quantization (signal processing)|quantized]] to store them as unsigned integers, to reduce the required storage and computation. Some early grayscale monitors can only display up to sixteen different shades, which would be stored in [[Binary code|binary]] form using 4 [[bit]]s.{{citation needed|date=March 2022}} But today grayscale images intended for visual display are commonly stored with 8 bits per sampled pixel. This pixel [[Color depth|depth]] allows 256 different intensities (i.e., shades of gray) to be recorded, and also simplifies computation as each pixel sample can be accessed individually as one full [[byte]]. However, if these intensities were spaced equally in proportion to the amount of physical light they represent at that pixel (called a linear encoding or scale), the differences between adjacent dark shades could be quite noticeable as banding [[compression artifact|artifacts]], while many of the lighter shades would be "wasted" by encoding a lot of perceptually-indistinguishable increments. Therefore, the shades are instead typically spread out evenly on a [[gamma correction|gamma-compressed nonlinear scale]], which better approximates uniform perceptual increments for both dark and light shades, usually making these 256 shades enough to avoid noticeable increments.<ref>{{cite book |last= Poynton |first= Charles |date= 2012 |title= Digital Video and HD: Algorithms and Interfaces |edition= 2nd |author-link= Charles Poynton |publisher= [[Morgan Kaufmann]] |url= https://books.google.com/books?id=dSCEGFt47NkC |access-date= 2022-03-31 |pages= 31β35, 65β68, 333, 337 |isbn= 978-0-12-391926-7}}</ref> Technical uses (e.g. in [[medical imaging]] or [[remote sensing]] applications) often require more levels, to make full use of the [[sensor]] accuracy (typically 10 or 12 bits per sample) and to reduce rounding errors in computations. Sixteen bits per sample (65,536 levels) is often a convenient choice for such uses, as computers manage 16-bit [[Word (data type)|words]] efficiently. The [[Tagged Image File Format|TIFF]] and [[Portable Network Graphics|PNG]] (among other) [[image file formats]] support 16-bit grayscale natively, although browsers and many imaging programs tend to ignore the low order 8 bits of each pixel. Internally for computation and working storage, image processing software typically uses integer or floating-point numbers of size 16 or 32 bits. == Converting color to grayscale == [[File:Auschwitz_channel_mixer.jpg|thumb|Examples of conversion from a full-color image to grayscale using [[Adobe Photoshop]]'s ''Channel Mixer'', compared to the original image and colorimetric conversion to grayscale]] Conversion of an arbitrary color image to grayscale is not unique in general; different weighting of the color channels effectively represent the effect of shooting black-and-white film with different-colored [[photographic filter]]s on the cameras. === Colorimetric (perceptual luminance-preserving) conversion to grayscale === A common strategy is to use the principles of [[photometry (optics)|photometry]] or, more broadly, [[colorimetry]] to calculate the grayscale values (in the target grayscale colorspace) so as to have the same luminance (technically relative luminance) as the original color image (according to its colorspace).<ref>{{cite conference |last= Poynton |first= Charles A. |date= 2022-03-14 |title= Rehabilitation of Gamma |editor-last1= Rogowitz |editor-first1= B. E. |editor-last2= Pappas |editor-first2= T. N. |conference= SPIE/IS&T Conference 3299: Human Vision and Electronic Imaging III; January 26β30, 1998 |location= San Jose, Calif. |publisher= SPIE |publication-place= Bellingham, Wash. |doi= 10.1117/12.320126 |url= https://poynton.ca/PDFs/Rehabilitation_of_gamma.pdf |archive-url= https://web.archive.org/web/20230423034709/https://poynton.ca/PDFs/Rehabilitation_of_gamma.pdf |archive-date= 2023-04-23 |url-status= live }}</ref><ref>{{cite web |last= Poynton |first= Charles A. |date= 2004-02-25 |title= Constant Luminance |url= http://poynton.ca/notes/video/Constant_luminance.html |website= Video Engineering |archive-url= https://web.archive.org/web/20230316214443/https://poynton.ca/notes/video/Constant_luminance.html |archive-date= 2023-03-16 |url-status= live}}</ref> In addition to the same (relative) luminance, this method also ensures that both images will have the same [[Luminance|absolute luminance]] when displayed, as can be measured by instruments in its [[SI]] units of [[candela per square metre|candelas per square meter]], in any given area of the image, given equal [[whitepoint]]s. Luminance itself is defined using a standard model of human vision, so preserving the luminance in the grayscale image also preserves other perceptual [[Lightness#Relationship between lightness, value, and luminance|lightness measures]], such as {{math|''L''<sup>*</sup>}} (as in the 1976 CIE [[Lab color space#CIELAB|''L''ab color space]]) which is determined by the linear luminance {{math|''Y''}} itself (as in the [[CIE 1931 color space#Definition of the CIE XYZ color space|CIE 1931 ''XYZ'' color space]]) which we will refer to here as {{math|''Y''<sub>linear</sub>}} to avoid any ambiguity. To convert a color from a colorspace based on a typical [[gamma correction|gamma-compressed]] (nonlinear) [[RGB color model]] to a grayscale representation of its luminance, the gamma compression function must first be removed via gamma expansion (linearization) to transform the image to a linear RGB colorspace, so that the appropriate [[weighted sum]] can be applied to the linear color components (<math>R_\mathrm{linear},G_\mathrm{linear},B_\mathrm{linear}</math>) to calculate the linear luminance {{math|''Y''<sub>linear</sub>}}, which can then be gamma-compressed back again if the grayscale result is also to be encoded and stored in a typical nonlinear colorspace.<ref>{{cite web |last= Lindbloom |first= Bruce |date= 2017-04-06 |title= RGB Working Space Information |url= http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html |archive-url= https://web.archive.org/web/20230601091400/http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html |archive-date= 2023-06-01 |url-status= live}}</ref> For the common [[sRGB]] color space, gamma expansion is defined as <math display="block">C_\mathrm{linear}= \begin{cases}\frac{C_\mathrm{srgb}}{12.92}, & \text{if } C_\mathrm{srgb}\le0.04045\\ \left(\frac{C_\mathrm{srgb}+0.055}{1.055}\right)^{2.4}, & \text{otherwise} \end{cases} </math> where {{math|''C''<sub>srgb</sub>}} represents any of the three gamma-compressed sRGB primaries ({{math|''R''<sub>srgb</sub>}}, {{math|''G''<sub>srgb</sub>}}, and {{math|''B''<sub>srgb</sub>}}, each in range [0,1]) and {{math|''C''<sub>linear</sub>}} is the corresponding linear-intensity value ({{math|''R''<sub>linear</sub>}}, {{math|''G''<sub>linear</sub>}}, and {{math|''B''<sub>linear</sub>}}, also in range [0,1]). Then, linear luminance is calculated as a weighted sum of the three linear-intensity values. The [[sRGB]] color space is defined in terms of the [[CIE 1931 color space|CIE 1931]] linear luminance {{math|''Y''<sub>linear</sub>}}, which is given by<ref>{{cite web |last1= Stokes |first1= Michael |last2= Anderson |first2= Matthew |last3= Chandrasekar |first3= Srinivasan |last4= Motta |first4= Ricardo |date= 1996-11-05 |title= A Standard Default Color Space for the Internet β sRGB |website= [[World Wide Web Consortium]] β Graphics on the Web |url= http://www.w3.org/Graphics/Color/sRGB |archive-url= https://web.archive.org/web/20230524195001/https://www.w3.org/Graphics/Color/sRGB |archive-date= 2023-05-24 |url-status= live |at= Part 2, matrix in equation 1.8}}</ref> <math display="block">Y_\mathrm{linear} = 0.2126 R_\mathrm{linear} + 0.7152 G_\mathrm{linear} + 0.0722 B_\mathrm{linear}.</math> These three particular coefficients represent the intensity (luminance) perception of typical [[trichromat]] humans to light of the precise [[Rec. 709]] additive primary colors (chromaticities) that are used in the definition of sRGB. Human vision is most sensitive to green, so this has the greatest coefficient value (0.7152), and least sensitive to blue, so this has the smallest coefficient (0.0722). To encode grayscale intensity in linear RGB, each of the three color components can be set to equal the calculated linear luminance <math>Y_\mathrm{linear}</math> (replacing <math>R_\mathrm{linear},G_\mathrm{linear},B_\mathrm{linear}</math> by the values <math>Y_\mathrm{linear},Y_\mathrm{linear},Y_\mathrm{linear}</math> to get this linear grayscale), which then typically needs to be [[gamma correction|gamma compressed]] to get back to a conventional non-linear representation.<ref name="Wilhelm Burger, Mark J. Burge">{{cite book |last1= Burger |first1= Wilhelm |last2= Burge |first2= Mark J. |date= 2010 |title= Principles of Digital Image Processing Core Algorithms |url= https://books.google.com/books?id=s5CBZLBakawC&pg=PA |publisher= Springer Science & Business Media |isbn= 978-1-84800-195-4 |pages= 110β111}}</ref> For sRGB, each of its three primaries is then set to the same gamma-compressed {{math|''Y''<sub>srgb</sub>}} given by the inverse of the gamma expansion above as <math display="block">Y_\mathrm{srgb}=\begin{cases} 12.92\ Y_\mathrm{linear}, & \text{if } Y_\mathrm{linear} \le 0.0031308\\ 1.055\ Y_\mathrm{linear}^{1/2.4}-0.055, & \text{otherwise} \end{cases} </math> Because the three sRGB components are then equal, indicating that it is actually a gray image (not color), it is only necessary to store these values once, and we call this the resulting grayscale image. This is how it will normally be stored in sRGB-compatible image formats that support a single-channel grayscale representation, such as JPEG or PNG. Web browsers and other software that recognizes sRGB images should produce the same rendering for such a grayscale image as it would for a "color" sRGB image having the same values in all three color channels. === Luma coding in video systems === {{Main|luma (video)}} For images in color spaces such as [[Y'UV]] and its relatives, which are used in standard color TV and video systems such as [[PAL]], [[SECAM]], and [[NTSC]], a nonlinear [[luma (video)|luma]] component {{math|(''Y{{prime}}'')}} is calculated directly from gamma-compressed primary intensities as a weighted sum, which, although not a perfect representation of the colorimetric luminance, can be calculated more quickly without the gamma expansion and compression used in photometric/colorimetric calculations. In the [[Y'UV]] and [[YIQ|Y'IQ]] models used by PAL and NTSC, the [[Rec. 601|rec601]] luma {{math|(''Y{{prime}}'')}} component is computed as <math display="block">Y' = 0.299 R' + 0.587 G' + 0.114 B'</math> where we use the prime to distinguish these nonlinear values from the sRGB nonlinear values (discussed above) which use a somewhat different gamma compression formula, and from the linear RGB components. The [[Rec. 709|ITU-R BT.709]] standard used for [[High-definition television|HDTV]] developed by the [[Advanced Television Systems Committee standards|ATSC]] uses different color coefficients, computing the luma component as <math display="block">Y' = 0.2126 R' + 0.7152 G' + 0.0722 B'.</math> Although these are numerically the same coefficients used in sRGB above, the effect is different because here they are being applied directly to gamma-compressed values rather than to the linearized values. The [[Rec. 2100|ITU-R BT.2100]] standard for [[High Dynamic Range|HDR]] television uses yet different coefficients, computing the luma component as <math display="block">Y' = 0.2627 R' + 0.6780 G' + 0.0593 B'.</math> Normally these colorspaces are transformed back to nonlinear R'G'B' before rendering for viewing. To the extent that enough precision remains, they can then be rendered accurately. But if the luma component Y' itself is instead used directly as a grayscale representation of the color image, luminance is not preserved: two colors can have the same luma {{math|''Y{{prime}}''}} but different CIE linear luminance {{math|''Y''}} (and thus different nonlinear {{math|''Y''<sub>srgb</sub>}} as defined above) and therefore appear darker or lighter to a typical human than the original color. Similarly, two colors having the same luminance {{math|''Y''}} (and thus the same {{math|''Y''<sub>srgb</sub>}}) will in general have different luma by either of the {{math|''Y{{prime}}''}} luma definitions above.<ref>{{cite web |last= Poynton |first= Charles A. |date= 1997-07-15 |title= The Magnitude of Nonconstant Luminance Errors |url= http://poynton.ca/PDFs/Mag_of_nonconst_luminance.pdf}}</ref> == Grayscale as single channels of multichannel color images == {{Unsourced section|date=March 2023}} Color images are often built of several stacked [[Channel (digital image)|color channels]], each of them representing value levels of the given channel. For example, [[RGB]] images are composed of three independent channels for red, green and blue [[primary color]] components; [[CMYK]] images have four channels for cyan, magenta, yellow and black [[Color printing|ink plates]], etc. Here is an example of color channel splitting of a full RGB color image. The column at left shows the isolated color channels in natural colors, while at right there are their grayscale equivalences: [[File:Beyoglu 4671 tricolor.png|thumb|400px|center|Composition of RGB from three grayscale images]] The reverse is also possible: to build a full-color image from their separate grayscale channels. By mangling channels, using offsets, rotating and other manipulations, artistic effects can be achieved instead of accurately reproducing the original image. == See also == * [[Channel (digital image)]] * [[Halftone]] * [[Duotone]] * [[False-color]] * [[Sepia tone]] * [[Cyanotype]] * [[Morphological image processing]] * [[Mezzotint]] * [[List of monochrome and RGB color formats]] β [[List of monochrome and RGB color formats#Monochrome palettes|Monochrome palettes]] section * [[List of software palettes]] β [[List of software palettes#Color gradient palettes|Color gradient palettes]] and [[List of software palettes#False color palettes|false color palettes]] sections * [[Achromatopsia#Complete achromatopsia|Achromatopsia]], total [[color blindness]], in which vision is limited to a grayscale * [[Zone System]] == References == {{reflist}} {{color topics}} [[Category:Imaging]] [[Category:Color depths]] [[Category:Shades of gray]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite web
(
edit
)
Template:Color depth
(
edit
)
Template:Color topics
(
edit
)
Template:Main
(
edit
)
Template:Math
(
edit
)
Template:More citations needed
(
edit
)
Template:Other uses
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Unsourced section
(
edit
)
Template:Use American English
(
edit
)