Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views7 pages

DIP Lab 7

Lab 7 focuses on local enhancement and spatial domain filtering techniques for image processing. It discusses methods such as local histogram processing, neighborhood statistics, and various spatial filters, including smoothing and order statistic filters, to improve image quality. Practical activities are included to apply these concepts and evaluate their effectiveness in enhancing images.

Uploaded by

Bismah Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

DIP Lab 7

Lab 7 focuses on local enhancement and spatial domain filtering techniques for image processing. It discusses methods such as local histogram processing, neighborhood statistics, and various spatial filters, including smoothing and order statistic filters, to improve image quality. Practical activities are included to apply these concepts and evaluate their effectiveness in enhancing images.

Uploaded by

Bismah Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Lab 7

Local Enhancement and Spatial


Domain Filtering

The histogram processing methods, discussed in Lab.6, are global. These transformation
functions designed according to the gray-level distribution over the entire gray levels of an
image. They are good when we want to enhance the entire range of gray levels and not
suitable for enhancing details over small areas. These small areas have negligible influence
on designing the global transformation function. In this lab our objective to study the
transformation functions that are designed for small areas of gray levels in an image.

7.1 Enhancement Based on Local Histogram Processing

In spatial domain filtering square or rectangular neighborhood(block)is defined and


histogram in the local block is computed. The design of transformation functions are based
on the local gray-level distribution. Then the local enhancement transformation function
e.g histogram equalization or specification method is used to generate the transformation
function, which perform the gray level mapping for each pixels in the block. The center of
the block is moved to an adjacent pixel location and repeat this process is repeated we
reach to the last pixel in the image.

Since, the block only shifts one pixels each time the local histogram can be updated each
time without re-computing the histogram over all pixels in the new block. If utilizing
non-overlapping region shift, the processed image usually has an undesirable checkerboard
e↵ect.

Fig. 7.1 shows di↵erence between global histogram and local histogram processing. Fig.
7.1(a), Fig. 7.1(b),and Fig. 7.1(c) show noised and blurred image, output from applying
global histogram, and result from local histogram processing, respectively. We can see
significant visual enhancement in 7.1(c) over Fig. 7.1(b). In Fig. Fig. 7.1(b) the noise
contents were also enhanced. While, in Fig. 7.1(c) their e↵ect were minimized due the use
of 7 x 7 neighborhood which has too small influence to the global histogram specification.

32
Lab 7 Local Enhancement and Spatial Domain Filtering

Figure 7.1: (a) Input noised and blurred image (b) Output image after global histogram
processing (c) Output image after local histogram processing

7.2 Introduction to Local Enhancement Based on


Neighborhood Statistics

In addition to histogram processing, Local enhancement functions are also based on other
statistical properties of gray levels in the block i.e mean µs (x, y) and variance s (x, y).
Mean is used for averaging brightness and variance is used for contrast in an image. Lets
consider that Sxy represents a neighborhood subimage of size NS xy ; a block centered at
(x, y) and µs (x, y) in Eq. 7.1 and S (x, y) in Eq. 7.2 represent gray level mean and
standard deviation in Sxy , respectively. Let µG and G denote global mean and standard
deviation in image f (x, y). P
(s,t)✏Sxy f (s, t)
µS (x, y) = (7.1)
NS xy
P
(s,t)✏Sxy f (s, t) µS (x, y)
S (x, y) = (7.2)
2
NS xy
There are two methods to implement these statistical properties for local enhancement.
Mathematically, the first method is shown in Eq. 7.3. Where, A(x, y) is called local gain
factor which is inversely proportional to standard deviation shown in Eq. 7.4.
g(x, y) = A(x, y).[f (x, y) µS (x, y)] + µS ( x, y) (7.3)

µG
A(x, y) = k. ;0  k  1 (7.4)
S (x, y)
The method represented by Eq. 7.3 is implemented for input image Fig. 7.2(a) and 15 x 15
block which results in locally enhanced output image shown in Fig. 7.2(b).

The second method is represented by Eq. 7.2(a). Here the successful selection of
parameters (E, k0 , k1 , k2 ) requires experiment for di↵erent images. Where E cannot be too
large to a↵ect the general visual balance of the image and k0 < 0.5. The selection of Nxy
should be as possible to preserve detail and reduce computational load.

⇢ W
E.f(x, y), if [µx (x, y)  k0 µG ] [k1 G  s (x, y)  k2 G]
g(x, y) =
f(x, y), otherwise, . . . Eq. 7.2(a)

33
Lab 7 Local Enhancement and Spatial Domain Filtering

Figure 7.2: (a)Input image (b) Locally enhanced output image with 15 x 15 block

7.3 Local Enhancement Based on Spatial(Mask) Filtering

In this section we will focus spatial filtering and its contribution to the enhancement of an
image. A subimage Fig. 7.3(b) called f ilter, mask, kernal, template, or window is
masked with input image Fig. 7.3(a) as in Eq. 7.5. The values in the window are called
filter coefficients. Based upon the filter coefficient we can classified spatial filters as linear
filters(LF), nonlinear filters(NLF), lowpas filters(LPF), and highpass filters(HPF). base on
spatial filtering.
Xa X b
g(x, y) = !(i, j).f (x + i, y + j) (7.5)
i= a j= b

Specifically, the response of a 3 x 3 mask with a subimage with gray levels z1 , z2 ,z2 ,. . . ,z9 is
given in Eq. ??
9
X
R = w1 z1 + w2 z2 + . . . + w9 z9 = wi zi eq : shortmask (7.6)
i=1

Mask operation near the image border some part of the masks is located outside the image

Figure 7.3: Spatial Mask with w1, w2 etc as filter coefficients

plane; to handle this problem we use

34
Lab 7 Local Enhancement and Spatial Domain Filtering

1. Discard the problem pixels (e.g. 512 x 512 input becomes 510 x 510 output image if
the mask is 3 x 3)

2. Zero padding at the first and last rows and columns. So, 512 x 512 image become
equal to 514 x 514 intermediate output image. To get the final output 512 x 512
image the first and last rows and columns are discarded to.

7.3.1 Smoothing Spatial Filtering

Smoothing filters are also called LPF. Because it attenuate or eliminate high-frequency
components that characterize edges and sharp details in an input image. It results in
blurring or noise reduction. Blurring is usually used in preprocessing steps, e.g., to remove
small details from an image prior to object extraction or to bridge small gaps in lines or
curves. These filters are based on neighborhood averaging and in general M x M mask with
the same filter coefficients, Eq. 7.7 are used to design a LPF. Some filters have weighted
masks. To preserve the nearest neighborhood e↵ect they are weighted with some weight
factor. These filters produce some undesirable edge blurring.
1
wi = ; 1  wi  M (7.7)
M2

7.3.2 Order Statistic Nonlinear Filters

The order statistic filters are nonlinear filters whose response is based on ordering (ranking)
the pixels contained in the image area surrounded by the filter, and then the center value is
replaced with the value determined by the ranking result. Based on ranking criteria we can
classified order statistic filters into three types.

7.3.3 Median( 50th Percentile) Filter

The transformation function of median filter is given in Eq. 10.7. Median filters are useful
in situation where impulse noise, salt and pepper noise. The median, ⇠, of masked
neighbors, zk (x, y), is calculated by ranked in ascending order of gray levels. Ultimately,
half of the pixels above the median, ⇠, and half are below than ⇠. And finally assigned to
the output pixel R(x, y), at (x, y).

R(x, y) = ⇠(zk (x, y)|k = 1, 2, . . . , 9) (7.8)

Generally, The transfer function of median filter forces the output gray levels to be more
2
similar to the neighbors. If the isolated group of pixels have area A  n2 ; are eliminated by
n x n median filter. Conversely, the larger cluster are less a↵ected by it.

35
Lab 7 Local Enhancement and Spatial Domain Filtering

7.3.4 Min (0th Percentile) Filter

The transformation function of min f ilter is given by Eq. 7.9.

Rk (x, y) = min(zk |k = 1, 2, 3, . . . , 9) (7.9)

These filters are applied, similar to the median filters, on input images to result masked
intermediate outputs zk (x, y) but the ranking and assigning criteria is di↵erent from median
filters. The assignment of minimum value, to the output zk (x, y), in the neighborhood make
it useful to remove salt noise.

7.3.5 Max (100th Percentile) Filter

The transformation function of min f ilter is given by Eq. 7.10.

Rk (x, y) = max(zk |k = 1, 2, 3, . . . , 9) (7.10)

These filter are applied, similar to min filters, on input images to result masked
intermediate outputs zk (x, y) but the ranking and assigning criteria is di↵erent from both
mean and median filters. The assignment of maximum value, in the neighborhood, to the
output zk (x, y) make them useful to remove pepper noise.

7.4 Practical

Use these basic concept and perform the following activities:

7.4.1 Activity No.1

Use the figures accompanied with this lab and generate the results discussed in Sec. 7.1.

7.4.2 Activity No.2

Take the image in Fig. 7.4 and take out hidden object in the background using the
techniques discussed in Sec. 7.1.

7.4.3 Hint for Activity No.2

Apply a 3 x 3 moving average filter on the input image and detect areas of higher contrast
like edges and then use the co-efficient in g(x, y) to produce the output image.

7.4.4 Activity No.3

Take the input image shown in Fig. 7.5 and apply smoothing filter mask of order: i 3 x 3,
ii 5 x 5, iii 9 x 9, and iv 15 x 15. Sketch the output image and comment on your
results.

36
Lab 7 Local Enhancement and Spatial Domain Filtering

Figure 7.4: Input image having hidden object in background

Figure 7.5: Input image having hidden object in background

7.4.5 Activity No.4

Take a noised image and prove that which order statistic f ilter is best.

7.4.6 Hint for Activity No. 4

Read an image and add salt and pepper noise with it using imnoise() function. And then
write you code to implement Eq. 10.7, ??, and ??.

7.4.7 Questions

1. What is enhancement and what is its objective?

2. What is the basic di↵erence between histogram processing and spatial domain
filtering?

37
Lab 7 Local Enhancement and Spatial Domain Filtering

3. Explain the deference between local histogram and global histogram.

4. How the checkerboard e↵ect is produced in an image and how we can avoid it?

5. Discuss the limiting e↵ect of repeatedly applying a 3 x 3 lowpass spatial filter to a


digital image; ignoring the border e↵ects.

6. What will be the size of intermediate output image when we use padding for mask of
order 7 x 7?

7. What will be the size of output image when we are not using padding for mask of
order 7 x 7?

8. What is salt and pepper noise and which filter is useful to remove it at a time.

9. What are the factors which e↵ect the designing of order statistic filters.

10. Which type of filter is useful for bridging the gaps?

38

You might also like