Colorspace
   HOME

TheInfoList



OR:

A color space is a specific organization of
color Color (or colour in English in the Commonwealth of Nations, Commonwealth English; American and British English spelling differences#-our, -or, see spelling differences) is the visual perception based on the electromagnetic spectrum. Though co ...
s. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a
digital Digital usually refers to something using discrete digits, often binary digits. Businesses *Digital bank, a form of financial institution *Digital Equipment Corporation (DEC) or Digital, a computer company *Digital Research (DR or DRI), a software ...
representation. A color space may be arbitrary, i.e. with physically realized colors assigned to a set of physical color swatches with corresponding assigned color names (including discrete numbers infor examplethe Pantone collection), or structured with mathematical rigor (as with the NCS System, Adobe RGB and
sRGB sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996 and became an official standard of the International Electrotechnical Commission (IEC) as IEC 6 ...
). A "color space" is a useful conceptual tool for understanding the color capabilities of a particular device or digital file. When trying to reproduce color on another device, color spaces can show whether shadow/highlight detail and color saturation can be retained, and by how much either will be compromised. A "
color model In color science, a color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components. When this model is associated with a precise description ...
" is an abstract mathematical model describing the way colors can be represented as
tuple In mathematics, a tuple is a finite sequence or ''ordered list'' of numbers or, more generally, mathematical objects, which are called the ''elements'' of the tuple. An -tuple is a tuple of elements, where is a non-negative integer. There is o ...
s of numbers (e.g. triples in RGB or quadruples in
CMYK The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
); however, a color model with no associated mapping function to an absolute color space is a more or less arbitrary color system with no connection to any globally understood system of color interpretation. Adding a specific mapping function between a color model and a reference color space establishes within the reference color space a definite "footprint", known as a
gamut In color reproduction and colorimetry, a gamut, or color gamut , is a convex set containing the colors that can be accurately represented, i.e. reproduced by an output device (e.g. printer or display) or measured by an input device (e.g. cam ...
, and for a given color model, this defines a color space. For example, Adobe RGB and sRGB are two different absolute color spaces, both based on the RGB color model. When defining a color space, the usual reference standard is the
CIELAB The CIELAB color space, also referred to as ''L*a*b*'', is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. It expresses color as three values: ''L*'' for perceptual lightness and ''a*'' and ''b* ...
or
CIEXYZ In 1931, the International Commission on Illumination (CIE) published the CIE 1931 color spaces which define the relationship between the visible spectrum and human color vision. The CIE color spaces are mathematical models that comprise a "stan ...
color spaces, which were specifically designed to encompass all colors the average human can see. Since "color space" identifies a particular combination of the color model and the mapping function, the word is often used informally to identify a color model. However, even though identifying a color space automatically identifies the associated color model, this usage is incorrect in a strict sense. For example, although several specific color spaces are based on the
RGB color model The RGB color model is an additive color, additive color model in which the red, green, and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials ...
, there is no such thing as the singular RGB color space.


History

In 1802, Thomas Young postulated the existence of three types of photoreceptors (now known as
cone cell Cone cells or cones are photoreceptor cells in the retina of the vertebrate eye. Cones are active in daylight conditions and enable photopic vision, as opposed to rod cells, which are active in dim light and enable scotopic vision. Most v ...
s) in the eye, each of which was sensitive to a particular range of visible light.
Hermann von Helmholtz Hermann Ludwig Ferdinand von Helmholtz (; ; 31 August 1821 – 8 September 1894; "von" since 1883) was a German physicist and physician who made significant contributions in several scientific fields, particularly hydrodynamic stability. The ...
developed the
Young–Helmholtz theory The Young–Helmholtz theory (based on the work of Thomas Young and Hermann von Helmholtz in the 19th century), also known as the trichromatic theory, is a theory of trichromatic color vision – the manner in which the visual system gives rise ...
further in 1850: that the three types of cone photoreceptors could be classified as short-preferring (
blue Blue is one of the three primary colours in the RYB color model, RYB colour model (traditional colour theory), as well as in the RGB color model, RGB (additive) colour model. It lies between Violet (color), violet and cyan on the optical spe ...
), middle-preferring (
green Green is the color between cyan and yellow on the visible spectrum. It is evoked by light which has a dominant wavelength of roughly 495570 nm. In subtractive color systems, used in painting and color printing, it is created by a com ...
), and long-preferring ( red), according to their response to the
wavelength In physics and mathematics, wavelength or spatial period of a wave or periodic function is the distance over which the wave's shape repeats. In other words, it is the distance between consecutive corresponding points of the same ''phase (waves ...
s of light striking the
retina The retina (; or retinas) is the innermost, photosensitivity, light-sensitive layer of tissue (biology), tissue of the eye of most vertebrates and some Mollusca, molluscs. The optics of the eye create a focus (optics), focused two-dimensional ...
. The relative strengths of the signals detected by the three types of cones are interpreted by the
brain The brain is an organ (biology), organ that serves as the center of the nervous system in all vertebrate and most invertebrate animals. It consists of nervous tissue and is typically located in the head (cephalization), usually near organs for ...
as a visible color. But it is not clear that they thought of colors as being points in color space. The color-space concept was likely due to
Hermann Grassmann Hermann Günther Grassmann (, ; 15 April 1809 – 26 September 1877) was a German polymath known in his day as a linguist and now also as a mathematician. He was also a physicist, general scholar, and publisher. His mathematical work was littl ...
, who developed it in two stages. First, he developed the idea of
vector space In mathematics and physics, a vector space (also called a linear space) is a set (mathematics), set whose elements, often called vector (mathematics and physics), ''vectors'', can be added together and multiplied ("scaled") by numbers called sc ...
, which allowed the algebraic representation of geometric concepts in ''n''-dimensional
space Space is a three-dimensional continuum containing positions and directions. In classical physics, physical space is often conceived in three linear dimensions. Modern physicists usually consider it, with time, to be part of a boundless ...
.''Hermann Grassmann and the Creation of Linear Algebra''
/ref> Fearnley-Sander (1979) describes Grassmann's foundation of linear algebra as follows: With this conceptual background, in 1853, Grassmann published a theory of how colors mix; it and its three color laws are still taught, as
Grassmann's law Grassmann's law, named after its discoverer Hermann Grassmann, is a dissimilatory phonological process in Ancient Greek and Sanskrit which states that if an Aspiration (phonetics), aspirated consonant is followed by another aspirated consonant ...
.


Examples

Colors can be created in
printing Printing is a process for mass reproducing text and images using a master form or template. The earliest non-paper products involving printing include cylinder seals and objects such as the Cyrus Cylinder and the Cylinders of Nabonidus. The ...
with
color Color (or colour in English in the Commonwealth of Nations, Commonwealth English; American and British English spelling differences#-our, -or, see spelling differences) is the visual perception based on the electromagnetic spectrum. Though co ...
spaces based on the
CMYK color model The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
, using the subtractive primary colors of
pigment A pigment is a powder used to add or alter color or change visual appearance. Pigments are completely or nearly solubility, insoluble and reactivity (chemistry), chemically unreactive in water or another medium; in contrast, dyes are colored sub ...
( cyan, magenta, yellow, and key nowiki/>black">black.html" ;"title="nowiki/>black">nowiki/>black. To create a three-dimensional representation of a given color space, we can assign the amount of magenta color to the representation's X coordinate axis">axis An axis (: axes) may refer to: Mathematics *A specific line (often a directed line) that plays an important role in some contexts. In particular: ** Coordinate axis of a coordinate system *** ''x''-axis, ''y''-axis, ''z''-axis, common names ...
, the amount of cyan to its Y axis, and the amount of yellow to its Z axis. The resulting 3-D space provides a unique position for every possible color that can be created by combining those three pigments. Colors can be created on computer monitors with color spaces based on the
RGB color model The RGB color model is an additive color, additive color model in which the red, green, and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials ...
, using the additive primary colors ( red,
green Green is the color between cyan and yellow on the visible spectrum. It is evoked by light which has a dominant wavelength of roughly 495570 nm. In subtractive color systems, used in painting and color printing, it is created by a com ...
, and
blue Blue is one of the three primary colours in the RYB color model, RYB colour model (traditional colour theory), as well as in the RGB color model, RGB (additive) colour model. It lies between Violet (color), violet and cyan on the optical spe ...
). A three-dimensional representation would assign each of the three colors to the X, Y, and Z axes. Colors generated on a given monitor will be limited by the reproduction medium, such as the phosphor (in a
CRT monitor A cathode-ray tube (CRT) is a vacuum tube containing one or more electron guns, which emit electron beams that are manipulated to display images on a phosphorescent screen. The images may represent electrical waveforms on an oscilloscope, ...
) or filters and backlight (
LCD A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device that uses the light-modulating properties of liquid crystals combined with polarizers to display information. Liquid crystals do not em ...
monitor). Another way of creating colors on a monitor is with an HSL or HSV color model, based on hue, saturation,
brightness Brightness is an attribute of visual perception in which a source appears to be radiating/reflecting light. In other words, brightness is the perception dictated by the luminance of a visual target. The perception is not linear to luminance, and ...
(value/lightness). With such a model, the variables are assigned to
cylindrical coordinates A cylinder () has traditionally been a three-dimensional solid, one of the most basic of curvilinear geometric shapes. In elementary geometry, it is considered a prism with a circle as its base. A cylinder may also be defined as an infinite ...
. Many color spaces can be represented as three-dimensional values in this manner, but some have more, or fewer dimensions, and some, such as Pantone, cannot be represented in this way at all.


Conversion

Color space conversion is the translation of the representation of a color from one basis to another. This typically occurs in the context of converting an image that is represented in one color space to another color space, the goal being to make the translated image look as similar as possible to the original.


RGB density

The RGB color model is implemented in different ways, depending on the capabilities of the system used. The most common incarnation in general use is the 24- bit implementation, with 8 bits, or 256 discrete levels of color per channel. Any color space based on such a 24-bit RGB model is thus limited to a range of 256×256×256 ≈ 16.7 million colors. Some implementations use 16 bits per component for 48 bits total, resulting in the same
gamut In color reproduction and colorimetry, a gamut, or color gamut , is a convex set containing the colors that can be accurately represented, i.e. reproduced by an output device (e.g. printer or display) or measured by an input device (e.g. cam ...
with a larger number of distinct colors. This is especially important when working with wide-gamut color spaces (where most of the more common colors are located relatively close together), or when a large number of digital filtering algorithms are used consecutively. The same principle applies for any color space based on the same color model, but implemented at different bit depths.


Lists

CIE 1931 XYZ color space was one of the first attempts to produce a color space based on measurements of human color perception (earlier efforts were by
James Clerk Maxwell James Clerk Maxwell (13 June 1831 – 5 November 1879) was a Scottish physicist and mathematician who was responsible for the classical theory of electromagnetic radiation, which was the first theory to describe electricity, magnetism an ...
, König & Dieterici, and Abney at Imperial College)William David Wright, ''50 years of the 1931 CIE Standard Observer''. Die Farbe, 29:4/6 (1981). and it is the basis for almost all other color spaces. The CIERGB color space is a linearly-related companion of CIE XYZ. Additional derivatives of CIE XYZ include the CIELUV, CIEUVW, and
CIELAB The CIELAB color space, also referred to as ''L*a*b*'', is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. It expresses color as three values: ''L*'' for perceptual lightness and ''a*'' and ''b* ...
.


Generic

RGB uses
additive color Additive color or additive mixing is a property of a color model that predicts the appearance of colors made by coincident component lights, i.e. the perceived color can be predicted by summing the numeric representations of the component col ...
mixing, because it describes what kind of ''light'' needs to be ''emitted'' to produce a given color. RGB stores individual values for red, green and blue. RGBA is RGB with an additional channel, alpha, to indicate transparency. Common color spaces based on the RGB model include
sRGB sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996 and became an official standard of the International Electrotechnical Commission (IEC) as IEC 6 ...
, Adobe RGB, ProPhoto RGB, scRGB, and CIE RGB.
CMYK The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
uses
subtractive color Subtractive color or subtractive color mixing predicts the spectral power distribution of light after it passes through successive layers of partially absorbing media. This idealized model is the essential principle of how dyes and pigments are ...
mixing used in the printing process, because it describes what kind of inks need to be applied so the light ''reflected'' from the substrate and through the inks produces a given color. One starts with a white substrate (canvas, page, etc.), and uses ink to subtract color from white to create an image. CMYK stores ink values for cyan, magenta, yellow and black. There are many CMYK color spaces for different sets of inks, substrates, and press characteristics (which change the dot gain or transfer function for each ink and thus change the appearance).
YIQ YIQ is the color space used by the analog NTSC color TV system. ''I'' stands for ''in-phase'', while ''Q'' stands for ''quadrature'', referring to the components used in quadrature amplitude modulation. Other TV systems used different color spa ...
was formerly used in
NTSC NTSC (from National Television System Committee) is the first American standard for analog television, published and adopted in 1941. In 1961, it was assigned the designation System M. It is also known as EIA standard 170. In 1953, a second ...
(
North America North America is a continent in the Northern Hemisphere, Northern and Western Hemisphere, Western hemispheres. North America is bordered to the north by the Arctic Ocean, to the east by the Atlantic Ocean, to the southeast by South Ameri ...
,
Japan Japan is an island country in East Asia. Located in the Pacific Ocean off the northeast coast of the Asia, Asian mainland, it is bordered on the west by the Sea of Japan and extends from the Sea of Okhotsk in the north to the East China Sea ...
and elsewhere) television broadcasts for historical reasons. This system stores a luma value roughly analogous to (and sometimes incorrectly identified as)
luminance Luminance is a photometric measure of the luminous intensity per unit area of light travelling in a given direction. It describes the amount of light that passes through, is emitted from, or is reflected from a particular area, and falls wit ...
, along with two chroma values as approximate representations of the relative amounts of blue and red in the color. It is similar to the YUV scheme used in most video capture systems and in
PAL Phase Alternating Line (PAL) is a color encoding system for analog television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
(
Australia Australia, officially the Commonwealth of Australia, is a country comprising mainland Australia, the mainland of the Australia (continent), Australian continent, the island of Tasmania and list of islands of Australia, numerous smaller isl ...
,
Europe Europe is a continent located entirely in the Northern Hemisphere and mostly in the Eastern Hemisphere. It is bordered by the Arctic Ocean to the north, the Atlantic Ocean to the west, the Mediterranean Sea to the south, and Asia to the east ...
, except
France France, officially the French Republic, is a country located primarily in Western Europe. Overseas France, Its overseas regions and territories include French Guiana in South America, Saint Pierre and Miquelon in the Atlantic Ocean#North Atlan ...
, which uses
SECAM SECAM, also written SÉCAM (, ''Séquentiel de couleur à mémoire'', French for ''sequential colour memory''), is an analog color television system that was used in France, Russia and some other countries or territories of Europe and Africa. ...
) television, except that the YIQ color space is rotated 33° with respect to the YUV color space and the color axes are swapped. The
YDbDr YDbDr, sometimes written YD_BD_R, is the colour space used in the SECAM (adopted in France and some countries of the former Eastern Bloc) analog colour television broadcasting standard. It is very close to YUV (used on the PAL system) and it ...
scheme used by SECAM television is rotated in another way. YPbPr is a scaled version of YUV. It is most commonly seen in its digital form,
YCbCr YCbCr, Y′CbCr, also written as YCBCR or Y′CBCR, is a family of color spaces used as a part of the color image pipeline in digital video and digital photography, photography systems. Like YPbPr, YPBPR, it is based on RGB primaries; the two ...
, used widely in
video Video is an Electronics, electronic medium for the recording, copying, playback, broadcasting, and display of moving picture, moving image, visual Media (communication), media. Video was first developed for mechanical television systems, whi ...
and
image compression Image compression is a type of data compression applied to digital images, to reduce their cost for computer data storage, storage or data transmission, transmission. Algorithms may take advantage of visual perception and the statistical properti ...
schemes such as
MPEG The Moving Picture Experts Group (MPEG) is an alliance of working groups established jointly by International Organization for Standardization, ISO and International Electrotechnical Commission, IEC that sets standards for media coding, includ ...
and
JPEG JPEG ( , short for Joint Photographic Experts Group and sometimes retroactively referred to as JPEG 1) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degr ...
. xvYCC is a new international digital video color space standard published by the IEC (IEC 61966-2-4). It is based on the ITU BT.601 and BT.709 standards but extends the gamut beyond the R/G/B primaries specified in those standards. HSV (hue, saturation, value), also known as HSB (hue, saturation, brightness) is often used by artists because it is often more natural to think about a color in terms of hue and saturation than in terms of additive or subtractive color components. HSV is a transformation of an RGB color space, and its components and colorimetry are relative to the RGB color space from which it was derived. HSL (hue, saturation, lightness/luminance), also known as HLS or HSI (hue, saturation, intensity) is quite similar to HSV, with "lightness" replacing "brightness". The difference is that the ''brightness'' of a pure color is equal to the brightness of white, while the ''lightness'' of a pure color is equal to the lightness of a medium gray.


Commercial

*
Munsell color system The Munsell color system is a color space that specifies colors based on three properties of color: hue (basic color), value (lightness), and colorfulness, chroma (color intensity). It was created by Albert Henry Munsell, Albert H. Munsell in the ...
* Pantone Matching System (PMS) * Natural Color System (NCS)


Special-purpose

* The RG Chromaticity space is used in
computer vision Computer vision tasks include methods for image sensor, acquiring, Image processing, processing, Image analysis, analyzing, and understanding digital images, and extraction of high-dimensional data from the real world in order to produce numerical ...
applications. It shows the color of light (red, yellow, green etc.), but not its intensity (dark, bright). * The TSL color space (Tint, Saturation and Luminance) is used in face detection.


Obsolete

Early color spaces had two components. They largely ignored blue light because the added complexity of a 3-component process provided only a marginal increase in fidelity when compared to the jump from monochrome to 2-component color. * RG for early
Technicolor Technicolor is a family of Color motion picture film, color motion picture processes. The first version, Process 1, was introduced in 1916, and improved versions followed over several decades. Definitive Technicolor movies using three black-and ...
film * RGK for early color printing


Absolute color space

In
color science Color science is the science, scientific study of color including lighting and optics; Photometry (optics), measurement of light and colorimetry, color; the physiology, psychophysics, and color model, modeling of color vision; and color reproductio ...
, there are two meanings of the term absolute color space: * A color space in which the perceptual difference between colors is directly related to distances between colors as represented by points in the color space, i.e. a
uniform color space A color appearance model (CAM) is a mathematical model that seeks to describe the perceptual aspects of human color vision, i.e. viewing conditions under which the appearance of a color does not tally with the corresponding physical measurement o ...
. * A color space in which colors are unambiguous, that is, where the interpretations of colors in the space are colorimetrically defined without reference to external factors. In this article, we concentrate on the second definition.
CIEXYZ In 1931, the International Commission on Illumination (CIE) published the CIE 1931 color spaces which define the relationship between the visible spectrum and human color vision. The CIE color spaces are mathematical models that comprise a "stan ...
,
sRGB sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996 and became an official standard of the International Electrotechnical Commission (IEC) as IEC 6 ...
, and
ICtCp ''ICTCP'', ''ICtCp'', or ''ITP'' is a color representation format specified in the Rec. ITU-R BT.2100 standard that is used as a part of the color image pipeline in video and digital photography systems for high dynamic range (HDR) and wide c ...
are examples of absolute color spaces, as opposed to a generic RGB color space. A non-absolute color space can be made absolute by defining its relationship to absolute colorimetric quantities. For instance, if the red, green, and blue colors in a monitor are measured exactly, together with other properties of the monitor, then RGB values on that monitor can be considered as absolute. The CIE 1976 L*, a*, b* color space is sometimes referred to as absolute, though it also needs a white point specification to make it so. A popular way to make a color space like RGB into an absolute color is to define an ICC profile, which contains the attributes of the RGB. This is not the only way to express an absolute color, but it is the standard in many industries. RGB colors defined by widely accepted profiles include sRGB and Adobe RGB. The process of adding an
ICC profile In color management, an ICC profile is a set of data that characterizes a color input or output device, or a color space, according to standards promulgated by the International Color Consortium (ICC). Profiles describe the color attributes o ...
to a graphic or document is sometimes called ''tagging'' or ''embedding''; tagging, therefore, marks the absolute meaning of colors in that graphic or document.


Conversion errors

A color in one absolute color space can be converted into another absolute color space, and back again, in general; however, some color spaces may have
gamut In color reproduction and colorimetry, a gamut, or color gamut , is a convex set containing the colors that can be accurately represented, i.e. reproduced by an output device (e.g. printer or display) or measured by an input device (e.g. cam ...
limitations, and converting colors that lie outside that gamut will not produce correct results. There are also likely to be rounding errors, especially if the popular range of only 256 distinct values per component (
8-bit color 8-bit color graphics are a method of storing image information in a computer's memory or in an image file, so that each pixel is represented by 8 bits (1 byte). The maximum number of colors that can be displayed at any one time is 256 per pixel or ...
) is used. One part of the definition of an absolute color space is the viewing conditions. The same color, viewed under different natural or artificial
lighting Lighting or illumination is the deliberate use of light to achieve practical or aesthetic effects. Lighting includes the use of both artificial light sources like lamps and light fixtures, as well as natural illumination by capturing daylight. ...
conditions, will look different. Those involved professionally with color matching may use viewing rooms, lit by standardized lighting. Occasionally, there are precise rules for converting between non-absolute color spaces. For example,
HSL and HSV HSL and HSV are the two most common cylindrical coordinate system, cylindrical-coordinate representations of points in an RGB color model. The two representations rearrange the geometry of RGB in an attempt to be more intuitive and color vision, ...
spaces are defined as mappings of RGB. Both are non-absolute, but the conversion between them should maintain the same color. However, in general, converting between two non-absolute color spaces (for example, RGB to
CMYK The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
) or between absolute and non-absolute color spaces (for example, RGB to L*a*b*) is almost a meaningless concept.


Arbitrary spaces

A different method of defining absolute color spaces is familiar to many consumers as the swatch card, used to select paint, fabrics, and the like. This is a way of agreeing a color between two parties. A more standardized method of defining absolute colors is the
Pantone Matching System Pantone LLC (stylized as PANTONE) is an American limited liability company headquartered in Carlstadt, New Jersey, and best known for its Pantone Matching System (PMS), a proprietary color order system used in a variety of industries, notably gr ...
, a proprietary system that includes swatch cards and recipes that commercial printers can use to make inks that are a particular color.


See also

* * * * * *


References


External links


Color FAQ
Charles Poynton

Dan Bruton
Color Spaces
Rolf G. Kuehni (October 2003)
Colour spaces – perceptual, historical and applicational background
Marko Tkalčič (2003)

for image and video processing

between RGB, YUV, YCbCr and YPbPr.
PixFC-SSE
C library of SSE-optimised color format conversions. * Konica Minolta Sensing

* Higham, Nicholas J.
''Color Spaces and Digital Imaging''
from The Princeton Companion to Applied Mathematics {{Compression methods Color schemes Image processing Photometry 1853 introductions Data compression