Conversion of a Color Image
to a Binary Image
What is a Binary Image?
Binary images are images whose pixels have only two possible intensity
values. They are normally displayed as black and white. Numerically, the two
values are often 0 for black, and either 1 or 255 for white.
Binary images are often produced by thresholding a grayscale or color image,
in order to separate an object in the image from the background. The color of
the object (usually white) is referred to as the foreground color. The
rest (usually black) is referred to as the background color. However,
depending on the image which is to be thresholded, this polarity might be
inverted, in which case the object is displayed with 0 and the background is
with a non-zero value.
Some morphological operators assume a certain polarity of the binary input
image so that if we process an image with inverse polarity the operator will
have the opposite effect. For example, if we apply a closing operator to a black
text on white background, the text will be opened.
What are Pixels?
In order for any digital computer processing to be carried out on an image,
it must first be stored within the computer in a suitable form that can be
manipulated by a computer program. The most practical way of doing this is to
divide the image up into a collection of discrete (and usually small) cells,
which are known as pixels. Most commonly, the image is divided up into
a rectangular grid of pixels, so that each pixel is itself a small rectangle.
Once this has been done, each pixel is given a pixel value that represents the
color of that pixel. It is assumed that the whole pixel is the same color, and
so any color variation that did exist within the area of the pixel before the
image was discretized is lost. However, if the area of each pixel is very small,
then the discrete nature of the image is often not visible to the human eye.
Other pixel shapes and formations can be used, most notably the hexagonal
grid, in which each pixel is a small hexagon. This has some advantages in image
processing, including the fact that pixel connectivity is less ambiguously
defined than with a square grid, but hexagonal grids are not widely used. Part
of the reason is that many image capture systems (e.g. most CCD cameras
and scanners) intrinsically discretize the captured image into a rectangular
grid in the first instance.
What are Intensity values?
Each of the pixels that represents an image stored inside a computer has a
pixel value which describes how bright that pixel is, and/or what color
it should be. In the simplest case of binary images, the pixel value is a 1-bit
number indicating either foreground or background. For a grayscale images, the
pixel value is a single number that represents the brightness of the pixel. The
most common pixel
format is the byte image, where this number is stored as an 8-bit
integer giving a range of possible values from 0 to 255. Typically zero is taken
to be black, and 255 is taken to be white. Values in between make up the
different shades of gray.
To represent color images, separate red, green and blue components must be
specified for each pixel (assuming an RGB colorspace), and so the pixel `value'
is actually a vector of three numbers. Often the three different components are
stored as three separate `grayscale' images known as color planes (one
for each of red, green and blue), which have to be recombined when displaying or
processing.
Multi-spectral images can contain even more than three components for each
pixel, and by extension these are stored in the same kind of way, as a vector
pixel value, or as separate color planes.
The actual grayscale or color component intensities for each pixel may not
actually be stored explicitly. Often, all that is stored for each pixel is an
index into a colormap in which the actual intensity or colors can be looked up.
Although simple 8-bit integers or vectors of 8-bit integers are the most
common sorts of pixel values used, some image formats support different types of
value, for instance 32-bit signed integers or floating point values. Such values
are extremely useful in image processing as they allow processing to be carried
out on the image where the resulting pixel values are not necessarily 8-bit
integers. If this approach is used then it is usually necessary to set up a
colormap which relates particular ranges of pixel values to particular displayed
colors.
What is meant by the Term RGB(RGB)?
It is a useful fact that the huge variety of colors that can be perceived by
humans can all be produced simply by adding together appropriate amounts of red,
blue and green colors. These colors are known as the primary colors. Thus in
most image processing applications, colors are represented by specifying
separate intensity values for red, green and blue components. This
representation is commonly referred to as RGB.
The primary color phenomenon results from the fact that humans have three
different sorts of color receptors in their retinas which are each most
sensitive to different visible light wavelengths.
The primary colors used in painting (red, yellow and blue) are different.
When paints are mixed, the `addition' of a new color paint actually
subtracts wavelengths from the reflected visible light.
C# Sample Program:
Guidelines for Use
To illustrate Conversion of Color Image to
Grayscale image, we
start with a simple image containing some distinct artificial objects(specifically text)

Now we apply Grayscale conversion to the image
to convert it to Grayscale image.

Now we apply Binary conversion to the image
to convert it to Binary image.

Attachments:
Project Files: binary.zip