0% found this document useful (0 votes)
11 views14 pages

DIP Lab 8

The document outlines a lab report on local enhancement and spatial domain filtering techniques in image processing, focusing on methods to improve image quality through histogram processing and various filtering techniques. It includes objectives, required equipment, detailed activities with explanations, and answers to questions related to image enhancement concepts. The conclusions emphasize the effectiveness of localized processing methods in enhancing visual quality and reducing noise in 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)
11 views14 pages

DIP Lab 8

The document outlines a lab report on local enhancement and spatial domain filtering techniques in image processing, focusing on methods to improve image quality through histogram processing and various filtering techniques. It includes objectives, required equipment, detailed activities with explanations, and answers to questions related to image enhancement concepts. The conclusions emphasize the effectiveness of localized processing methods in enhancing visual quality and reducing noise in 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/ 14

DEPARTMENT OF ELECTRICAL AND

COMPUTER ENGINEERING BATCH 2022-26

NAME: BISMAH ASIF, AREEBA SANA, URAIDAH ANJUM


REGISTRATION-ID: 222650,220610,220568
SUBMITTED TO: Ma’am Zoafshan
COURSE: DIP
DATE: 01-May-2025
Local Enhancement and Spatial Domain Filtering

Objective:
The objectives of this lab are to study the transformation functions that are designed for small areas of
gray levels in an image.

Equipment’s Required:
▪ MATLAB installed on PCs.
▪ Sample images provided.

Activity No.1:
Use the figures accompanied with this lab and generate the results discussed in
Sec. 7.1.
Code:

Page | 1
Page | 2
Explanation:
I improved the contrast of a grayscale image using local histogram processing. For each
pixel, I looked at the surrounding area and created a histogram showing how often each
intensity level appeared. Then, I adjusted the pixel’s value based on the cumulative sum
of the histogram up to that intensity. This process enhances details in the image by
making local features stand out more clearly.

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.
Code:

Page | 3
Explanation:

I processed a grayscale image to sharpen its edges. For each pixel, I looked at the
surrounding 3×3 area and found the average intensity of those nearby pixels. Then, I
measured how different the pixel's intensity was compared to this average—this
difference is called the gradient magnitude. Using this value as a weight, I adjusted the
pixel's intensity, making edges stand out more and improving the contrast in the final
image.
Page | 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.

Code:

Page | 5
Page | 6
Explanation:

I applied different smoothing filters to a grayscale image, using sizes 3×3, 5×5, 9×9, and
15×15. Each filter works by averaging the pixel intensities in a small neighborhood
around each pixel. The larger the filter size, the more neighboring pixels it considers,
leading to stronger smoothing.

Effect of increasing filter size:


As the filter size grows, the image becomes more blurred. This happens because larger
filters combine more pixel values, reducing sharp details and making the image look
softer.

Activity No.4:
Take a noisy image and prove which order statistic filter is best.

Hint for Activity No. 4


Read an image and add salt and pepper noise with it using imnoise() function.
And then write your code to implement Eq. 7.10.
Code:

Page | 7
Page | 8
Page | 9
Explanation:
I applied three different filters—max, min, and median—to a noisy grayscale image.
The image had "salt and pepper" noise, meaning some pixels were randomly bright
(white) or dark (black).

Each filter worked in a small 3×3 neighborhood around each pixel:


➢ Max filter: Replaced each pixel with the highest intensity in its neighborhood.
➢ Min filter: Replaced each pixel with the lowest intensity in its neighborhood.
➢ Median filter: Replaced each pixel with the middle value of its neighborhood.

These filters helped clean up the noise while keeping important image details, making
the final version clearer and smoother.

Questions:
1. What is enhancement and what is its objective?
➢ Enhancement is the process of improving certain aspects of an image to make it more visually
appealing or suitable for a specific application.
➢ Its objective is to enhance important features, such as contrast, brightness, and sharpness, while
reducing unwanted artifacts or noise.

2. What is the basic difference between histogram processing and spatial domain
filtering?
➢ The basic difference between histogram processing and spatial domain filtering is that
histogram processing operates on the distribution of pixel intensities in the image, adjusting
their values globally or locally based on the histogram characteristics, whereas spatial domain
filtering modifies pixel values based on their spatial relationships within a neighborhood.

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


➢ Local histogram processing considers the distribution of pixel intensities within localized
regions or neighborhoods of the image, enabling enhancement tailored to specific areas.
➢ In contrast, global histogram processing considers the entire image's intensity distribution,
applying enhancement uniformly across the entire image.

4. How is the checkerboard effect produced in an image and how we can avoid
it?
The checkerboard effect occurs when alternating bright and dark regions appear in an image due
Page | 10
to uneven spatial filtering. It can be avoided by using appropriate filter sizes and techniques that
preserve image details while reducing noise or artifacts.

5. Discuss the limiting effect of repeatedly applying a 3 x 3 lowpass spatial filter


to a digital image: ignoring the border effects.
Repeatedly applying a 3x3 lowpass spatial filter to a digital image can lead to loss of high-
frequency information, resulting in a blurred appearance and loss of image detail.

6. What will be the size of intermediate output image when we use padding for
mask of order 7 x 7?
When using padding for a mask of order 7x7, the size of the intermediate output image would be
larger than the original image due to the addition of padding pixels.

7. What will be the size of output image when we are not using padding for mask
of order 7 x 7?
Without using padding for a mask of order 7x7, the size of the output image would be smaller
than the original image due to the loss of border pixels during convolution.

8. What is salt and pepper noise and which filter is useful to remove it at a time.
• Salt and pepper noise consists of random occurrences of bright and dark pixels in an image.
• A median filter is useful for removing salt and pepper noise while preserving image details.

9. What are the factors which affect the designing of order statistic filters.
The factors that affect the design of order statistic filters include the size of the filter mask, the
choice of order statistic (e.g., min, max, median), and the desired trade-off between noise
reduction and preservation of image features.

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


• Morphological filters, such as dilation and erosion, are useful for bridging gaps or connecting
broken structures in an image.

Page | 11
Conclusions:

In this lab, we learned how to improve image quality using local enhancement techniques and
spatial filtering. By applying local histogram processing, we observed how enhancing details
within small sections of an image makes them clearer and more visually appealing. We also used
different statistical filters, including max, min, and median filters, to remove "salt and pepper"
noise—random black and white pixels that distort the image. These filters helped clean up the
noise while preserving important details, making the final image much smoother. Overall, these
methods highlight the importance of focusing on localized image processing to enhance visual
quality and reduce unwanted artifacts, which plays a crucial role in various image enhancement
applications.

Page | 12
Page | 13

You might also like