|
Part 1: Playing with the Pixels
by James Antonakos
Start
ý Imaging 101 ý RLE
Compressor Tool ý Adjusting
the X-Y Resolution ý Adjusting
the Z-Axis Resolution ý Simple
Image Operations ý Run-Length
Compression ý More to Come
ý Sources and PDF
SIMPLE IMAGE OPERATIONS
Table 1 lists several basic image processing
operations. Some operations alter the way pixels appear in the image,
and others actually move the pixels around within the image.
|
Operation
|
Function
|
|
Histogram
|
Displays a graph of pixel count
versus pixel intensity
|
|
Threshold
|
Compares each pixel against a
threshold value. Changes the pixel to one shade if its intensity
is less than the threshold and a different shade if equal
or greater.
|
|
Negative
|
Changes each pixel to its opposite
shade (black becomes white and vice versa)
|
|
Horizontal Flip
|
Exchanges pixels on the left
side of the image with pixels on the right side
|
|
Vertical Flip
|
Exchanges pixels at the top of
the image with pixels on the bottom (turns the image upside
down)
|
|
Zoom
|
Magnifies a selected portion
of the image
|
|
Table 1ýHere you can see several
common image operations that manipulate the image in specific
ways.
|
Photos 4a and b show the histogram for
the source image. There are two tall spikes, one for the numerous
black pixels (the hair and background) in the image, and the other
for the white pixels (the shirt). Photo 4b is the histogram for the
same image after its z-axis has been adjusted to 3-bit pixel values
(eight shades of intensity). Note that there are only eight spikes
in the histogram, and they are all tall. This is because there are
still over 65,000 pixels in the image, but with only eight different
shades, each shade must account for a large number of pixels.
a)
|
b)
|
| Photo 4aýThis histogram
of the original image shows a lot of intensity variation. býThis
is a histogram of the same image when 3-bit pixel values are
used. One technique, called histogram equalization, is used
to evenly distribute the shades of pixels in an image, improving
the contrast. |
The threshold operation is used to convert
an image into a binary image. Each pixel in the image is compared
against the threshold value and then replaced with one of two different
shades, depending on whether the pixel value is larger or smaller
than the threshold value. Photos 5aýc show three processed images,
with each image processed with a different threshold value. As Photo
5c indicates, care must be taken when choosing the threshold value
because a great deal of information may be lost if the threshold is
too large or small.
a) |
b) |
c) |
| Photos 5aýcýHere
I used a threshold to create a binary image. aýThreshold set
to 15. býThreshold set to 30. cýThreshold set to 45. |
Replacing every pixel value in an image
with its opposite value (0 becomes 63, 63 becomes 0) produces a negative.
Photo 6 shows the negative of the source image. Creating a negative
after the image has been stored takes more time than doing it on the
fly with an appropriate set of ILUT or OLUT data.
 |
| Photo 6ýThis is the negative
of the source image. Sometimes an image detail that is not obvious
in the normal image is apparent in the negative. |
Photos 7aýc illustrate some simple geometric
operations. Flipping the image upside down or left-to-right is useful
when you cannot control the method of image capture. For example,
someone else might give you an image to process, and the image may
contain letters and numbers that are backwards. Flipping the image
around may help with the processing in this case.
a) |
b) |
c) |
| Photos 7aýcýHere
simple geometric operations are applied to the source imageý(a)
horizontal flip, (b) vertical flip, and (c) zoom. |
Zooming in on a region of the image is
also an important operation. In Photo 7c, the 128 ý 128 center portion
of the source image has been magnified to 256 ý 256.
In general, you may only want to flip
or zoom in on a small portion of an image. In this case, additional
software must be used to allow you to select the rectangle of pixels
that will be processed.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |