Palette (computing): Difference between revisions

Content deleted Content added
no sentences
 
(26 intermediate revisions by 19 users not shown)
Line 1:
{{More citations needed|date=September 2021}}
{{about|color lookup tables|color schemes used in design software|color scheme|the UI element also known as utility window|Palette window}}
{{short description|In computer graphics, a finite set of available colors}}
{{Color depth}}
 
{{multiple image
| align = right
| image1 = RGB 24bits palette sample image.jpg
| width1 = 150
| caption1 = Sample image
| image2 = Sample Image RGB Cube.gif
| width2 = 200
| caption2 = The palette used in the image, shown rotating about the [[RGB color space]].
}}
 
In [[computer graphics]], a '''palette''', alsois calledthe '''colorset lookupof table'''available (CLUT),colors isfrom awhich setan ofimage [[color]]scan availablebe inmade. a digitalIn imagingsome scenariosystems, suchthe aspalette ais displayfixed orby anthe imagehardware filedesign, format.<ref>[https://docs.gimp.org/2.10/en/gimp-palette-dialog.htmland docsin gimpothers 2.10:it palette-dialog]</ref>is Adynamic, palettetypically isimplemented basicallyvia a '''color lookup table''' defining(CLUT), a limitedcorrespondence subsettable ofin which selected colors from a certain [[color space]]'s color reproduction range; thisare enablesassigned colorsan inindex, theby palettewhich tothey can be referenced. usingBy referencing the colors via an index, which takes less information than the one needed to describe the actual colors in saidthe color space. Images employing, this technique areaims calledto [[indexedreduce color]]data images. Thususage, theincluding usageprocessing, oftransfer colorbandwidth, palettesRAM isusage, aand techniquestorage. thatImages aimsin towhich reducecolors dataare usage,indicated beby itreferences asto processinga payload,CLUT transferare bandwidth,called RAM[[indexed usagecolor]] or persistent storageimages.
 
==Description==
As of 2019, the most common image colorspace in computing[[graphics card]]s is the [[RGB color model]] with 8 bits per pixel [[color depth]]. Using this technique, 8 bits per pixel are used to describe the [[luminance]] level in each of the [[RGB channel]]s, therefore 24 bits offully storagedescribe (inthe eithercolor RAMof oreach persistentpixel. storage) areThe necessaryfull tosystem fullypalette describefor thesuch colorhardware oftherefore eachhas pixel2<sup>24</sup> colors. The objective of the usage of smaller palettes via CLUTs is to lower thisthe storagenumber requirementof bits per pixel by reducing the set of possible colors that are to be handled at once (often using adaptive methods),. assigning eachEach possible color is assigned an index, which allows each color to be referenced using less information than needed to fully describe the color. A commonAn example is the 256-color palette commonly used in the [[GIF]] file format, in which 256 colors to be used to represent an image are selected from the whole 24 bppbit color space, each being assigned an 8 bit index. This way, while the system can potentially reproduce any color in the RGB color space (as long as the 256 color restriction allows), the storage requirement per pixel is lowered from 24 to 8 bits per pixel.
 
==Master palette==
[[File:Palette sizes.ogv|right|thumb|300px|An adaptive color palette expanding from 2 colors to 256 colors, demonstrating how the image changes (click to see animation).]]
In an application showing many different [[thumbnail|image thumbnail]]s in a mosaic on screen, the program may not be able to load all the adaptive palettes of every displayed image thumbnail at the same time in the hardware color registers. A solution is to use a unique, common ''[[List of software palettes#RGB arrangements|master palette]]'' or ''universal palette'', which can be used to display with reasonable accuracy any kind of image.
 
This is done by selecting colors in such way that the master palette comprises a full [[RGB color space]] "in miniature", limiting the possible levels that the red, green, and blue components may have. This kind of arrangement is sometimes referred to as a ''uniform palette''.<ref>[http://tex.imm.uran.ru/alchemy.pdf Handmade Software's ''Image Alchemy'' User's Manual.]</ref> The normal [[human eye]] has sensibility to the three primary colors in different degrees: the more to the green, the less to the blue. So RGB arrangements can take advantage of this by assigning more levels for the green component and lessfewer to the blue.
 
A master palette built this way can be filled with up to {{nowrap|[[List of software palettes#8-8-4 levels RGB|8R×8G×4B {{=}} 256 colors]]}}, but this does not leave space in the palette for reserved colors, color indices that the program could use for special purposes. It is more general to use only {{nowrap|[[List of software palettes#6 level RGB|6R×6G×6B {{=}} 216]]}} (as in the [[Web colors]] case), {{nowrap|[[List of software palettes#6-8-5 levels RGB|6R×8G×5B {{=}} 240]]}} or {{nowrap|[[List of software palettes#6-7-6 levels RGB|6R×7G×6B {{=}} 252]]}}, which leaves room for some reserved colors.
Line 34 ⟶ 35:
 
==Adaptive palette==
When using [[indexed color]] techniques, real life images are represented with better fidelity to the [[24-bit color|truecolor]] original one by using [[List of software palettes#Adaptive palettes|adaptive palette]]s (sometimes spelledtermed ''adaptative palettes''), in which the colors are selected or [[color quantization|quantized]] through some algorithm directly from the original image (by picking the most frequent colors). This way, and with further [[dithering]], the indexed color image can nearly match the original.
 
But this creates a heavy dependence between the image [[pixel]]s and its adaptive palette. Assuming a limited 8-bit depth graphic display, it is necessary to load a given image's adaptive palette into the color hardware registers prior to loading the image surface itself into the [[Framebuffer|frame buffer]]. To display different images with different adaptive palettes, they must be loaded one by one, as in a [[slideshow]]. Here are samples of four different indexed color images with color patches to show their respective (and largely incompatible) adaptive palettes:
Line 72 ⟶ 73:
[[2D computer graphics|2-D painting programs]], like [[Microsoft Paint]] and [[Deluxe Paint]], can employ the user designated ''background color'' as the transparent color when performing [[cut, copy, and paste]] operations.
 
Although related (due to they are used for the same purposes), [[Image mask|image bit masks]] and [[alpha channel]]s are techniques which do not involve the use of palettes nor transparent color at all, but off-image added extra binary data layers.
 
==Software palettes==
{{see also|List of software palettes}}
===Microsoft Windows===
[[Microsoft Windows]] applications manage the palette of 4-bit or 8-bit indexed color display devices through specialized functions of the [[Win32 API]]. The applicability of palettes in [[Highcolor]] and [[24-bit color|Truecolor]] display modes becomes questionable. These APIs deals with the so-called ''"system palette''" and with many ''"logical palettes''".
 
The ''"system palette''" is a copy in [[Random-access memory|RAM]] of the color display's hardware registers, primarily a physical palette, and it is a unique, shared common resource of the system. At boot, it is loaded with the [[List of software palettes#Microsoft Windows and IBM OS/2 default 16-color palettecolor_palette|default system palette]] (mainly a ''"master palette''" which works well enough with most programs).
 
When a given application intends to output colorized graphics and/or images, it can set their own ''"logical palette''", that is, its own private selection of colors (up to 256). It is supposed that every graphic element that the application tries to show on screen employs the colors of its logical palette. Every program can manage freely one or more logical palettes without further expected interference (in advance).
 
Before the output is effectively made, the program must ''realize'' its logical palette: theThe system tries to match then the ''"logical''" colors with ''"physical''" ones. If an intended color is already present intoin the system palette, the system internally maps both the logical andto the system palette indexes (due tobecause they rarely coincide). If the intended color is not present yet, the system applies an internal algorithm to discard the least -used color in the system palette (generally, someone used by another window in the background) and substitutes it with the new color. Due to there arebeing limited room for colors in the system palette, the algorithm also tries also to remap similar colors together, and will always byavoid avoidingcreating redundant colors.
 
The final result depends on how many applications are workingtrying withto show their colors on screen colorsat the same time. The foreground window is always favored, so background windows at background may behave in different ways: from become corrupted to quickly redraw themselves. When the system palette changes, the system triggers a specific [[Event-driven programming|event]] to inform every application. When received, a window can quickly redraw itself using a single Win32 API function. But this must be doingdone explicitly in the program code; hence the fact that many programs lackfail into managehandle this event, and their windows will become corrupt in this situation.
 
An application can force the system palette to be loaded with specific colors and (even in a specific order), ''"tricking''" the system by telling it they are color entries intended for ''animation'' (quick color changes of the colors in the physical palette at specific entries). The system cannot assumewill then assume that everythose hardware palette entryentries isno longer are free for theirits palette color managements, and those entries are excluded from itsmanagement algorithm. The final result dependdepends on the skills of the color -forcing program and the behavior of the other programs (thealthough laststhis problem is the exactlysame as in the regular case), and that of the operating system in itself.
 
==See also==
Line 96 ⟶ 97:
 
==References==
* Julio Sanchez and Maria P. Canton (2003). ''[https://books.google.com/books?id=gZ5SDTpMR-MC&pg=PA756&dq=palette+intitle:%22The+PC+Graphics+Handbook%22&lrpg=&as_brr=0&ei=uaPHR7aKHqbutAOohely&sig=4UrkgNS_n3TkvwC1DQ5x91wzcv4PA756 The PC Graphics Handbook.]'' CRC Press. {{ISBN|0-8493-1678-2}}.
* [http://msdn.microsoft.com/en-us/library/dd183459(VS.85).aspx Color palettes at Microsoft Developer Network (MSDN)]
* [http://msdn.microsoft.com/en-us/library/dd162938%28VS.85%29.aspx The RGBQUAD color table entry in BITMAPINFO structure at Microsoft Developer Network (MSDN)]
Line 105 ⟶ 106:
[[Category:Computer graphics data structures]]
[[Category:Color depths]]
[[Category:ComputingComputer output devices]]
[[Category:Articles containing video clips]]