Digital Image Processing
Week 5
Digital Image Processing
Week 5
Color Image Processing Color Image Processing Color Image Processing
Color is very important characteristic of an image that in most cases simplifies object identification and extraction form a scene. Human eye can discern thousands of color shades and intensities and only two dozen shades of gray.
Color image processing is divided in 2 major areas: full-color (images acquired with a full-color sensor) and pseudo-color (gray images for which color is assigned) processing.
The colors that humans can perceive in an object are determined by the nature of the light reflected from the object. Visible light is composed of a relatively narrow band of frequencies in the electromagnetic spectrum (390nm to750nm).
Digital Image Processing
Week 5
A body that reflects light that is balanced in all visible wavelengths appears white to the observer. A body that favors reflectance in a limited range of the visible spectrum exhibits some shades of color.
For example, blue objects reflect light with wavelengths from 450 to 475 nm, while absorbing most of the energy of other wavelengths.
Digital Image Processing
Week 5
How to characterize light? If the light is achromatic (void of color) its only attribute is its intensity (or amount) – determined by levels of gray (black-grays- white).
Chromatic light spans the electromagnetic spectrum from approximately 400 to 720 nm. Three basic quantities are used to describe the quality of a chromatic light source: radiance, luminance, and brightness.
- Radiance is the total amount of energy that flows from the light source (usually measured in watts).
- Luminance (measured in lumens – lm) gives a measure of the amount of energy an observer perceives from a light source. For example, the light emitted from a source operating in the infrared region of the spectrum could
Digital Image Processing
Week 5
have significant energy (radiance), but an observer would hardly perceive it (the luminance is almost zero).
- Brightness is a subjective descriptor that cannot be measured, it embodies the achromatic notion of intensity and is a factor describing color sensation.
Cones are the sensors in the eye responsible for color vision. It has been established that the 6 to 7 million cones in the human eye can be divided into three principal sensing categories, corresponding roughly to red, green, and blue.
Approximately 65% of all cones are sensitive to red light, 33% are sensitive to green light, an only about 2% are sensitive to blue (but the blue cones are the most sensitive).
Digital Image Processing
Week 5
Due to these absorption characteristics of the human eye, colors are seen as variable combinations of the so-called primary colors: red (R), green (G), and blue (B).
Digital Image Processing
Week 5
For the purpose of standardization, the CIE (Commission Internationale de l’Eclairage) designated in 1931 the following specific wavelength values to the three primary colors: blue= 435.8 nm, green = 546.1 nm, and red=700 nm. The CIE standards correspond only approximately with experimental data.
These three standard primary colors, when mixed in various intensity proportions, can produce all visible colors.
The primary colors can be added to produce the secondary colors of light – magenta (red+blue), cyan (green+blue), and yellow (red+green). Mixing the three primaries, or a secondary with its opposite primary color in the right intensities produces white light.
We must differentiate between the primary colors of light and the primary colors of pigments. A primary color for pigments is one that subtracts or absorb a
Digital Image Processing
Week 5
primary color of light and reflects or transmits the other two. Therefore, the primary colors of pigments are magenta, cyan, and yellow, and the secondary colors are red, green, and blue.
Digital Image Processing
Week 5
The characteristics usually used to distinguish one color from another are brightness, hue, and saturation.
Brightness embodies the achromatic notion of intensity. Hue is an attribute associated with the dominant wavelength in a mixture of light waves. Hue represents dominant color as perceived by an observer (when we call an object to be red, orange or yellow we refer to its hue). Saturation refers to the relative purity or the amount of white light mixed with a hue. The pure spectrum colors are fully saturated. Color such as pink (red+white) and lavender (violet+white) are less saturated, with the degree of saturation being inversely proportional to the amount of white light added.
Hue and saturation taken together are called chromaticity, and therefore a color may be characterized by its brightness and chromaticity.
Digital Image Processing
Week 5
The amounts of red, green, and blue needed to form any particular color are called the tristimulus values and are denoted X, Y and Z, respectively. A color is specified by its trichromatic coefficients, defined as:
x X
X Y Z
= + +
y Y
X Y Z
= + +
z Z
X Y Z
= + +
1
x + + = y z
Digital Image Processing
Week 5
For any wavelength of light in the visible spectrum, the tristimulus values needed to produce the color corresponding to that wavelength can be obtained from the existing curves or tables.
Another approach for specifying colors is to use the CIE chromaticity diagram, which shows color composition as a function of x (red) and y (green);
z (blue) is obtained from relation z = 1-x-y.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
The positions of the various spectrum colors (from violet at 380 nm to red at 780 nm) are indicated around the boundary of the tongue-shaped chromaticity diagram.
The chromaticity diagram is useful for color mixing because a straight-line segment joining any two points in the diagram defines all the different color variation that can be obtained by combining these two colors. This procedure can be extended to three colors: to triangle determined by the three color-points on the diagram embodies all the possible colors that can be obtained by mixing the three colors.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
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 color is represented by a single point.
http://www.colorcube.com/articles/models/model.htm
Most color models in use today are oriented either toward hardware (color monitors or printers) or toward applications where color manipulation is a goal.
The most commonly used hardware-oriented model is RGB (red-green-blue) – for color monitors, color video cameras.
The CMY (cyan-magenta-yellow) and CMYK (cyan-magenta-yellow-black) models are in use for color printing.
Digital Image Processing
Week 5
The HSI (hue-saturation-intensity) model correspond with the way humans describe and interpret colors. The HSI model has the advantage that it decouples the color and gray-scale information in an image, making it suitable for using the gray-scale image processing techniques.
The RGB Color Model
In the RGB model, each color appears decomposed in its primary color components: red, green, blue. This model is based on a Cartesian coordinate system. The color subspace of interest is the unit cube (Figure 6.7), in which the primary and the secondary colors are at the corners; black is at the origin, and white is at the corner farthest from the origin.
Digital Image Processing
Week 5
The gray scale (point of equal RGB values) extends from black to white along the line joining these two points. The different colors in this model are points on or inside the cube, and are defined by vectors extending from the origin.
Digital Image Processing
Week 5
Images represented in the RGB color model consist of three component images, one for each primary color. The number of bits used to represent each pixel in RGB space is called the pixel depth. Consider an RGB image in which each of the red, green, and blue images are an 8-bit image. In this case, each RGB color pixel has a depth of 24 bits. The term full-color image is used often to denote a 24-bit RGB color image. The total number of colors in a 24-bit RGB image is
Digital Image Processing
Week 5
( ) 28 3 = 16.777.216
A convenient way to view these colors is to generate color planes (faces or cross sections of the cube).
A color image can be acquired by using three filters, sensitive to red, green, and blue.
Digital Image Processing
Week 5
Because of the variety of systems in use, it is of considerable interest to have a subset of colors that are likely to be reproduced faithfully, reasonably independently of viewer hardware capabilities. This subset of colors is called the set of safe RGB colors, or the set of all-systems-safe colors. In Internet applications, they are called safe Web colors or safe browser colors.
We assume that 256 colors is the minimum number of colors that can be reproduced faithfully by any system. Forty of these 256 colors are known to be
Digital Image Processing
Week 5
processed differently by various operating system. We have 216 colors that are common to most systems, and are the safe colors, especially in Internet applications. Each of the 216 safe colors has a RGB representation with:
{ }
, , 0, 51,102,153, 204, 255 R G B ∈
We have (6)3=216 possible color values. It is customary to express these values in the hexagonal number system.
Each safe color is formed from three of the two digit hex numbers from the above table. For example purest red if FF0000. The values 000000 and FFFFFF represent black and white respectively.
Digital Image Processing
Week 5
Figure 6.10(a) shows the 216 safe colors, organized in descending RGB values.
Figure 6.10(b) shows the hex codes for all the possible gray colors in the 216 safe color system.
Figure 6.11 shows the RGB safe-color cube.
Digital Image Processing
Week 5
http://www.techbomb.com/websafe/
The CMY and CMYK Color Models
Cyan, magenta, and yellow are the secondary colors of light but the primary color of pigments. For example, when a surface coated with yellow pigment is illuminated with white light, no blue light is reflected from the surface. Yellow subtracts blue light from reflected white light (which is composed of equal amounts of red, green, and blue light).
Digital Image Processing
Week 5
Most devices that deposit color pigments on paper, such as color printers and copiers, require CMY data input and perform RGB to CMY conversion.
Assuming that the color values were normalized to range [0,1], this conversion is:
1 1 1
C R
M G
Y B
= −
From this equation we can easily deduce, that pure cyan does not reflect red, pure magenta does not reflect green, and pure yellow does not reflect blue.
Equal amount of pigments primary, cyan, magenta, and yellow should produce black. In practice, combining these colors for printing produces a muddy- looking black. In order to produce true black (which is the predominant color in printing), a fourth color, black, is added, giving rise to the CMYK color model.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
The HSI Color Model
The RGB, CMY, and other similar color models are not well suited for describing colors in terms that are practical for human interpretation.
We (humans) describe a color by its hue, saturation and brightness. Hue is a color attribute that describes a pure color, saturation gives a measure of the degree to which a pure color is diluted by white light and brightness is a subjective descriptor that embodies the achromatic notion of intensity.
The HSI (hue, saturation, intensity) color model, decouples the intensity component from the color information (hue and saturation) in a color image.
What is the link between the RGB color model and HSI color model? Consider again the RGB unit cube. The intensity axis is the line joining the black and the white vertices. Consider a color point in the RGB cube. Let P be a plane
Digital Image Processing
Week 5
perpendicular to the intensity axis and containing the color point. The intersection of this plane with the intensity axis gives us the intensity of the color point. The saturation (purity) of the considered color point increases as a function of distance from the intensity axis (the saturation of the point on the intensity axis is zero).
In order to determine how hue can be linked to a given RGB point, consider a plane defined by black, white and cyan. The intensity axis is also included in this plane. The intersection of this plane with the RGB-cube is a triangle. All point contained in this triangle would have the same hue (i.e. cyan).
Digital Image Processing
Week 5
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 boundary defined by the intersection of this plane with the faces of the cube have either triangular or hexagonal shape.
Digital Image Processing
Week 5
In the plane shown in Figure 6.13(a) primary colors are separated by 120º. The secondary colors are 60º from the primaries. The hue of the point is determined
Digital Image Processing
Week 5
by an angle from some reference point. Usually (but not always) an angle of 0º from the red axis designates 0 hue, and the hue increases counterclockwise from there. The saturation (distance from the vertical axis) is the length of the vector from the origin to the point. The origin is defined by the intersection of the color plane with the vertical intensity axis.
Converting colors from RGB to HSI
if if 360
B G
H B G
θ
θ
≤
= − >
[ ]
2
( ) ( )
arccos
2 ( ) ( )( )
R G R B
R G R B G B
θ = − + −
− + − −
Digital Image Processing
Week 5
1 3 min{ , , }
S R G B
R G B
= − + +
( )
1
I = 3 R + + G B
It is assumed that the RGB values have been normalized to the range [0,1] and that angle θ is measured with respect to the red axis of the HSI space in Figure 6.13. Hue can be normalized to the range [0,1] by dividing it to 360º. The other two HSI components are in this range if the RGB values are in the interval [0,1].
R=100, G=150, B=200 H=210º, S=1/3, I=150/255=0.588
Digital Image Processing
Week 5
Converting colors from HSI to RGB
Given values of HSI we now want to find the corresponding RGB values in the same range.
RG sector (0º ≤ H < 120º)
(1 ) 1 cos
cos(60 )
3 ( )
B I S
S H
R I
H
G I R B
= −
= + −
= − +
Digital Image Processing
Week 5
GB sector (120º ≤ H < 240º)
(1 )
120 , 1 cos
cos(60 )
3 ( )
R I S
S H
H H G I
H
B I R G
= −
= − = + −
= − +
BR sector (120º ≤ H < 240º)
(1 )
240 , 1 cos
cos(60 )
3 ( )
G I S
S H
H H B I
H
R I G B
= −
= − = + −
= − +
Digital Image Processing
Week 5
Lab color space
The effectiveness of such transformations is judged ultimately in print. The transformations are developed and evaluated on monitors. It is necessary to have a high degree of consistency between the monitors and the output devices. This is best accomplished with a device-independent color model that relates the color gamut of the monitors and output devices, as well as any other devices being used, to one another. The model of choice for many color management systems (CMS) is the CIE L*a*b* model, also called CIELAB. The L*a*b*
color components are given by the following equations:
Digital Image Processing
Week 5
* 116 16
W
L h Y
Y
= ⋅ −
* 500
W W
X Y
a h h
X Y
= ⋅ −
* 200
W W
Y Z
b h h
Y Z
= ⋅ −
3
0.008856
( ) 16
7.787 0.008856
116
q q
h q
q q
>
=
+ ≤
Digital Image Processing
Week 5
, ,
W W W
X Y Z
are reference tristimulus values – typically the white of a perfectly reflecting diffuser under CIE standard D65 illumination (x = 0.3127 , y = 0.33290 , z = − − 1 x y
).The L*a*b* color space is colorimetric (i.e. colors perceived as matching are encoded identically), perceptually uniform (i.e. color differences among various hues are perceived uniformly), and device independent. Like the HSI system, the L*a*b* system is an excellent decoupler of intensity (represented by lightness L*) and color (represented by a* for red minus green and b* for green minus blue), making it useful in both image manipulation (tone and contrast editing) and image compression applications.
Digital Image Processing
Week 5
Other color spaces
YIQ – for the NTSC (National Television System Committee) television system in US
Y – luminance
I (in-phase), Q (quadrature) – chrominance
YUV – for the PAL (Phase Alternation Line) and SECAM (Séquentiel Couleur à Mémoire) television system in Europe
(I, Q) – obtained by rotating (U,V) YCbCr – digital video transmission
More about color spaces in: Andreas Koschan, Mongi Abidi, Digital Color Image Processing, Wiley, 2008
Digital Image Processing
Week 5
Color Difference
RGB, CMY, Lab – Euclidean distance HSI - F1=(H1, S1, I1), F2=(H2, S2, I2)
HSI
if if
2 2
1 2 1 2
2 2
1 2 1 2
1 2 1 2
1 2 1 2
( , ) ( ) ( ) ,
2 cos
2
d F F I C I I I
C S S S S
H H H H
H H H H
θ θ π
π π
= ∆ + ∆ ∆ = −
∆ = + −
− − ≤
= − − − >
Digital Image Processing
Week 5
Pseudo-color Image Processing
Pseudo-color (also called false color) image processing consists of assigning colors to gray values based on a specified criterion. The main use of pseudo-color is for human visualization and interpretation of gray-scale events in an image or sequence of images.
Intensity (Density) Slicing
If an image is viewed as a 3-D function, the method can be described as one of placing planes parallel to the coordinate plane of the image; each plane then
“slices” the function in the area of intersection.
Digital Image Processing
Week 5
The plane at
f x y ( , ) = l
i slices the image function into two levels. If a different color is assigned to each side of the plane, any pixel whose intensity level is above the plane will be coded with one color and any pixel below the plane will be coded with other color. Levels that lie on the plane itself may be arbitrarily assigned one of the two colors. The result is a two color image whoseDigital Image Processing
Week 5
relative appearance can be controlled by moving the slicing plane up and down the intensity axis.
Let [0, L-1] represent the gray scale, let l0 represent black (f(x,y)=0) and level lL-1 represent white (f(x,y)=L-1). Suppose that P planes perpendicular to the intensity axis are defined at levels l1, l2, …, lP , 0<P<L-1. The P planes partition the gray scale into P+1 intervals, V1, V2, …, VP+1. Intensity to color assignments are made according to the relation:
if
( , )
k( , )
kf x y = c f x y ∈ V
.Digital Image Processing
Week 5
Measurements of rainfall levels with ground-based sensors are difficult and expensive, and total rainfall figures are even more difficult to obtain because a significant portion of precipitations occurs over the ocean. One way to obtain these figures is to use a satellite. The TRMM (Tropical Rainfall Measuring
Digital Image Processing
Week 5
Mission) satellite utilizes, among others, three sensors specially designed to detect rain: a precipitation radar, a microwave imager, and a visible and infrared scanner. The results from the various rain sensors are processed, resulting in estimates of average rainfall over a given time period in the area monitored by the sensors. From these estimates, it is not difficult to generate gray-scale images whose intensity values correspond directly to rainfall, with each pixel representing a physical land area whose size depends on the resolution of the sensors.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Basics of Full-Color Image Processing
3 4
( , ) ( , )
: / , ( , ) ( , ) ( , )
( , ) ( , )
( , ) ( , ) ( , )
( , ) ( , )
R G B
c x y R x y
f D f x y c c x y G x y
c x y B x y C x y
M x y f x y c
Y x y K x y
→ = = =
= =
Digital Image Processing
Week 5
Color Transformations
- processing the components of a color image within the context of a single- color model
[ ]
( , ) ( , )
g x y = T f x y
1 2
( , , ..., ) , 1, 2, ..., ( ( , ) , ( , ) )
i i n
s = T r r r i = n f x y = r g x y = s
ri, si are the color components of f(x, y) and g(x, y), n is the number of color components, and {T1, T2,…, Tn} is a set of transformations or color mapping functions that operate on ri to produce si. (n=3 or n=4)
Digital Image Processing
Week 5
Digital Image Processing
Week 5
In theory, any transformation can be performed in any color model. In practice, some operations are better suited to specific color models.
Suppose we wish to modify the intensity of a color image, using
( , ) ( , ) , 0 1 g x y = k f x y < < k
In the HSI color space, this can be done with:
s1= r1 , s2= r2 , s3=k r3
In the RGB/CMY color model all components must be transformed s1= kr1 , s2= kr2 , s3=kr3 (RGB)
si = kri+(1-k), i=1,2,3 (CMY)
Although the HSI transformation involves the fewest number of operations, the costs for converting an RGB or CMY(K) image to the HSI color space are much bigger than the transformations.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Color Complements
The hues directly opposite one another on the above color circle are called complements (analogous to the gray-scale negatives).
Digital Image Processing
Week 5
Unlike the intensity transformation, the RGB complement transformation functions used in this example do not have straightforward HSI space
Digital Image Processing
Week 5
equivalent. The saturation component of the complement cannot be computed from the saturation component of the input image alone.
Color Slicing
Highlighting a specific range of colors in an image is useful for separating objects from their surroundings. The basic idea is either to:
- display the colors of interest so they stand out from the background - use the region defined by the colors as a mask for further processing.
One of the simplest ways to “slice” a color image is to map the colors outside some range of interest to a neutral color. If the colors of interest are enclosed by a cube (or hypercube, if n>3) of width W and centered at a prototypical (e.g. average) color with components
( a a
1,
2, ..., a
n)
the set of transformations is:Digital Image Processing
Week 5
if
otherwise
0.5 , 1
, 1, 2, ...,
j j
2
i
i
r a W j n
s i n
r
− > ≤ ≤
= =
These transformations highlight the colors around the prototype by forcing all other colors to the midpoint of the reference color space (an arbitrarily chosen neutral point).
For the RGB color space, for example, a suitable neutral point is middle gray or color (0.5, 0.5, 0.5).
If a sphere is used to specify the colors of interest, the transformations are:
Digital Image Processing
Week 5
if
otherwise
2 2
0 1
0.5 ( )
, 1, 2, ...,
n
j j
i j
i
r a R
s i n
r
=
− >
= =
∑
where R0 is the radius of the enclosing sphere and
( a a
1,
2, ..., a
n)
are thecomponents of its center.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Histogram Processing
It is not advisable to histogram equalize the components of a color image independently. This can produce wrong colors. A more logical approach is to spread the color intensity uniformly, leaving the colors (e.g., hues) unchanged.
The HSI color space is ideally suited for this type of approach.
The unprocessed image contains a large number of dark colors that reduce the median intensity to 0.36. Histogram equalizing the intensity component, without
Digital Image Processing
Week 5
altering the hue and saturation produced image Figure 6.37(c). The image is brighter. Figure 6.37(d) was obtained by increasing also the saturation component.
Color Image Smoothing
Let Sxy denote a neighborhood centered at (x,y) in an RGB color image. The average of the RGB component vectors in this neighborhood is:
( , )
( , ) 1 ( , )
s t Sxy
c x y c s t
K
∈= ∑
( , )
( , )
( , )
1 ( , )
( , ) 1 ( , )
1 ( , )
xy
xy
xy
s t S
s t S
s t S
R s t K
c x y G s t
K
B s t K
∈
∈
∈
=
∑
∑
∑
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Color Image Sharpening
( , ) ( , )
2( , ) g x y = f x y + ∇ c f x y
2
2 2
2
( , ) ( , ) ( , ) ( , ) R x y c x y G x y B x y
∇
∇ = ∇
∇
Digital Image Processing
Week 5
Image Compression
Image compression is the art and science of reducing the amount of data required to represent an image.
Consider a two-hour standard definition (SD) television
movie using 720 × 480 × 24 bit pixel arrays. A digital movie is
a sequence of video frames in which each frame is a full-color
still image. Because video players must display the frames
sequentially at rates 30 fps (frames per second), SD digital
video must be accessed at:
Digital Image Processing
Week 5
frames pixels bytes
bytes/sec
sec frame pixel
30 × (720 480) × × 3 = 31.104.000 and a two-hour movie consist of
bytes sec
hours bytes( GB)
sec hour
2 11
31.104.000 × (60 ) × 2 2.24 10 × 224
To put a two-hour movie on a DVD, each frame must be compressed by a factor of 26.3(on average). The compression must be even higher for high definition (HD) television where image resolution reach 1920 × 1080 × 24 bit/image.
Digital Image Processing
Week 5
Fundamentals
The term data compression refers to the process of reducing the amount of data required to represent a given quantity of information. Data and information are not the same thing;
data are the means by which information is expressed.
Because various amounts of data can be used to represent the
same amount of information, representations that contain
irrelevant or repeated information are said to contain
redundant data.
Digital Image Processing
Week 5
Let b and b′ denote the number of bits in two representations of the same information, the relative data redundancy R of the representation with b bits is:
1 1
R = − C
Where C, commonly called the compression ratio is C b
= b
′
If C=10 - the larger representation has 10 bits of data for
every 1 bit of data in the smaller representation. The
Digital Image Processing
Week 5
corresponding relative data redundancy of the larger representation is 0.9 (R=0.9), indicating that 90% of its data is redundant.
In the context of digital image compression, b usually is the
number of bits needed to represent an image as a 2-D array of
intensity values. Two-dimensional intensity arrays (far from
optimal) suffer from three principal types of data
redundancies:
Digital Image Processing
Week 5
1. Coding redundancy. A code is a system of symbols
(letters, numbers, bits…) used to represent a body of
information or set of events. Each piece of information
or event is assigned a sequence of code symbols, called a
code word. The number of symbols in each code word is
its length. The 8-bit codes that are used to represent the
intensities in most 2-D intensity arrays contain more bits
than are needed to represent the intensities.
Digital Image Processing
Week 5
2. Spatial and temporal redundancy. Because the pixels of most 2-D intensity arrays are correlated spatially (i.e.
each pixel is similar to or dependent on neighboring
pixels), information is unnecessarily replicated in the
representations of correlated pixels. In a video sequence,
temporally correlated pixels (i.e., those similar to or
dependent on pixels in nearby frames) also duplicate
information.
Digital Image Processing
Week 5
3. Irrelevant information. Most 2-D intensity arrays contain information that is ignored by the human eye.
This information is redundant in the sense that it is not used.
Compression is achieved when one or more redundancy is
reduced or eliminated.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Code Redundancy
Assume that a discrete random variable r
kin the interval [0, L-1] is used to represent the intensities of an M × N image and that each r
koccurs with probability p(r
k).
( )
kn
k, 0,1, 2,..., 1
p r k L
= M N = −
⋅
Where L is the number of intensity values, and n
kis the number of times that the k-th intensity appears in the image.
If the number of bits used to represent each value of r
kis l(r
k),
Digital Image Processing
Week 5
then the average number of bits required to represent each pixel is:
1
0
( ) ( )
L
avg k k
k
L l r p r
−
=
= ∑
The total number of bits required to represent an M × N image is MNL
avg. If the intensities are represented using a natural m-bit fixed-length code, L
avg= m .
Consider image in Figure 8.1 (a) (M=N=256) and the coding
Table 8.1.
Digital Image Processing
Week 5
For Code 1 L
avg= 8 . For Code 2 we have:
bits 0.25 2 0.47 1 0.25 3 0.03 3 1.81
L
avg= ⋅ + ⋅ + ⋅ + ⋅ =
The total number of bits needed to represent the entire image
is MNL
avg= 256 256 1.81 × × = 118.621 .
Digital Image Processing
Week 5
256 256 8 8 256 256 1.81 1.81 4.42
C × ×
= = ≈
× ×
1 1
1 1 0.774
R 4.42
= − C = − =
Thus, 77.4% of the data in the original 8-bit 2-D intensity array is redundant.
The compression achieved by code 2 results from assigning
fewer bits to the more probable intensity values than to the
less probable ones, thus resulting a variable-length code. The
best fixed-length code that can be assigned to the intensities
Digital Image Processing
Week 5
of the image in Figure 8.1(a) is the natural 2-bit counting sequence {00, 01, 10, 11} but the resulting compression is only C=8/2=4:1 which is about 10% less than the 4.42:1 compression of the variable-length code.
Coding redundancy is present when the codes assigned to a
set of events (such as intensity values) do not take full
advantage of the probabilities of the events. Coding
redundancy is almost always present when the intensities of
an image are represented using a natural binary code. Most
Digital Image Processing
Week 5
images are composed of objects that have a regular and somewhat predictable morphology (shape) and reflectance, and are sampled so that the objects being depicted are much larger than the picture elements. For most images, certain intensities are more probable than others (that is, the histograms of most images are not uniform). A natural binary encoding assigns the same number of bits to both the most and least probable values, failing to minimize the value of
L
avgand resulting in coding redundancy.
Digital Image Processing
Week 5
Digital Image Processing
Week 5
Spatial and Temporal Redundancy
Consider the computer-generated image in Figure 8.1(b). In the corresponding 2-D intensity array:
1) All 256 intensities are equally probable
2) Because the intensity of each line was selected
randomly, its pixels are independent of one another in the
vertical direction
Digital Image Processing
Week 5
3) Because the pixels along each line are identical, they are maximally correlated (completely dependent on one another) in the horizontal direction.
The first observation tells us that this image cannot be
compressed by variable-length coding alone. Observation 2
and 3 reveal a significant spatial redundancy that can be
eliminated, for instance, by representing this image as a
sequence of run-length pairs, where each run-length pair
specifies the start of a new intensity and the number of
Digital Image Processing
Week 5
consecutive pixels that have that intensity. A run-length based representation compresses the original 2-D, 8-bit intensity array by
256 256 8
128 : 1 256 2 8
C × ×
= =
× ×
Each 256-pixel line of the original representation is replaced by a single 8-bit intensity value and length 256 in the run-length representation.
In most images, pixels are correlated spatially (in both x and
y) and in time (in case of video sequences). Because most
Digital Image Processing
Week 5
pixels’ intensities can be predicted reasonably well from neighboring intensities, the information carried by a single pixel is small. Much of its visual contribution is redundant in the sense that can be inferred from its neighbors. To reduce the redundancy associated with spatially and temporally correlated pixels, a 2-D intensity array must be transformed into a more efficient but usually ‘non-visual’ representation.
Transformations of this type are called mappings. A mapping
is said to be reversible if the pixels of the original 2-D
Digital Image Processing
Week 5
intensity array can be reconstructed without error from the transformed data set; otherwise the mapping is said to be irreversible.
Irrelevant Information
One of the simplest ways to compress a set of data is to
remove superfluous data from the set. In the context of DIP,
information ignored by the system which uses the image
(human eye, computer programs) are obvious candidates for
omission. Thus, the computer-generated image in Figure
Digital Image Processing
Week 5
8.1(c), because it appears to be a homogeneous field of grey,
can be represented by its average intensity alone – a single
8-bit value. The original 256 × 256 × 8 bit intensity array is
reduced to a single byte; the resulting compression is
65.536:1.
Digital Image Processing
Week 5
Figure 8.3(a) shows the histogram of the image in Figure 8.1(c) – there are some intensity values (125 through 131) actually present. The human visual system averages these intensities, perceives only the average value, and ignores the small changes in intensity that are present in this case.
Digital Image Processing
Week 5
Figure 8.3(b), a histogram equalized version of the image in Figure 8.1 (c), makes the intensity changes visible and reveals two previously undetected regions of constant intensity.
If the image in Figure 8.1 (c) is represented by its average value alone, this ‘invisible’ structure is lost.
This kind of redundancy can be eliminated because the
information itself is not essential for normal visual processing
and/or the intended use of the image. Because its omission
results in a loss of quantitative information, its removal is
Digital Image Processing
Week 5