HSI Color Space
HSI Color Space
HSI Color Space
| Download Demo | Support and Upgrade Policy | Pricing | Imaging Feature Comparison Chart |
| Document Imaging SDK Online Help | Document Imaging ActiveX Online Help | Purchase |
The HSI color space is very important and attractive(phân phối) color model for image processing
applications because it represents color s similarly how the human eye senses colors.
The HSI color model represents every color with three components: hue(sac thai) ( H ),
saturation(bao hoa) ( S ), intensity ( I )(cuong do). The below figure illustrates(minh hoa) how the
HIS color space represents colors.
The Hue component describes the color itself in the form of an angle between [0,360] degrees. 0
degree mean red, 120 means green 240 means blue. 60 degrees is yellow, 300 degrees is
magenta.
The Saturation component signals how much the color is polluted with white color. The range of
the S component is [0,1].
The Intensity range is between [0,1] and 0 means black, 1 means white.
As the above figure shows, hue is more meaningful when saturation approaches 1 and less
meaningful when saturation approaches 0 or when intensity approaches 0 or 1. Intensity also
limits the saturation values.
To formula that converts from RGB to HSI or back is more complicated than with other color
models, therefore we will not elaborate on the detailed specifics involved in this process.
RGB CMY CMYK
HSI HSV L*a*b
XYZ YIQ YUV
Home > Imaging Toolkits > Color Space Conversion > HSI
What Is Color?
(cont'd)
Hue
Hue is what most people think of when we say "color."
Hue is the name of a distinct color of the spectrum(quang phổ)—red, green, yellow,
orange, blue, and so on. It is the particular wavelength frequency.
Saturation
Saturation is the "purity" of the color.
Saturation refers to the amount of white light (or gray paint) mixed with the hue. Pastels
are less saturated colors. Both of these samples below have a hue we would call "blue"
but their saturation is different.
Less saturated
steelblue has gray
colors look muddier,
undertones
or less pure.
Value refers to the intensity of light present. When light is at its fullest intensity, colors
will become bright, at its least intensity, colors become dim. Unlike saturation, there isn't
necessarily "less" of the color -- it is just not as intense. You might think of value as being
a bit like the dimmer switch on your dining room light or the brightness knob on your
computer's monitor. Turn up the switch, and the value grows brighter.
A higher
value
creates a
whiter,
brighter
color.
Color Spaces
(Based on material from Digital Imaging: Theory and Applications, H. E. Burdick, McGraw-Hill,
1997)
Computer display CRTs typically have three electron guns that illuminate three
different kinds of phosphor dots on the screen. Those phosphor dots, when
illuminated, glow with the red, green, and blue primary colors of light. From these
primary colors, all other shades are generated.
• Digital imagery often uses the red/green/blue color space, known simply
as RGB.
• The cyan/yellow/magenta space, known as CYM, is used in printing.
• Hue, saturation, and intensity, (or HSI) is the color space typically used by
artists.
• Intensity-chromaticity color spaces, YUV and YIQ, are used for television
broadcast.
(red, green, blue)
Several colors are shown mapped into their locations in the RGB cube, or color
space. Black has zero intensities in red, green, or blue, so it has the coordinates
(0,0,0). At the opposite corner of the color cube, white has maximum intensities
of each color, or (255,255,255). Full intensity red, having zero green or blue
components, also is positioned at a corner of the cube at location (255,0,0).
Yellow, which is combination of red and green, is positioned at (255,255,0). Cyan
and magenta, which are combinations of green and blue and red and blue,
respectively, are at (0,255,255) and (255,0,255). Finally, note that a middle gray
is at the exact center of the cube at location (128,128,128). All other colors can
be described by specifying their coordinates within this cube.
The RGB color space is an additive color space. Its origin starts at black, and all
other colors are derived by adding various amounts of the primary colors. It is a
natural choice for computer displays where black, or no light intensity, is the
starting point, and the increasing intensity of the red, green, and blue electron
guns provides the range of colors.
The CYM color space is related to the RGB color space by being the inverse of it.
The origin of this color space is not black, but is white, and the primary axes of
the coordinate system are not red, green, and blue but are cyan, yellow, and
magenta. The color red in this space is a combination of yellow and magenta,
while green is composed of yellow and cyan. Blue is made up of cyan and
magenta. The following equations define how to convert from the RGB color
space into the CYM color space and back again.
The CYM color space is most often used in the printing industry, where images
start with a white piece of paper (the origin) and ink is applied to generate colors.
After years of experience, many techniques have been developed to create the
highest-quality printed images at the lowest possible cost. One of these methods
is called under color removal and modifies the normal CYM color space into
something called CYMK, where the K stands for black.
This approach notes that any CYM color has some underlying gray component,
which is equal amounts of cyan, yellow, and magenta. This gray component can
be generated with cheaper black ink, and small amounts of more expensive
colored inks can be added to give the correct shade. In addition to being more
economical, the printed image quality is increased because less ink is used
overall, which in turn enhances drying and reduces the likelihood of smears. For
example a color has certain components of cyan, yellow, and magenta on an
arbitrary scale. In this case, 7 units of cyan ink, 5 units of yellow ink, and 9 units
of magenta ink are required, for a total of 21 units. That same color can then
have its underlying gray, or under color, removed. To reproduce this same color
now takes 5 units of black ink, with 2 units of cyan, no yellow, and 4 units of
magenta. This makes a total of 11 units of ink, only 6 units of which are
expensive colors.
Artists tend to describe scenes not in terms of red, green, and blue, but as hue,
saturation, and intensity (HSI). We do not see things as quantities of primary
colors mixed in certain proportions. We see the brilliant orange of a sunset or the
dark, muted greens of a forest. We see things as colors, or hues, that either have
a washed-out look or have deep, rich tones. This means having low or high
saturation, respectively. A bright afternoon sun gives everything a high-intensity
look, while dusk provides dark images of low intensity.
HSI is very different three-dimensional color space from RGB or CYM. The
following figure illustrates a common representation of this space. The cone
shape has one central axis representing intensity. Along this axis are all the gray
values, with black at the pointed end of the cone and white at its base. The
greater the distance along this line from the pointed end, or origin, the brighter or
higher the intensity.
If this cone is viewed from above, it becomes a circle. Different colors, or hues,
are arranged around this circle - the familiar color wheel used by artists. Hues
are determined by their angular location on this wheel. Saturation, or the richness
of color, is defined as the distance perpendicular to the intensity axis. Colors near
the central axis have low saturation and look pastel. Colors near the surface of
the cone have high saturation.
It may be preferable to modify an image in HSI color space rather than RGB. For
example, we might want to change the color of a bright yellow car moving down a
road to blue, but we want to leave the rest of the scene, including highlights and
shadows on the car, unaffected. This would be a difficult task in RGB, but it is
relatively simple in HSI. Because the yellow pixels of the car have a specific
range of hue, regardless of intensity or saturation, those pixels can be isolated
easily and their hue component modified, thus giving a different-colored car.
Since almost all digital image processing systems operate on RGB images, the
example described above would be performed in three steps. First, the original
RGB image would be converted to HSI. Second, the hue (or saturation or
intensity) would be modified, Finally, the image would be converted back to RGB.
There are many techniques for transforming an image from RGB to HSI and back
again because the transformation is somewhat subjective.
The hue, saturation and value (HSV) system is a minor variation on the HSI
system. The HSV color model, uses a hue value of 0 degrees to 360 degrees,
with red at 0. Saturation is in the range of 0 to 1, with 0 being no color (along the
central axis) and 1 being on the outer edge of the cone. The value (a variation of
intensity) also has a range of 0 to 1, where 0 is black and 1 is white. Note that
these calculations require higher numerical precision than is offered by 8-bit
integer arithmetic. It therefore is advisable to maintain a HSV image as floating-
point numbers, or at least 16-bit or 32-bit integers, and reduce them to 8-bit
values as they are being transformed back into RGB.
Luminance-Chrominance
The last color spaces to be discussed are those based on luminance and
chrominance, which correspond to brightness and color. These color spaces are
denoted as YUV and YIQ. The YUV space is used for the PAL broadcast
television system used in Europe. The YIQ color space is used for the NTSC
broadcast standard in North America. The two methods are nearly identical,
using slightly different conversion equations to transform to and from RGB color
space. In both systems, Y is the luminance or brightness component and the I
and Q (or U and V) are the chrominance, or color, components. These are the
variables that are changed by the brightness, color, and tint controls on a
television.
The advantages of using YUV or YIQ for broadcast is that the amount of
information needed to define a color television image is greatly reduced.
However, this compression restricts the color range in these images. Many colors
that can appear on a computer display cannot be recreated on a television
screen. Listed below are the equations for converting RGB colors into YUV and
YIQ, and back to RGB. These equations assume that the red, green, and blue
components have values between 0.0 and 1.0. Since this range is typical
represented using 8-bit values between 0 and 255, they need to be scaled and
processed as floating-point numbers:
RGB-to-YUV
Y = .299R + .587G + .114B
U = .147R .289G + .437B
V = .615R .515G .100B
RGB-to-YIQ
Y = .299R + .587G + .114B
I = .596R .274G .322B
Q = .211R .523G .312B
YUV-to-RGB
R = 1.00Y + .000U + 1.403V
G = 1.00Y .344U .714V
B = 1.00Y + 1.773U + .000V
YIQ-to-RGB
R = 1.129Y + 3.306I 3.000Q
G = 1.607Y .934I + .386Q
B = 3.458Y 3.817I + 5.881Q
Introduction
After growing tired of spending hours zoomed in at 800% magnification using the
polygon lasso tool to create combined grayscale and color images in Macromedia
Fireworks, I decided that there had to be a better way. Thus I embarked upon creating this
application to make my life and hopefully that of others easier. This is a first attempt, and
if I receive positive feedback that others would actually like to use this application, I will
expand the features available when time permits.
Background
This application uses unsafe code and pointers for image manipulation. Check out the
"Image Processing for Dummies" articles by Christian Graus on The Code Project for a
good introduction to this technique. Also, for selecting an area of the image, I used code
from the article "The Secret of Marching Ants" by q123456789 on The Code Project.
I have found that one of the more effective methods of dealing with this is to use a ratio
value between the pixel's colors. Once users select a pixel from the image that they would
like to keep, the program computes the difference in value between the red and green
band, red and blue band, and green and blue band. This then is a ratio that can be used
over the entire image to find similar colored pixels, even though the light level may be
very different. For example, this would match a pixel that had the values red = 50, green
= 80, and blue = 110 to a pixel that had the values red = 180, green = 210, and blue = 240
because the difference between red and green in each is 30, etc.
However, even using the ratio method described above still does not match very many
pixels, a maximum of 256. To get a decent color selection, error values must be used on
each band difference. Therefore, the program provides three text boxes for the user to
provide an error value for the red and green difference, red and blue difference, and green
and blue difference. By adding and subtracting this error value from the difference
number, a much broader range of colors are included in the match. For example, if the
difference between the red and green pixels is 25, and the user enters an error value of 20,
all pixels with a difference between the red and green bands of anywhere from 5 to 45
will be within this range.
Another useful feature is that many times the color exists in several locations on the
image and the user only wants to keep it in one section. Therefore, some boundary needs
to be supplied allowing the user to select a small area from the image to keep in color.
For this example program, I have just added simple code for a rectangle, although it
could be expanded to any shape. I implemented just the drawing part of "The Secret of
Marching Ants" program from The Code Project so that users can see the rectangle as
they draw it. This necessitated drawing the image directly onto the form instead of using
a picturebox where scrollbars could easily be added. That said, here is the basic image
processing function in the program:
Collapse
private void GrayColor()
{
int height = user_image.Height;
int width = user_image.Width;
Note that it is not altering the bitmap directly, rather pixels that match the selected color
within the user's specified error limits are assigned to true on a boolean two dimensional
array. This array is used like a mask; all values of true correspond to a pixel that
remains in color, otherwise they are turned into a grayscale color. This lets the function
run multiple times on the same image and thus allows the user to select multiple colors
before generating the final image.
Now that we have an easy way to select the color and area of the image to affect, we now
need an easy way for users to interpret what they have and have not already selected.
Again, there are several different ways this could be done. I simply passed the user's
image and the mask created in the last step to a new form. The user can then select
whether to undo the color selection, add another color, or accept the image as final. When
adding another color, it inverts the mask so that users see colors they have already
selected as grayscale. Once the user is satisfied with the image, the following code is run
to create the final image.
Collapse
private void DrawImage()
{
int width = user_image.Width;
int height = user_image.Height;
unsafe
{
byte* p = (byte*)(void*)Scan0;
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
if (!img_array[y, x]) // convert to grayscale
{
p[2] = p[1] = p[0] = (byte)(.299 * p[2] + .587 *
p[1]
+ .114 * p[0]);
}
p += 3;
}
p += nOffset;
}
}
user_image.UnlockBits(bmdata);
DrawBackground(); // refresh the image
}