Sie sind auf Seite 1von 20

4/28/2008

Color image processing: g p g fundamentals

byGlebV.Tcheslavski:gleb@ee.lamar.edu http://ee.lamar.edu/gleb/dip/index.htm
Spring2008 ELEN4304/5365DIP 1

Preliminaries
Color image processing is motivated by two main factors: 1. Color is a powerful descriptor simplifying object recognition. 2. We can distinquish between thousands of color shades and intensities, compared to about 20-30 values of gray. There are two major areas of color image processing: 1. Full-color processing images are acquired with a full-color sensor (TV camera, color scanner); 2. 2 Pseudocolor processing colors are assigned to a particular monochrome intensity or intensity range. Many methods discussed for processing of monochrome images are applicable to color images; other methods need reformulation.
Spring2008 ELEN4304/5365DIP 2

4/28/2008

Fundamentals of color
Mechanisms of color processing by human brain are not completely understood. However, the physical nature of color can be formally expressed and modeled.

1666: Sir Isaac Newton managed to pass a beam of white light through a glass prism and got a rainbow on the other side where each color blends smoothly into the next.
Spring2008 ELEN4304/5365DIP 3

Fundamentals of color

Particular colors of the object as human perceive them are determined by the nature of light reflection properties of the object. A body reflecting light that is balanced in all visible wavelengths appears as white. A body reflecting more light in a particular range of wavelengths and absorbing light in other bands appears as colored. Note: creatures other than humans may (and do!) perceive colors in a completely different way than we do
Spring2008 ELEN4304/5365DIP 4

4/28/2008

Fundamentals of color
If the light is achromatic (no colors), its only attribute is its intensity (amount). Examples of achromatic light: images produced by a b&w TV set, monochrome pictures (not necessary b&w!) Our discussion set b&w!). so far was limited to achromatic images. Chromatic light spans the EM spectrum from approximately 400 to 700 nm. The three basic quantities used to describe a chromatic light source are radiance (the total amount of energy from the source, W), luminance (energy an observer perceives from the source, lm: for example, an observer might barely perceive any light from a source l b i h b l i li h f radiating in an infrared region), and brightness (a subjective descriptor practically impossible to measure since it is associated to both the intensity and color sensation).
Spring2008 ELEN4304/5365DIP 5

Fundamentals of color
Color sensitive sensors of human retina are cones. The total of 6-7 million of cones in a human eye can be associated 1965 with one of three groups: red (~575 nm) sensitive (about 65 % of all ) g cones), green (~535 nm 33%), and blue (~445 nm 2%) sensitive. Blue cones are the most sensitive.
Spring2008 ELEN4304/5365DIP 6

4/28/2008

Fundamentals of color
Due to the absorption characteristics of the human eye, we see colors as variable combinations of so-called primary colors of light: red (R), green (G), blue (B). The following wavelengths are designated to them in 1931: 700 nm, 546.1 nm, and 435.8 nm. A common misconception is that it is possible to get any desired visible color by properly mixing the primary colors! Note: this selection of primary colors is rather arbitrary: about every three colors whose wavelengths are far enough apart, can serve as colors, apart primary.

Spring2008

ELEN4304/5365DIP

Fundamentals of color
Speaking of arbitrary selection of primary colors count number of colors in two rainbows:

Eastern (Russian) version

Western version
Spring2008

and then find brown color


ELEN4304/5365DIP 8

4/28/2008

Fundamentals of color
Adding primary colors of light produces secondary colors: magenta (red + blue), cyan (green + blue), and yellow (green + red). Mixing the three primary colors of light (or a secondary with its opposite primary color) in the right intensities produces white light. Mixing together the three secondary colors of light, black (no light) can be produced. A primary color of pigment is a color that subtracts (or absorbs) a primary color of light and reflects (or transmits) the other two. Therefore, the primary colors of pigments are CMY.
Spring2008 ELEN4304/5365DIP 9

Fundamentals of color
CRT or LCD monitors are good examples of mixing light colors where three primary colors (RGB) are mixed (added) to form light of the particular color (either via the three gloving dots of different luminophore or via the three light beams of different color). Color printers are examples of mixing (adding) light pigments. Colors are usually distinguished from each other through the three characteristics: brightness, hue, and saturation. As mentioned before, before brightness embodies achromatic intensity. Hue represents the intensity dominant color as perceived by an observer (red, yellow, blue). Saturation is the amount of white added to a hue (purity of the color). For example, we need to specify saturation to characterize pink (red + white).
Spring2008 ELEN4304/5365DIP 10

4/28/2008

Fundamentals of color
Hue and saturation together are called chromaticity. A color may also be characterized by its brightness and chromaticity. The amounts of red, green, and blue needed to form any particular color are called the tristimulus values and are denoted as X, Y, Z. therefore, a color is specified by its trichromatic coefficients:

x=

X Y Z , y= , z= X +Y + Z X +Y + Z X +Y + Z

We notice that

x + y + z =1

The tristimulus values needed to produce a color of particular wavelength can be obtained from the tables.
Spring2008 ELEN4304/5365DIP 11

Fundamentals of color
Another way to specify colors is by using the CIE (chromaticity diagram), which shows a color composition as a function of x (red) and y (green). For any values of x and y, the corresponding value of z (blue) can be found as

z = 1 x y

Spring2008

ELEN4304/5365DIP

12

4/28/2008

Fundamentals of color
The point marked as green has approximately 62 % green and 25 % red. Therefore, it has about 13 % of blue. The positions of different colors (from violet at 380 nm to red at 700 nm) are indicated by the wavelengths around the boundary of the chromaticity diagram. They are the pure colors. Any point not on the boundary represent some mixture of spectrum colors.
Spring2008 ELEN4304/5365DIP 13

Fundamentals of color
The white point in the middle of CIE is called the point of equal energy h equal fractions of the has lf i f h three primary colors: CIE standard for white light. Any point along the boundary is fully saturated. When leaving the boundary, some amount of white light is added to form the color. The saturation at the point of equal energy is zero.

Spring2008

ELEN4304/5365DIP

14

4/28/2008

Fundamentals of color
A straight line joining any two points in the diagram defines all the diff h different color variations that l i i h can be obtained by combining these two colors additively. A line drawn from the point of equal energy to any point on the boundary defines all the shades of that particular color.

Spring2008

ELEN4304/5365DIP

15

Fundamentals of color
Extending this procedure to the three (primary) colors, we need to f form a triangle, whose apexes i l h are the three primary colors. Any color at the boundary or inside the triangle can be produced by various combinations of the three initial colors. colors Therefore, not all colors can be obtained from three fixed primaries.
Spring2008 ELEN4304/5365DIP 16

4/28/2008

Fundamentals of color
A typical range of colors (color gamut) produced by RGB monitors. i The irregular region inside the triangle represents the color gamut of the high-quality color printers. The region is irregular since color printing involves a combination of additive and subtractive color mixing.

Spring2008

ELEN4304/5365DIP

17

Fundamentals of color
CRT
monitor i

Spring2008

ELEN4304/5365DIP

18

4/28/2008

Fundamentals of color
LCD
Monitor M i (projector)

Spring2008

ELEN4304/5365DIP

19

Color models
A color model (color space or color system) is a specification of a coordinate system and a subspace within that system where each y p y color is represented by a single point. Most contemporary color models are oriented either toward hardware (color monitors and printers) or toward applications where color manipulation is used (color graphics for animation). The most commonly used in Image Processing practice models are RGB (monitors, most of cameras), CMY and CMYK (printers), and ( it t f ) d ( i t ) d HIS (closely correspond to the human visual system.

Spring2008

ELEN4304/5365DIP

20

10

4/28/2008

RGB color model


The RGB (red, green, blue) color model is based on a Cartesian coordinate system. The color subspace is a cube, in which RGB primary values are at the three corners; the secondary colors (cyan, magenta, and yellow) are at three other corners; black is at the origin; and white is at the farthest from the origin corner. The gray scale (points of equal RGB values) extends from black to white along the straight line. Different colors are points on or inside the cube and are defined by vectors extending from the origin. All values of R, G, and B are normalized and are assumed to be in the range [0,1].
Spring2008 ELEN4304/5365DIP 21

RGB color model


Images represented in the RGB model consist of three component images (one for each primary color) that are combined into a composite color image. it l i The number of bits used to represent a pixel is called the pixel depth. Assuming that each component image uses 8 bits, each RGB color pixel is said to have a depth of 24 bits. Such RGB color images are frequently called full-color images. The total number of colors in a 24-bit color image is

(2 )

8 3

= 16 777 216
ELEN4304/5365DIP 22

Spring2008

11

4/28/2008

RGB color model


A convenient way to view these colors is to generate color planes (faces of color sections of the cube). To do this, one color is fixed while two other are varying. In the component images, 0 represents i black and 255 is white. An RGB image can be viewed by feeding the component images to a color monitor.
Spring2008 ELEN4304/5365DIP 23

Cross-sectional plane (127,G,B); G, G B = [0 255]

RGB color model


Acquiring color images can be accomplished by reversing the procedure: the scene can be sensed through red, green, and blue filt consequently to record component images. tl t d ti filters

The three hidden surfaces of the color cube.

Spring2008

ELEN4304/5365DIP

24

12

4/28/2008

RGB color model


Some of the hardware used for color image reproduction is limited to 256 colors. Only 216 of these colors are common to most systems (the t i (th rest is processed differently). These colors became the de facto d diff tl ) Th l b th d f t all-systems-safe colors. Each of them is formed from three RGB values but each value is limited to [0, 51, 102, 153, 204, 255] or in the hexagonal system [00 33 66 99 CC FF]. Since three numbers specify an RGB color, each safe color is formed from three of the two-digit hexagonal numbers: the purest red would be (FF 00 00), black is (00 00 00), and white is (FF FF FF). The decimal equivalents are (255 0 0), (0 0 0), and (255 255 255).

Spring2008

ELEN4304/5365DIP

25

RGB color model


The 216 safe colors: the left top square is (FF FF FF) th FF), the next (FF FF CC), etc. The second raw is (FF CC FF), (FF CC CC), etc.

Spring2008

ELEN4304/5365DIP

26

13

4/28/2008

RGB color model

Full color cube


Spring2008

Safe color cube (sampled)


ELEN4304/5365DIP 27

CMY and CMYK color models


Cyan, magenta, and yellow are the secondary colors of light (or the primary colors of pigments). Most color printing devices use CMY model. The conversion from RGB is done by: d l Th i f i d b

C 1 R M = 1 G Y 1 B
Equal amount of three pigments must produce black. This approach q pg p pp is not very practical and leads to a muddy-looking black. To produce a true black (predominant color in printing), a fourth color black is added to the color model to make a CMYK model.

Spring2008

ELEN4304/5365DIP

28

14

4/28/2008

HSI color model


While RGB and CMY color models are well suited for hardware implementations, these models do not fit well human perception of colors since we describe colors by their hue, saturation, and hue saturation brightness. Therefore, the hue, saturation, intensity (HSI) model was developed, where the intensity component is independent from color information. The intensity axis goes from black to white and can be computed as

I=
Spring2008

R+G+ B 3
ELEN4304/5365DIP 29

HSI color model


Considering the triangle with apexes of Black, White, and any color point (Cyan, f.i.), we notice that all points on the triangle have the same hue. Rotating the plane about the intensity axis, we can obtain different hues.

H = 360
Where
= cos 1

if B G if B > G
2 2 ( R G ) + ( R B )( G B )
30

( R G) + ( R B)

A small number often is added to the denominator to avoid dividing by zero. Zero angle corresponds to red here. If RGB values are normalized, hue is divided by 3600.
Spring2008 ELEN4304/5365DIP

15

4/28/2008

HSI color model


The HSI space is represented by a vertical intensity axis and the locus of color points that lie on planes perpendicular to this axis. As the planes move up and down the intensity axis, the boundaries have axis either a triangular or hexagonal shape. Primary colors are separated by 1200 while the secondary are 600 from primaries. Therefore, the hue of the point can be f h i b determined by an angle from some reference point (as shown previously)
Spring2008 ELEN4304/5365DIP 31

HSI color model


Saturation (distance from the vertical axis) is the length of the vector from the origin to the point:

S = 1

3 [ min( R, G, B)] R+G + B

The important components of the HSI model are the vertical intensity axis, the length of the vector to the color point, and the angle of that vector. HSI planes are defined as hexagons, triangles, or circles. The shape does not matter!
Spring2008 ELEN4304/5365DIP 32

16

4/28/2008

Converting colors from HSI to RGB


Assuming that HSI values are normalized (in the interval [0 1]), conversion to RBG depends on the H value and is different for the three sectors First we multiply H by 3600. sectors. First, 1. RG sector: 0 H 120

S cos H R = I 1 + cos ( 60 H ) G = 3I ( R + B ) B = I (1 S )
Spring2008 ELEN4304/5365DIP 33

Converting colors from HSI to RGB


2. GB sector: 120 H 240

H = H 120 R = I (1 S ) S cos H G = I 1 + cos ( 60 H ) B = 3I ( R + G )

Spring2008

ELEN4304/5365DIP

34

17

4/28/2008

Converting colors from HSI to RGB


3. BR sector: 240 H 360

H = H 240 R = 3I ( G + B ) G = I (1 S ) S cos H B = I 1 + cos ( 60 H )

Spring2008

ELEN4304/5365DIP

35

Converting colors from HSI to RGB


Original color cube

Its hue component: the discontinuity


Spring2008

Its saturation component


ELEN4304/5365DIP

Its intensity component


36

18

4/28/2008

Manipulating HSI component images


Color image showing g primary and secondary colors Its hue component image: red is mapped to black

Its saturation component image

Its intensity y component image

Spring2008

ELEN4304/5365DIP

37

Manipulating HSI component images


To change the color in any region, we change the values in the corresponding region in the hue image; then convert the new H di i i th h i th t th image with the unchanged S and I images back to RGB image. To change the saturation (purity) in any region, we follow the same procedure except that we change the saturation image. Similarly, Similarly intensity in a region can be chabged chabged.

Spring2008

ELEN4304/5365DIP

38

19

4/28/2008

Manipulating HSI component images


Modified hue component image: blue and green regions are set to 0 Modified intensity component image: white region was reduced by half
Spring2008 ELEN4304/5365DIP

Modified saturation component t image: cyan region is reduced by half Resultant RGB image

39

20

Das könnte Ihnen auch gefallen