DIP Unit 2 (Enhancement, Binary, Colour)
DIP Unit 2 (Enhancement, Binary, Colour)
UNIT - 2
TYBSC Sem – VI
Lecturer - Dhawal S. Bhangale
IMAGE ENHANCEMENT IN
SPATIAL DOMAIN
Spatial domain
• Means working with pixel values, working
directly with the raw data.
• The modified image
can be expressed as,
g( x , y ) = T [ f( x , y ) ]
where T is the
Transformation applied
• Spatial domain transformations are carried out in
2 ways:
Point processing, Neighborhood processing.
• Point Processing:- Work with single pixel.
T is 1 X 1 operator.
• Identity transform; in this
the original image
don’t change. Modified Gray
Level
(output pixel
value) s
• Contrast Stretching:-
• We may get low contrast images due to poor
illumination or wrong setting of lens aperture.
Contrast stretching is Making dark portion darker
and bright portion brighter.
• It increases the dynamic range of modified image.
• Formula for contrast stretching is;
Original
HIGH
FREQUENCY
LOW
FREQUENCY
Step1: Step2:
Step3: Step4:
median filter
• Highpass Filtering
• Eliminates low frequency regions and enhance
high frequency region. Effect of applying this filter
on image may result in removal of background
and enhancement of fine details and edges.
• So it is also used to sharpen images.
• Consider this image with a sharp edge. If we
apply above mask on this image output will be;
•
• High boosted image
• Unsharp Masking: We can also get a sharp
image by subtracting a blurred version of image
from original image. Used for edge enhancement.
• Steps are given below:
– Blur filter the image
– Subtract blurred image from original image
– Multiply the result with some weight
– Add result obtained to the original image
• f’(m,n) = f(m,n) + [f(m,n) – ̿f (m,n)]
– f(m,n) – original image
– ̿f (m,n) – blurred version
– f‘(m,n) – sharped result
• Zooming
• Can be done by two methods;
– Replication, Interpolation
• Replication:-
• Simply replicating each row and column.
• This is very easy method of zooming, but if the
image is zoomed to larger sizes clusters of gray
levels are formed, making the image look patchy.
• Original image Zoomed image
• Linear Interpolation:-
• Average of two adjacent pixels along the row is
taken and placed between those pixels, same
operation is performed along the columns.
• Interpolation along rows;
v-row(m,n) = u(m,n); 0<=m<=M-1, 0<=n<=N-1
v-row(m,n+1) = ½{u(m,n) + u(m,n+1)}
0<=m<=M-1, 0<=n<=N-1
Interpolation along columns;
v-col(m,n) = u(m,n); 0<=m<=M-1, 0<=n<=N-1
v-col(m,n+1) = ½{u(m,n) + u(m+1,n)}
0<=m<=M-1, 0<=n<=N-1
Histogram
• It is a plot of the number of occurrences of gray
levels in the image against the gray-level values.
• provides more insight about image contrast and
brightness.
– The histogram of a dark image will be clustered
towards the lower gray level.
– The histogram of a bright image will be clustered
towards higher gray level.
– For a low-contrast image, the histogram will not be
spread equally, that is, the histogram will be narrow.
– For a high-contrast image, the histogram will have an
equal spread in the gray level.
• Histogram Linear Stretching
• We do not alter the basic shape of the histogram,
but we spread it to cover the entire range.
• New gray level to assign pixels to;
(s-max – s-min)
s = T(r) = (r – r-min) + s-min
(r-max – r-min)
• Where,
• s-max max gray level of output image
• s-min min gray level of output image
• r-max max gray level of input image
• r-min min gray level of input image
Histogram Equalization
• A perfect image is one which has equal number of
pixels in all its gray levels.
• Equalization is a process that attempts to spread
out the gray levels in an image so that they are
evenly distributed across their range.
l
• Ideal filter is not realizable using
physical components, but using
computer programs only.
• Ringing effect in low pass filtering:-
• With D0 = 10
Homomorphic Filtering
• An image f(n1,n2) is characterized by two
components;
– The amount of light incident on scene/object
(illumination) :- i(n1,n2)
– Amount of light reflected by the object
(reflection):- r(n1,n2)
• Image f(n1,n2) is formed by;
f(n1,n2) = i(n1,n2) . r(n1,n2)
where 0 < i(n1,n2) < infinity AND
0 < r(n1,n2) < 1; 0 indicates
total absorption and 1 indicates total reflection.
B B B
W B W
B W W
W W W
W W W
W B B
B W B
B B B
• NOT, XOR operation.
W B
B W
W W W
W B B
B W B
B B W
• Logical Opearations
STANDARD BINARY
MORPHOLOGICAL OPERATIONS
• Dilation
• The dilation operation is defined as,