3) Arithmetic Operations
3) Arithmetic Operations
Arithmetic/Logic Operations
B.E.Instrumenation
Arithmetic/Logic Operations
• Arithmetic/logic operations - performed on a pixel-by-pixel
basis between two or more images
• This excludes the logic operation NOT, which is performed on
a single image
• E.g., subtraction of two images results in a new image whose
pixel at coordinates (x, y) is the difference between the pixels
in that same location in the two images being subtracted
• AND, OR, and NOT - functionally complete - any other logic
operator can be implemented by using only these three basic
functions
Arithmetic/Logic Operations
• Logic operations on gray-scale images - pixel values are
processed as strings of binary numbers
• E.g., performing the NOT operation on a black, 8-bit pixel (a
string of eight 0’s) produces a white pixel (a string of eight 1’s)
• Intermediate values - same way - changing all 1’s to 0’s and
vice versa
• NOT logic operator – same as the negative transformation
• AND and OR operations - used for masking - for selecting
subimages in an image ( Refer next fig.)
Arithmetic/Logic Operations
Masking using AND and OR operations
Arithmetic/Logic Operations
Masking using AND and OR operations
• AND and OR image masks
– light represents a binary 1
– dark represents a binary 0
• Masking - region of interest (ROI) processing
• In enhancement - masking is used primarily to isolate an area
for processing - to highlight that area and differentiate it from
the rest of the image
• Logic operations - also are used frequently in conjunction with
morphological operations
Arithmetic/Logic Operations
• Arithmetic operations - subtraction and addition (in that
order) are the most useful for image enhancement
• We consider division of two images simply as multiplication of
one image by the reciprocal of the other
• Multiplication
– multiplying an image by a constant to increase its average
gray level
– enhancement - masking operation
• In other words, multiplication of one image by another can be
used to implement gray-level, rather than binary, masks
Arithmetic/Logic Operations
Image Subtraction
• The difference between two images f(x, y) and h(x, y),
expressed as
g(x, y) = f(x, y) - h(x, y)
• obtained by computing the difference between all pairs of
corresponding pixels from f and h
• key usefulness - enhancement of differences between images
• E.g., refer next fig. – Fig a - fractal image
• higher-order bit planes of an image carry a significant amount
of visually relevant detail
• lower planes contribute more to fine (often imperceptible)
detail
Arithmetic/Logic Operations
Image Subtraction: Example
• Figure (b) - result of discarding
(setting to zero) the four least
significant bit planes of the
original image
• The images are nearly identical
visually, with the exception of a
very slight drop in overall contrast
due to less variability of the gray-
level values in the image of Fig.
(b)
• The pixel-by-pixel difference
between these two images is
shown in Fig. (c)
The differences in pixel values are so small that the difference image appears
nearly black when displayed on an 8-bit
In order to bring out more detail, we can perform a contrast stretching
transformation
Arithmetic/Logic Operations
Image Subtraction: Example
• We chose histogram
equalization, but an
appropriate power-law
transformation would
have done the job also.
The result is shown in
Fig.(d)
• This is a very useful image
for evaluating the effect
of setting to zero the
lower-order planes
Arithmetic/Logic Operations
Image Subtraction: Radiography Application
• One of the most commercially successful and beneficial uses of image
subtraction is in the area of medical imaging called mask mode
radiography
• In this case h(x, y), the mask, is an X-ray image of a region of a patient’s
body captured by an intensified TV camera (instead of traditional X-ray
film) located opposite an X-ray source.
• The net effect of subtracting the mask from each sample in the incoming
stream of TV images is that the areas that are different between f(x, y) and
h(x, y) appear in the output image as enhanced detail.
Arithmetic/Logic Operations
Image Subtraction: Radiography Application
Arithmetic/Logic Operations
Image Subtraction: Radiography Application
Arithmetic/Logic Operations
Image Subtraction: Radiography Application
The camera yielding this image was positioned above the patient’s
head, looking down. As a reference point, the bright spot in the lower
one-third of the image is the core of the spinal column.
Figure 3.29(b) shows the difference between the mask (Fig. 3.29a)
and an image taken some time after the medium was introduced into
the bloodstream.
Arithmetic/Logic Operations
Image Subtraction: Radiography Application
where
• expected value of
• variance of
• variance of
Arithmetic/Logic Operations
Image Averaging : Astronomy
• field of astronomy - imaging
with very low light levels is
routine - causing sensor noise
frequently make images
virtually useless for analysis
• Figure 3.30(a) shows an image
of a galaxy pair called NGC
3314, taken by NASA’s Hubble
Space Telescope with a wide
field planetary camera
Arithmetic/Logic Operations
Image Averaging : Astronomy
• NGC 3314 lies about 140
million light-years from Earth,
in the direction of the
southern-hemisphere
constellation Hydra
• The bright stars forming a
pinwheel shape near the
center of the front galaxy have
formed recently from
interstellar gas and dust
Arithmetic/Logic Operations
Image Averaging : Astronomy
• Figure 3.30(b) shows the same
image, but corrupted by
uncorrelated Gaussian noise with
zero mean and a standard
deviation of 64 gray levels
• This image is useless for all
practical purposes
• Figures 3.30(c) through (f) show
the results of averaging 8, 16, 64,
and 128 images, respectively
• We see that the result obtained
with K=128 is reasonably close to
the original in visual appearance
Arithmetic/Logic Operations
Image Averaging : Astronomy
• We can get a better
appreciation from Fig. 3.31
for how reduction in the
visual appearance of noise
takes place as a function of
increasing K.
• This figure shows the
difference images between
the original [Fig. 3.30(a)]
and each of the averaged
images in Figs. 3.30(c)
through (f)
Arithmetic/Logic Operations
Image Averaging : Astronomy
• The histograms
corresponding to the
difference images are also
shown in the figure
• As usual, the vertical scale
in the histograms represents
number of pixels and is in
the range [0, 2.6*104]
• The horizontal scale
represents gray level and is
in the range [0, 255]
Arithmetic/Logic Operations
Image Averaging : Astronomy
• Notice in the histograms that the
mean and standard deviation of the
difference images decrease as K
increases.
• This is as expected because,
according to Eqs. (3.4-3) and (3.4-4),
the average image should approach
the original as K increases.
• We can also see the effect of a
decreasing mean in the difference
images on the left column of Fig.
3.31, which become darker as the K
increases Addition is the discrete
formulation of continuous
integration.
Arithmetic/Logic Operations
Image Averaging : Astronomy
• In astronomical observations, a
process equivalent to the
method just described is to use
the integrating capabilities of
CCD or similar sensors for noise
reduction by observing the
same scene over long periods of
time.
• The net effect, however, is
analogous to the procedure just
discussed.
• Cooling the sensor further
reduces its noise level.
Arithmetic/Logic Operations
Image Averaging
• As in the case of image subtraction, adding two or more 8-bit
images requires special care when it comes to displaying the result
on an 8-bit display
• The values in the sum of K, 8-bit images can range from 0 to 255*K
• The images in the example were scaled using the second scaling
method discussed at the end of the previous section
• That is, the minimum value in a given average image was obtained
and its negative was added to the image
• Then all the pixels in the modified image were scaled to the range
[0, 255] by multiplying each pixel in the modified image by the
quantity 255_Max, where Max was the maximum pixel value in that
image
Statistical Formulae