<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/w/index.php?action=history&amp;feed=atom&amp;title=Conditional_%28computer_programming%29</id>
	<title>Conditional (computer programming) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/w/index.php?action=history&amp;feed=atom&amp;title=Conditional_%28computer_programming%29"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;action=history"/>
	<updated>2026-07-09T03:49:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.47.0-wmf.7</generator>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;diff=289232&amp;oldid=prev</id>
		<title>219.89.10.180: /* Arithmetic if */ IBM704 has three-destination conditional branch op code. Some suggest that from IBM704 came FoUrtran....</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;diff=289232&amp;oldid=prev"/>
		<updated>2014-11-19T03:46:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Arithmetic if: &lt;/span&gt; IBM704 has three-destination conditional branch op code. Some suggest that from IBM704 came FoUrtran....&lt;/p&gt;
&lt;a href=&quot;https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;amp;diff=289232&amp;amp;oldid=4998&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>219.89.10.180</name></author>
	</entry>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;diff=4998&amp;oldid=prev</id>
		<title>en&gt;ClueBot NG: Reverting possible vandalism by 190.90.35.20 to version by Gilliam. False positive? Report it. Thanks, ClueBot NG. (0) (Bot)</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Conditional_(computer_programming)&amp;diff=4998&amp;oldid=prev"/>
		<updated>2014-01-16T12:39:53Z</updated>

		<summary type="html">&lt;p&gt;Reverting possible vandalism by &lt;a href=&quot;/wiki/Special:Contributions/190.90.35.20&quot; title=&quot;Special:Contributions/190.90.35.20&quot;&gt;190.90.35.20&lt;/a&gt; to version by Gilliam. False positive? &lt;a href=&quot;/w/index.php?title=User:ClueBot_NG/FalsePositives&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:ClueBot NG/FalsePositives (page does not exist)&quot;&gt;Report it&lt;/a&gt;. Thanks, &lt;a href=&quot;/w/index.php?title=User:ClueBot_NG&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:ClueBot NG (page does not exist)&quot;&gt;ClueBot NG&lt;/a&gt;. (0) (Bot)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Redirect|Greyscale|the film|Greyscale (film)}}&lt;br /&gt;
{{Distinguish|Gray code}}&lt;br /&gt;
{{Color depth}}&lt;br /&gt;
{{grayscale}}&lt;br /&gt;
&lt;br /&gt;
In [[photography]] and [[computing]], a &amp;#039;&amp;#039;&amp;#039;grayscale&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;greyscale&amp;#039;&amp;#039;&amp;#039; [[digital image]] is an image in which the value of each [[pixel]] is a single [[sample (signal)|sample]], that is, it carries only [[Luminous intensity|intensity]] information. Images of this sort, also known as [[black-and-white]], are composed exclusively of shades of [[gray]], varying from black at the weakest intensity to white at the strongest.&amp;lt;ref&amp;gt;{{cite book | title = Stephen Johnson on Digital Photography | author = Stephen Johnson | publisher = O&amp;#039;Reilly | year = 2006 | isbn = 0-596-52370-X | url = http://books.google.com/books?id=0UVRXzF91gcC&amp;amp;pg=PA17&amp;amp;dq=grayscale+black-and-white-continuous-tone&amp;amp;ei=XlwqSdGVOILmkwTalPiIDw }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Grayscale images are distinct from one-bit bi-tonal black-and-white images, which in the context of computer imaging are images with only the two [[color]]s, [[black]], and [[white]] (also called &amp;#039;&amp;#039;bilevel&amp;#039;&amp;#039; or &amp;#039;&amp;#039;[[binary image]]s&amp;#039;&amp;#039;).  Grayscale images have many shades of gray in between.  Grayscale  images are also called [[monochromatic]], denoting the presence of only one (mono) color (chrome).&lt;br /&gt;
&lt;br /&gt;
Grayscale images are often the result of measuring the intensity of light at each pixel in a single band of the [[electromagnetic spectrum]] (e.g. [[infrared]], [[visible spectrum|visible light]], [[ultraviolet]], etc.), and in such cases they are monochromatic proper when only a given [[frequency]] is captured. But also they can be synthesized from a full color image; see the section about converting to grayscale.&lt;br /&gt;
&lt;br /&gt;
==Numerical representations==&lt;br /&gt;
[[File:Grayscale 8bits palette sample image.png|thumb|left|An example grayscale image.]]&lt;br /&gt;
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 (total absence, black) and 1 (total presence, white), with any fractional values in between. This notation is used in academic papers, but this does not define what &amp;quot;black&amp;quot; or &amp;quot;white&amp;quot; is in terms of [[colorimetry]].&lt;br /&gt;
&lt;br /&gt;
Another convention is to employ [[percentage]]s, so the scale is then from 0% to 100%. This is used for a more intuitive approach, but if only [[integer]] values are used, the range encompasses a total of only 101 intensities, which are insufficient to represent a broad gradient of grays. Also, the percentile notation is used in [[printing]] to denote how much ink is employed in [[halftoning]], but then the scale is reversed, being 0% the paper white (no ink) and 100% a solid black (full ink).&lt;br /&gt;
&lt;br /&gt;
In computing, although the grayscale can be computed through [[rational numbers]], image pixels are stored in [[Binary code|binary]], [[Quantization (signal processing)|quantized]] form. Some early grayscale monitors can only show up to sixteen (4-[[bit]]) different shades, but today grayscale images (as photographs) intended for visual display (both on screen and printed) are commonly stored with 8 bits per sampled pixel, which allows 256 different intensities (i.e., shades of gray) to be recorded, typically on a [[gamma correction|non-linear scale]]. The precision provided by this format is barely sufficient to avoid visible banding [[compression artifact|artifacts]], but very convenient for programming due to the fact that a single pixel then occupies a single [[byte]].&lt;br /&gt;
&lt;br /&gt;
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 guard against roundoff errors in computations. Sixteen bits per sample (65,536 levels) is a convenient choice for such uses, as computers manage 16-bit [[Word (data type)|word]]s efficiently.  The [[Tagged Image File Format|TIFF]] and the [[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.&lt;br /&gt;
&lt;br /&gt;
No matter what pixel [[Color depth|depth]] is used, the binary representations assume that 0 is black and the maximum value (255 at 8 bpp, 65,535 at 16 bpp, etc.) is white, if not otherwise noted.&lt;br /&gt;
&lt;br /&gt;
==Converting color to grayscale==&lt;br /&gt;
Conversion of a color image to grayscale is not unique; 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.&lt;br /&gt;
&lt;br /&gt;
===Colorimetric (luminance-preserving) conversion to grayscale===&lt;br /&gt;
A common strategy is to use the principles of [[photometry (optics)|photometry]] or, more broadly, [[colorimetry]] to match the [[luminance (relative)|luminance]] of the grayscale image to the luminance of the original color image.&amp;lt;ref&amp;gt;Poynton, Charles A. &amp;quot;Rehabilitation of gamma.&amp;quot; Photonics West&amp;#039;98 Electronic Imaging. International Society for Optics and Photonics, 1998. [http://proceedings.spiedigitallibrary.org/proceeding.aspx?articleid=936787 online]&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Charles Poynton, [http://poynton.com/notes/video/Constant_luminance.html Constant Luminance]&amp;lt;/ref&amp;gt;  This also ensures that both images will have the same [[Luminance|absolute luminance]], as can be measured in its [[SI]] units of  [[candela per square metre|candelas per square meter]], in any given area of the image, given equal [[whitepoint]]s.  In addition, matching luminance provides matching perceptual [[Lightness#Relationship_between_lightness.2C_value.2C_and_luminance|lightness measures]], such as {{math|&amp;#039;&amp;#039;L&amp;#039;&amp;#039;&amp;lt;sup&amp;gt;*&amp;lt;/sup&amp;gt;}} (as in the 1976 CIE [[Lab_color_space#CIELAB|&amp;#039;&amp;#039;L&amp;#039;&amp;#039;ab color space]]) which is determined by the luminance {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;}} (as in the [[CIE 1931 color space|CIE 1931 &amp;#039;&amp;#039;XYZ&amp;#039;&amp;#039; color space]]) .&lt;br /&gt;
&lt;br /&gt;
To convert a color from a colorspace based on an [[RGB color model]] to a grayscale representation of its luminance, [[weighted sum]]s must be calculated in a linear RGB space, that is, after the [[gamma correction|gamma compression]] function has been removed first via gamma expansion.&amp;lt;ref&amp;gt;Bruce Lindbloom, [http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html RGB Working Space Information] ([http://web.archive.org/web/20131002132220/http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html retrieved 2013-10-02])&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the [[sRGB]] color space,  gamma expansion is defined as &lt;br /&gt;
:&amp;lt;math&amp;gt;C_\mathrm{linear}=&lt;br /&gt;
\begin{cases}\frac{C_\mathrm{srgb}}{12.92}, &amp;amp; C_\mathrm{srgb}\le0.04045\\&lt;br /&gt;
\left(\frac{C_\mathrm{srgb}+0.055}{1.055}\right)^{2.4}, &amp;amp; C_\mathrm{srgb}&amp;gt;0.04045&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where {{math|&amp;#039;&amp;#039;C&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}} represents any of the three gamma-compressed sRGB primaries ({{math|&amp;#039;&amp;#039;R&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}}, {{math|&amp;#039;&amp;#039;G&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}}, and {{math|&amp;#039;&amp;#039;B&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}}, each in range [0,1]) and {{math|&amp;#039;&amp;#039;C&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;linear&amp;lt;/sub&amp;gt;}} is the corresponding linear-intensity value ({{math|&amp;#039;&amp;#039;R&amp;#039;&amp;#039;}}, {{math|&amp;#039;&amp;#039;G&amp;#039;&amp;#039;}}, and {{math|&amp;#039;&amp;#039;B&amp;#039;&amp;#039;}}, also in range [0,1]). Then, 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|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;}}, which is given by&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;Y = 0.2126 R + 0.7152 G + 0.0722 B&amp;lt;/math&amp;gt;.&amp;lt;ref&amp;gt;Michael Stokes, Matthew Anderson, Srinivasan Chandrasekar, and Ricardo Motta, &amp;quot;A Standard Default Color Space for the Internet - sRGB&amp;quot;, [http://www.w3.org/Graphics/Color/sRGB online] see matrix at end of Part 2.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The coefficients represent the measured intensity perception of typical [[trichromat]] humans, depending on the primaries being used; in particular, human vision is most sensitive to green and least sensitive to blue.  To encode grayscale intensity in linear RGB, each of the three primaries can be set to equal the calculated linear luminance {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;}} (replacing R,G,B by Y,Y,Y to get this linear grayscale). Linear luminance typically needs to be [[gamma correction|gamma compressed]] to get back to a conventional non-linear representation.  For sRGB, each of its three primaries is then set to the same gamma-compressed {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}} given by the inverse of the gamma expansion above as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;Y_\mathrm{srgb}=\begin{cases}&lt;br /&gt;
12.92\ Y, &amp;amp; Y \le 0.0031308\\&lt;br /&gt;
1.055\ Y^{1/2.4}-0.055, &amp;amp; Y &amp;gt; 0.0031308.&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, because the three sRGB components are then equal, it is only necessary to store these values once in sRGB-compatible image formats that support a single-channel representation.  Web browsers and other software that recognizes sRGB images will typically produce the same rendering for a such a grayscale image as it would for an sRGB image having the same values in all three color channels.&lt;br /&gt;
&lt;br /&gt;
===Luma coding in video systems===&lt;br /&gt;
{{Main|luma (video)}}&lt;br /&gt;
&lt;br /&gt;
For images in color spaces such as [[Y&amp;#039;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|(&amp;#039;&amp;#039;Y&amp;amp;#39;&amp;#039;&amp;#039;)}} is calculated directly from gamma-compressed primary intensities as a weighted sum, which can be calculated quickly without the gamma expansion and compression used in colorimetric grayscale calculations. In the [[Y&amp;#039;UV]] and [[YIQ|Y&amp;#039;IQ]] models used by PAL and NTSC, the [[Rec. 601|rec601]] [[luma (video)|luma]] {{math|(&amp;#039;&amp;#039;Y&amp;amp;#39;&amp;#039;&amp;#039;)}} component is computed as&lt;br /&gt;
:&amp;lt;math&amp;gt;Y&amp;#039; =  0.299 R&amp;#039; + 0.587 G&amp;#039; + 0.114 B&amp;#039;&amp;lt;/math&amp;gt;&lt;br /&gt;
where we use the prime to distinguish these gamma-compressed values from the linear R, G, B, and Y discussed above.  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&lt;br /&gt;
:&amp;lt;math&amp;gt;Y&amp;#039; =  0.2126 R&amp;#039; + 0.7152 G&amp;#039; + 0.0722 B&amp;#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Normally these colorspaces are transformed back to R&amp;#039;G&amp;#039;B&amp;#039; before rendering for viewing.  To the extent that enough precision remains, they can then be rendered accurately.&lt;br /&gt;
&lt;br /&gt;
But if the luma component by 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|&amp;#039;&amp;#039;Y&amp;amp;#39;&amp;#039;&amp;#039;}} but different CIE linear luminance {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;}} (and thus different nonlinear {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}} 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|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;}} (and thus the same {{math|&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;&amp;lt;sub&amp;gt;srgb&amp;lt;/sub&amp;gt;}}) will in general have different luma by either of the {{math|&amp;#039;&amp;#039;Y&amp;amp;#39;&amp;#039;&amp;#039;}} luma definitions above.&amp;lt;ref&amp;gt;Charles Poynton, [http://poynton.com/PDFs/Mag_of_nonconst_luminance.pdf The magnitude of nonconstant luminance errors] in Charles Poynton, A Technical Introduction to Digital Video. New York: John WIley &amp;amp; Sons, 1996.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Grayscale as single channels of multichannel color images==&lt;br /&gt;
&lt;br /&gt;
Color images are often built of several stacked [[Channel (digital image)|color channel]]s, 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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
[[File:Beyoglu 4671 tricolor.png|thumb|400px|center|Composition of RGB from 3 Grayscale images]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Channel (digital image)]]&lt;br /&gt;
* [[Halftone]]&lt;br /&gt;
* [[Duotone]]&lt;br /&gt;
* [[False-color]]&lt;br /&gt;
* [[Sepia tone]]&lt;br /&gt;
* [[Cyanotype]]&lt;br /&gt;
* [[Morphological image processing]]&lt;br /&gt;
* [[Mezzotint]]&lt;br /&gt;
* [[List of monochrome and RGB palettes]] – [[List of monochrome and RGB palettes#Monochrome palettes|Monochrome palettes]] section&lt;br /&gt;
* [[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&lt;br /&gt;
* [[Achromatopsia#Complete Achromatopsia|Achromatopsia]], total [[color blindness]], in which vision is limited to a grayscale.&lt;br /&gt;
* [[Zone System]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Imaging]]&lt;br /&gt;
[[Category:Color depths]]&lt;/div&gt;</summary>
		<author><name>en&gt;ClueBot NG</name></author>
	</entry>
</feed>