0% found this document useful (0 votes)
26 views31 pages

Week 5 Image Enhacement (Sharpening Noise Updated)

The document discusses image enhancement techniques, specifically sharpening and noise reduction. It covers: 1. Sharpening images enhances edges and fine details to make images appear sharper and more defined. Common sharpening techniques include basic sharpening filters that increase contrast along edges. 2. Noise in images refers to random pixel variations that do not represent actual image features. Noise reduction techniques aim to remove or reduce noise while preserving important image details. Median filters are commonly used to reduce salt and pepper noise. 3. The median filter works by replacing each pixel with the median value of neighboring pixels, smoothing out noise while retaining edges. OpenCV's cv2.medianBlur() function can apply median filtering to remove noise from

Uploaded by

Abdullah Afzal
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)
26 views31 pages

Week 5 Image Enhacement (Sharpening Noise Updated)

The document discusses image enhancement techniques, specifically sharpening and noise reduction. It covers: 1. Sharpening images enhances edges and fine details to make images appear sharper and more defined. Common sharpening techniques include basic sharpening filters that increase contrast along edges. 2. Noise in images refers to random pixel variations that do not represent actual image features. Noise reduction techniques aim to remove or reduce noise while preserving important image details. Median filters are commonly used to reduce salt and pepper noise. 3. The median filter works by replacing each pixel with the median value of neighboring pixels, smoothing out noise while retaining edges. OpenCV's cv2.medianBlur() function can apply median filtering to remove noise from

Uploaded by

Abdullah Afzal
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/ 31

CT029-3-2 Imaging and Special Effects

WEEK 4
INTRODUCTION TO IMAGE ENHANCEMENT
(SHARPENING & NOISE REMOVAL)

CT070-3-3 Design Patterns Overview of Special / Visual Effects SLIDE 1


Topic & Structure of The Lesson

1. Brightness and Contrast Adjustment


2. Color Adjustment
3. Sharpening and Blurring
4. Noise Reduction
5. Histogram Equalization

CT070-3-3 Design Patterns Overview of Special / Visual Effects SLIDE 2


Recap : Lecture 4
• Image enhancement is the process of adjusting / manipulating the digital images

• Brightness refers to the overall lightness or darkness of the image.

• Contrast is the difference in brightness between objects or regions.

• HSV - It is a 3-dimensional color space


– Hue - represents the color (blue, red, green, etc.), Its value ranges from 0 to 360*.

– Saturation -represents the amount of purity or colorfulness of a color.

– Value - represents the lightness or darkness of a hue.



CT070-3-3 Design Patterns Overview of Special / Visual Effects SLIDE 3
3. Sharpening images

• Sharpening is the process of enhancing the edges


and fine details in an image to make it appear
sharper and more defined.

• helps to bring out the details and features in an


image, making it more visually appealing and
easier to understand.

• Sharpening can be used to correct blur or softness


in an image and can be applied using a variety of
techniques.

Module Code & Module Title Slide Title SLIDE 4


Sharpening images

• It's a digital image processing method that increases the contrast


along the edges to make them visually sharper.

Module Code & Module Title Slide Title SLIDE 5


How Sharpening Works:

1. Edge Detection:
The sharpening process typically involves identifying edges within the image.
Edges are areas where there's a significant change in color or brightness.

2. Contrast Enhancement:
Once the edges are identified, the contrast along these edges is increased.
The pixels on either side of an edge are adjusted to intensify the transition
between them. This makes the edges more distinct.

Module Code & Module Title Slide Title SLIDE 6


Techniques for Sharpening:

• Basic Sharpening Filters: Simple


sharpening filters like the
"sharpen" filter increase the
contrast along the edges by
highlighting differences in
adjacent pixel values.

Module Code & Module Title Slide Title SLIDE 7


Application:

• Sharpening is commonly used in


- photography, image editing, and computer vision.

• It can improve the visual quality of images, especially those that


might have become slightly blurred during capture or processing.

• However, excessive sharpening can introduce artifacts and noise,


so it's essential to find a balance to maintain a natural look.

Module Code & Module Title Slide Title SLIDE 8


Differences: Contrast adjustment Vs sharpening
• Focus:
– Contrast adjustment primarily affects the overall tonal range and brightness
distribution of an image.
– Sharpening, on the other hand, specifically targets edges and fine details to
enhance their clarity.
• Impact:
– Contrast adjustment affects the entire image uniformly, altering the
perception of brightness and color intensity.
– Sharpening selectively enhances edges and details, leaving other areas
unaffected.

Module Code & Module Title Slide Title SLIDE 9


Relationship: Contrast adjustment Vs sharpening

• Combined Effect:
– Often, contrast adjustment and sharpening are used together in image
processing workflows.

– Applying contrast adjustment first can improve the overall visibility of the
image,
– making subsequent sharpening more effective by enhancing the edges and
details that have become more distinguishable.

• Both contrast adjustment and sharpening play crucial roles in improving the visual
quality of images, and their combined use can significantly enhance the overall
appearance of an image.
Module Code & Module Title Slide Title SLIDE 10
4. Noise Reduction

Module Code & Module Title Slide Title SLIDE 13


What is Noise?

• In image processing, noise refers to random variations in pixel brightness or


color that do not represent the actual features of the image.

• It can occur due to various factors such as electronic interference, sensor


limitations, environmental conditions, or transmission errors.

• Noise can degrade the quality of an image, making it harder to extract useful
information or affect the visual appearance by adding unwanted artifacts.

Module Code & Module Title Slide Title SLIDE 14


Example

• Salt and pepper noise is generally caused by


– errors in data transmission,
– failure in memory cell or
– analog-to-digital converter errors.

• Normally if there is black dots in the image, we called it pepper noise and
• if there is white dots in the image, we called it salt noise.

Module Code & Module Title Slide Title SLIDE 15


Noise

Module Code & Module Title Slide Title SLIDE 16


Example

• An image infected with salt-and-pepper noise. The noise is easily


recognized in both the image- and the number representations

Module Code & Module Title Slide Title SLIDE 17


Example continued

• Zoom in on the image and look closer at particular pixel values.


– What we can see is that the noise is isolated pixels having a value of
either 0 (black) or 255 (white), such noise is denoted salt-and-pepper
noise.

• By isolated we mean that they have a value very different from their
neighbors.

• We need somehow to identify such pixels and replace them by a value


which is more similar to the neighbors.

Module Code & Module Title Slide Title SLIDE 18


Removing noise from images

• Noise reduction is the process of removing or reducing unwanted noise or


artifacts from an image.

• It is important because it can improve the visual quality and clarity of the
image and make it easier to analyze or process using computer algorithms.

• There are several techniques for reducing noise, including using filters such as
the median filter.

• It is important to apply noise reduction judiciously to avoid blur or loss of


detail in the image.

Module Code & Module Title Slide Title SLIDE 19


Solution

• One solution is to replace the noise pixel by the mean value of


the neighbors.
• Say we use the eight nearest neighbors for the noise pixel at
position (1,1) in the image patch in Fig

This results in the noise pixel being replaced by 181, which is


more similar to the neighbors.
Module Code & Module Title Slide Title SLIDE 20
Removing noise from images

• One common method for removing noise from images using OpenCV and
Python is to use a median filter.

• The median filter works by replacing each pixel in the image with the
median value of a set of neighboring pixels.

• This can help to smooth out noise and reduce artifacts in the image.

• Here is an example of how to remove noise from an image

Module Code & Module Title Slide Title SLIDE 21


Removing noise - using the cv2.medianBlur() function in OpenCV:

Module Code & Module Title Slide Title SLIDE 22


IMAGE
RESTORATION
Median Filter
Maximum and Minimum Filters

1
Cont.

a. Salt and peppernoise b. Median filtered image (3x3)


Figure (2.14): Median Filter

5 5 6
Example : Given the following 3×3 neighborhood (window ) : 3 4 5
3 4 7
• Sort the values in window (ascending order) (3,3,4,4,5,5,5,6,7)
• Then we select the middle value ,in this case it is 5. 5 5 6
• The middle value 5 is then placed in center location. 3 5 5
3 4 7
Module Code & Module Title Slide Title SLIDE 24
Median Filter Procedure
■ The window is overlaid on the upper left corner of the image, and the median value is
determined.
■ This value (median) is put into the output image (buffer) corresponding to the center location
of the window.
■ The window is then slide one pixel over, and the process is repeated
■ When the end of the row is reached, the window is slide back to the left side of the image
and down one row, and the process is repeated.
■ This process continues until the entire image has been processed.

Not: the outer rows and columns are not


replaced.. And these “wasted” rows and columns
are often filled with zeros (or cropped off the
image). For example, with 3X3 mask, we lose
one outer row and column, a 5X5 mask we lose
two rows and columns.
Module Code & Module Title Slide Title SLIDE 25
Example: Filter the following sub-image by (3×3 )median
filter (Order Statistic)
1 4 0 1
2 2 4 2 Pixel value at
I= Input Image the center
1 0 1 0
location
1 2 1 0

1 4 0 1
Solution:
2 2 4 2
1. Overlade (3x3) window at the upper left corner of the input image :
1 0 1 0
2. Sort the pixels values (ascending order) : 0, 0, 1, 1, 1, 2, 2, 4, 4 1 2 1 0

3. Determine the median value by selecting the middle : 0, 0, 1, 1, 1, 2, 2, 4, 4


1 4 0 1
4. Replace the pixel at the center location by median value 2 1 2
1 0
5. The window is then slide one pixel over, and Repeat thesteps (1- 4). 1 2 1 0

Module Code & Module Title Slide Title SLIDE 26


Cont. Pixel value at
the center
1 4 0 1 location
2 2 4 2 • Sort the pixels values (ascending order) : 0, 0, 0, 1, 1, 2, 2, 4, 4
1 0 1 0 • The median value is :1
1 2 1 0 • Replace the median value by the pixel value at center location
1 4 0 1
2 1 1 2
1 0
1 2 1 0
1 4 0 1 • Sort the pixels values (ascending order) : 0, 1, 1, 1, 1, 2, 2, 2, 4
2 2 4 2 • The median value is :1
1 0 1 0 • Replace the median value by the pixel value at center location
1 2 1 0 1 4 0 1
Pixel value at 2 1 1 2
the center 1 1 0
location 1 2 1 0

Module Code & Module Title Slide Title SLIDE 27


Cont.

1 4 0 1 • Sort the pixels values (ascending order) : 0, 0, 0, 1, 1, 2, 2, 2, 4


2 2 4 2 • The median value is :1
1 0 1 0 • Replace the median value by the pixel value at center location
1 2 1 0

1 4 0 1
Pixel value at 2 1 1 2
the center
1 1 1 0
location
1 2 1 0

Filtered Image

Module Code & Module Title Slide Title SLIDE 28


Maximum and Minimum Filters
■ Maximum and Minimum Filters are two order filters that can be used for
elimination of salt- and-pepper noise.
■ The maximum filter selects the largest value within an ordered window of pixels values
and replaces the central pixel with the largest value (lightest one) .
■ Used to find the brightest points in an image.
■ The maximum filters work best for removing pepper-typenoise.

■ The minimum filter selects the smallest value within an ordered window of pixels values
and replaces the central pixel with the smallest value (darkest one) in the ordered
window .

■ The minimum filters work best for removing salt- typenoise,


NOT: a minimum or low rank filter will tend to darken an image and a
maximum or high rank filter will tend to brighten an image

Module Code & Module Title Slide Title SLIDE 29


Maximum & Minimum Filters

Maximum filter

a) Image with pepper noise b) Filtered image by maximum filter

Minimum filter

c) Image with salt noise d) Filtered image by minimum filter

Module Code & Module Title Slide Title SLIDE 30


Example: Apply a maximum filter (Order Statistic) on the
following assumed image, using (3×3) Windowsize
1 4 0 1
2 2 4 2 Pixel value at
I= Input Image the center
1 0 1 0
location
1 2 1 0

Solution: 1 4 0 1
1. Overlade (3x3) window at the upper left corner of the input image : 2 2 4 2

2. Sort the pixels values (ascending order) : 0, 0, 1, 1, 1, 2, 2, 4, 4 1 0 1 0


1 2 1 0
3. Determine the maximum value : 0, 0, 1, 1, 1, 2, 2, 4, 4

4. Replace the pixel at the center location by median value 1 4 0 1


2 4 2
5.The window is then slide one pixel over, and Repeat the steps 1 0
(1- 4). 1 2 1 0

Module Code & Module Title Slide Title SLIDE 31


Pixel value at
Cont. the center
location
1 4 0 1
2 2 4 2 • Sort the pixels values (ascending order) : 0, 0, 0, 1, 1, 2, 2, 4,
• The median value is :4 4
1 0 1 0
• Replace the median value by the pixel value at center location
1 2 1 0
1 4 0 1
2 4 4 2
1 0
1 2 1 0
1 4 0 1 • Sort the pixels values (ascending order) : 0, 1, 1, 1, 1, 2, 2, 2,
• The median value is :4
2 2 4 2 4
1 0 1 0 • Replace the median value by the pixel value at center location
1 2 1 0 1 4 0 1
Pixel value at 2 4 4 2
the center 1 4 4 0
location 1 2 1 0
Filtered Image
Module Code & Module Title Slide Title SLIDE 32
Summary:

• Sharpening enhances the perceived sharpness of an image by increasing the contrast


along edges.
• It's achieved through filters or algorithms that identify edges and adjust pixel values to
make these edges more distinct, resulting in a clearer and more defined appearance.

• Adjusting parameters like radius, amount, and threshold allows for control over the
degree and type of sharpening applied to an image.

Module Code & Module Title Slide Title SLIDE 33

You might also like