3.1 Background: - Specific Application-Problem Oriented

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 78

Image Enhancement in the Spatial Domain

3.1 Background
Specific applicationproblem oriented
Trial and error is necessary
Spatial domain will be denoted by the expression
g(x,y)=T[f(x,y)], refers to the aggregate of pixels composing
an image

The simplest form of T: s=T(r)


Contrast stretching: (Fig. 3.2 (a))
Thresholding function: binary image (Fig. 3.2)
Masks (filters, kernels, templates, windows)
Enhancement : mask processing or filtering

Mohammed Dwikat CIS 133381 Multimedia II

Contrast stretching :darkening the levels


below m and brightening the levels above m in
the original image
Thresholding: mapping previosly

Mohammed Dwikat CIS 133381 Multimedia II

3.2 Some gray level transformations


Three basic types of functions used for image
enhancement
Linear
logarithmic
Power-law

Mohammed Dwikat CIS 133381 Multimedia II

3.2.1 Image negatives


Is obtained by using the negative transformation s=L-1-r
Produces the equivalent of a photographic negative
Suited for enhancing white or gray detail embedded in dark regions
of an image

L=5 denotes the link


S=L-1-r
S (4) =5-1-4=0
S (3) =5-1-3=1
S (2) =5-1-2=2

Mohammed Dwikat CIS 133381 Multimedia II

3.2.2 Log transformations


The general form of the log transformation : s=clog(1+r)
Expand the values of dark pixels while compressing the highlevel values
Compress the dynamic range of images with large variations
3.2.3 Power-law transformation

The basic form:


Gamma correction
CRT device have an intensity-to-voltage response that is a
power function
Produce images that are darker than intended
Is important if displaying an image accurately on a
computer screen

s cr

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Low r: wash-out in the background (Fig. 3.8 r =0.3)


High r: enhance a wash-out appearance (Fig. 3.9 r =5.0 areas are too
dark)

3.2.4 Piecewise-linear transformation functions


Advantage: the form of piecewise functions can be arbitrary
complex over the previous functions
Disadvantage: require considerably more user input
Contrast stretching
One of the simplest piecewise function

Increase the dynamic range of the gray levels in the image


A typical transformation: control the shape of the transformation
r1=r2 s1=0 and s2=L-1

Gray level slicing


Highlight a specific range of gray levels
Display a high value for all gray levels in the range of interest and a
low value for all other gray levels : produce a binary image
Brighten the desired range of gray levels, but preserves the
background and gray level tonalities (Fig. 3.11)
The higher order bits (especially the top four) contain the majority of
the visually significant data
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Bit-plane slicing
Highlight the contributions made to total image
appearance by specific bits
higher order bits contain the majority of the visually
significant bits
Separating a digital image into its bit plane is suitable
for analyzing the relative importance played by each bit
of the image
Useful for image decomposition
The binary image for bit-plane 7 like a thresholding
function

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.3 Histogram processing


Histogram of a digital image--the gray levels in the range[0,
L-1]
The sum of all components of a normalized histogram is equal to 1
Low contrast: a narrow histogram, a dull, wash-out gray look
High contrast : cover a broader range of the gray scale and the distribution
of pixels is not too far uniform, with very few vertical lines being much
higher than the others
A great deal of details and high dynamic range

3.3.1 Histogram equalization (Histogram linearization)


Histogram of S=T (r) 0 r1
Produce a level s for every pixel value in the original image, the
transformation satisfies the following conditions:
(1) T(r) is single-valued and monotonically increasing in the
interval
0 r 1; and
(2) 0 T ( r ) 1 for 0 r 1

r =T-1(s) 0 s 1
Mohammed Dwikat CIS 133381 Multimedia II

Mohammed Dwikat CIS 133381 Multimedia II

The goal of this operation--produce an output


image that has a uniform histogram
The results are predicable and the method is simple
n
to implement
s T (r ) p (r ) 0 r 1 k 0,1 ..., L 1
n
Probability density function continuous
For discrete values: probability and summation
instead of density functions: Pr(rk)( the discrete
version of the transformation function
k

j 0

j 0

Spread the histogram of the input image so that the


levels of the histogram
Equalized image will span a fuller range

The results are predicable, and the method is easy


to implement automatically
Mohammed Dwikat CIS 133381 Multimedia II

To enhance the contrast of a monochrome image


Construct a histogram of the grey levels present
256 bins representing 0 through 255
Each bin is the number of pixels with that grey level

Remap the grey levels so that the histogram is (roughly) flat


To ensure that every collection of N adjacent bins has the same pixel
count:
All pixels within one bin in the input image will be within one
(possibly different) bin in the output image. That is, two pixels with
equal grey level in the input image will have equal grey level in the
output image.
For some adequately small value of N (i.e., at some adequately fine
scale), collections of N adjacent bins will not have the same pixel
count.
The pixels must be dithered to equally fill all bins, including those
that would not have had any pixels at all. Note that dithering adds a
(pseudo) random value to the pixel's grey level.

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Mohammed Dwikat CIS 133381 Multimedia II

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.3.2 Histogram matching (specification)


Enhancement based on a uniform histogram is not the best
approach
It is useful sometimes to specify the shape of the histogram that we wish to
have

Generate a processed image that has a specified histogram


Suitable for interactive image enhancement
Difficulty--build a meaningful histogram
^
The smallest integer in the interval [0,L-1] such that G ( Z sk ) 0
The procedure for histogram matching (Page 99)

Mohammed Dwikat CIS 133381 Multimedia II

Two pixels with equal grey level in the input image will not
necessarily have equal grey level in the output image .

Remapping without dithering seems the most appropriate


for scientific data
Improve the visual information as must as possible
without intentionally adding randomness.

3.3.3 Local Enhancement


Enhance details over small areas--- in the neighborhood of
every pixel in the image
Local histogram equalization

Mohammed Dwikat CIS 133381 Multimedia II

Linear or non-linear transformation


Based on gray level distribution around the neighborhood of a pixel
(convolution mask)
Define a square or rectangular neighborhood and move the center
of the area
At each location, the histogram of the points in the neighborhood
is computed
A histogram equalization or specification function is obtained
This function is use to map the gray level of the pixel centered in
the neighborhood
The center of the neighborhood is then moved to an adjacent pixel
Use very little a priori knowledge about the image contents
The choice of the transformation, size, and shape of the neighborhood
depends on the size of objects

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.3.4 Use of histogram statistics for image enhancement


Use statistical parameters obtained from the histogram
Estimate of occurrence of gray level ri
The nth moment of r about the mean is defined as (r ) (r m) p(r )
L 1

Global mean and variance , local mean and variance


mS rs ,t p( rs ,t )
( s ,l )S
The mean value of the pixel in Sxy is

i 0

xy

xy

The gray level variance of the pixels in the region is given by


The local mean is a measure of average gray level
The variance is a measure of contrast
Using Local mean and variance is flexible and depends on image
appearance

Mohammed Dwikat CIS 133381 Multimedia II

Continue
Enhance low contrast of an area
Consider the pixel at a point (x,y) as a candidate for processing
mS k m M G
if
xy

determine whether the contrast if an area makes it a candidate for


S k2 DG
enhancementif
A summary of the enhancement
xy

E f ( x, y ) if mS xy k 0M G and k1DG S xy k2 DG

g ( x, y ) f ( x, y )
otherwise

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.4 Enhancement using arithmetic/logic


operations
Image subtraction g(x,y)=f(x,y)-h(x,y)
Masking
is referred to as ROI (region of interest)
interest processing
Isolate an area for processing

Arithmetic operations

Addition:
Subtraction:
Multiplication: used to implement gray-level rather than binary
Division:

Logic operations

And: used for masking (Fig. 3.27)


Or:used for masking
Not operation: negative transformation
Also are used in conjunction with morphological operations

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.4.1 Image subtraction


The difference between two images f(x,y) and h(x,y) is
expressed as g(x,y)=f(x,y)-h(x,y)
Enhance the difference of two images
Contrast stretching transformationuseful for evaluating the effect of
setting to zero the lower-order planes (Fig. 3.28(d))
Mask mode radiography (Fig 3.29)

Sort of scaling : solve image values outside form the


range 0 to 255 (-255 to 255)
(1) Add 255 to every pixel and divide by 2: fast and simple to
implement, but the full rang of the display may not be used
(2) more accuracy and full coverage of the 8-it range
The values of the minimum difference is obtained and its negative
added to all the pixels in the difference image
All the pixels in the image are scaled to [0,255] by multiplying
255/Max

3.4.2 Image averaging


g(x,y)=f(x,y)+(x,y) (assume every pair of coordinates (x,y)
the noise is uncorrelated and has zero average value)
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Reduce the noise content by adding a set of noise images


{gi(x,y)}
An image is formed by averaging K different noisy images
As k increases, the variability of the pixel values at each location (x,y)
decreases
The image gi(x,y) must be registered in order to avoid the introduction of
blurring
Use integrating capabilities of CCD or similar sensors for noise reduction
by observing the same scene over long periods of time

3.5 Basics of spatial filtering


Sub-image: (filter, mask, kernel, template or window)
Frequency domain:
Spatial domain
Linear spatial filtering: is give by a sum of products of the filter
coefficients R=
In general, linear filtering of an image with a filter mask of size MxN is
given by g(x,y)
Convolving a mask with an image by pixel-by-pixel basis
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.6 Smoothing spatial filters


Used for blurring and for noise reduction
Blurring is used for removal of detail and bridging of
small gaps in lines or curves

3.6.1 Smoothing linear filters


Averaging filter (low pass filter)
Replace the value of every pixel by the average of the
gray levels in the neighborhood by the filter mask
Reduce sharp transition (such as random noise)
Blur edges
The average of the gray levels in the 3x3 neighborhoods
Averaging with limited data validity
only to pixels in the original image in a pre-defined interval of
invalid data
Only if the computed brightness change of a pixel is in some
pre-defined interval
Mohammed Dwikat CIS 133381 Multimedia II

Weighted average (Fig. 3.34)


Blur an image for the purpose getting a gross representation of
objects of interest
The intensity of smaller objects blends with the background and
larger objects become blob-like and easy to detect (Fig. 3.36)

3.6.1 Order Statistics filters (rank filters)


Nonlinear spatial filter based on ordering (ranking)
Median filter
Remove impulse noises (salt and pepper noises)
Represent 50 percent of a ranked set
Large clusters are affected considerably less

Min filter
Max filter--useful in finding the brightest points
Non-linear mean filter
Arithmetic mean
Harmonic mean
Geometric mean
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.7 Sharpening spatial filter


Highlight fine detail or enhance detail
Enhance detail that has been blurred
Application ranging from electronic printing and medical
imaging to industrial inspection
Can be accomplished by digital differentiation
3.7.1 Foundation
Sharpening filter based on first- and second-order
derivatives
Definition of first derivatives

Must be zero in flat segment


Muse be nonzero at the onset of a gray level step or ramp
Must be nonzero along the entire ramp (thick edge)
f
Nature of first Derivate
f ( x 1) f ( x )
x
Produce thick edges
Has a strong response to gray-level step

Mohammed Dwikat CIS 133381 Multimedia II

Definition of second derivatives: is better suited than


the first-derivative for image enhancement
Must be zero in flat areas
Muse be nonzero at the onset and end of a gray level
step or ramp
Must be zero along ramps of constant slope
Nature of a second order derivate xf f ( x 1) f ( x 1) 2 f ( x)
2

Produces finer edges


Enhance fine detail (including noise) much more than a first
order derivate for example: a thin line
The response at an isolated point is stronger than first Der.
Has a transition form positive back to negative
Produce a double response to a gray-level step

Highlight the fundamental similarities and differences


between first- and second- order derivatives (Fig.
3.38)
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.7.2 Use of second derivatives for enhancement The


Laplacian
Consists of defining a discrete formulation of the secondderivative and then construct a filter mask
Isotropic filter (rotation invariant): independent of the direction
of the discontinuities in the image
Development of the method (Laplacian)
Is the simplest isotropic derivative operator (linear operator)
A function of f(x,y) of two variables is defined as f f f
x y
Filter mask used to implement the Laplacian (Fig. 3.39)
2

Diagonal or no diagonal

Highlight gray-level discontinuities and de-emphasizes regions


with slowly varying gray levels
Shortcoming : Produces images that grayish edge lines and
other discontinuities, all superimpose on a dark, featureless
background image
Mohammed Dwikat CIS 133381 Multimedia II

Continue
To overcome the shortcoming of the operation
Enhance small detail and preserve background tonality
recover background features while preserving the
sharpening effect
By adding the original and Laplacian images (Fig. 3.40)

g ( x, y )

f ( x, y ) 2 f ( x, y )
f ( x, y ) 2 f ( x , y )

A negative center coefficient--subtract sharpen result


A positive center coefficientadd sharpen result

Simplification
Composite Laplacian mask
no diagonal neighbors
Diagonal neighborssharper than no diagonal neighbors

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Unsharp masking and high-boost filtering


Un-sharp masking expression-subtract a blurred
version of an image from the image itself
The dark room photography

f s ( x , y ) f ( x , y ) f ( x, y )

A further generalization of un-sharp masking : highf hb ( x, y ) Af ( x, y ) f ( x, y )


boost filtering
Expression for computing a high-boost filtered image
The center coefficient of the Laplacian mask:negative or
positive
Can be implemented with either one of these mask, with A1

3.7.3 Use of first derivatives for enhancement-The


f
Gradient
x
G
f

f
G

The gradient of f at coordinates (x,y) is


y
x

Mohammed Dwikat CIS 133381 Multimedia II

The components of the vector are linear operator


f
The magnitude of this vector is
( x )
G
f G x G y

f mag (f )

2 1/ 2
x
2
y

f
( )2
y

1/ 2

or

Preserve relative changes in gray levels, but the isotropic


property is lost
Is not a linear operator

The partial derivatives of the gradient vector are not


rotation invariant
Give the same result only for vertical and vertical edges
The magnitude of the gradient vector is rotation invariant

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Approximate the magnitude of the gradient by using


absolute values
Lost isotropic feature property

Vertical and horizontal edges preserve the isotropic


properties only for multiples of 90
Mask of odd sizes

Robert operator
Robert Ross-gradient operators

An approximation using absolute values (3.7-18)

Sobel operator
Use a weight value of 2 to achieve some smoothing by giving more
importance to the center point
Constant or slowly varying shades are eliminated

Prewitt operator
Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

Image Enhancement in the Spatial Domain

Mohammed Dwikat CIS 133381 Multimedia II

3.8 Combining spatial enhancement methods


Application of several complementary enhancement
techniques
Laplacian
Adv. : highlight fine detail
Dis-adv: produce noisier results than the gradient
Gradient

Enhance prominent edges


Has a stronger response in area of significant gray-level transitions

Further lower the response of fine detail and noise for


the gradient
Mask the Laplacian image with a smoothed version of the gradient
image
Smooth the gradient and multiply it by the Laplacian image
Preserve details in the strong area while reducing noise in the
relatively flat areas

Mohammed Dwikat CIS 133381 Multimedia II

Enhance the image by sharpening it and bringing out


more detail (Fig. 3.46)
Nature of the image: the narrow dynamic range of the gray
levels and high noise content

Mohammed Dwikat CIS 133381 Multimedia II

Q) What effect would setting to zero the lower-order bit


planes have on the histogram of an image in general?

A) The number of pixels having different gray


level values would decrease, thus causing the
number of components in the histogram to
decrease. Since the number of pixels would not
change, this would cause the height some of the
remaining histogram peaks to increase in general.
Typically, less variability in gray level values will
reduce contrast.

Mohammed Dwikat CIS 133381 Multimedia II

Q) What would be the effect on the histogram if we set


to zero the higherorder bit planes instead?

A) The most visible effect would be significant


darkening of the image. For example, dropping
the highest bit would limit to 127 the brightest
level in an 8bit image. Since the number of pixels
would remain constant, the height of some of the
histogram peaks would increase. The general
shape of the histogram would now be taller and
narrower, with no histogram components being
located past 127.
Mohammed Dwikat CIS 133381 Multimedia II

Q) Explain why the discrete histogram equalization


technique does not, in general, yield a flat histogram.

A) All that histogram equalization does is remap


histogram components on the intensity scale. To
obtain a uniform (flat) histogram would require in
general that pixel intensities be actually
redistributed so that there are L groups of n/L
pixels with the same intensity, where L is the
number of allowed discrete intensity levels and n
is the total number of pixels in the input image.
The histogram equalization method has no
provisions for this type of (artificial) redistribution
process
Mohammed Dwikat CIS 133381 Multimedia II

You might also like