Sie sind auf Seite 1von 78

CONCEPT OF CONVOLUTION

• Image processing is more or less the study of signals and


systems because an image is nothing but a two
dimensional signal.
• In image processing, we are developing a system whose
input is an image and output would be an image.

11/30/2019 Image filtering 1


• The box is that is shown in the below figure
labeled as “Digital Image Processing system”
could be thought of as a black box

11/30/2019 Image filtering 2


• It can be better represented as:

• The different ways of manipulating images


are:
a) Graphs Histograms/histogram processing

11/30/2019 Image filtering 3


b) Transformation functions/gray level
transformation

11/30/2019 Image filtering 4


C) Convolution
-Usually the black box system used for image
processing is a linear time invariant (LTI) system
-By linear it means that such a system always has
linear output, neither log nor exponent or any
other.
-By time invariant it means that the system
remains same during time.

11/30/2019 Image filtering 5


• Convolution can be mathematically represented
in two ways:
– gx,y = hx,y * fx,y, the mask convolved with an image
– gx,y = fx,y * hx,y, the mage convolved with mask.
• The two ways are because the convolution
operator ∗ is commutative.
• The hx,y is the mask or filter.

11/30/2019 Image filtering 6


• What is mask?
• Mask is a signal which can be represented by a
2D matrix.
• The mask is usually of the order of 1x1, 3x3, 5x5,
7x7.
• A mask should always be in odd number, because
other wise you cannot find the mid of the mask.
• Why do we need to find the mid of the
mask?

11/30/2019 Image filtering 7


• Process of performing convolution
– Flip the mask horizontally and vertically only once
– Slide the mask onto the image.
– Multiply the corresponding elements and then add
them
– Repeat this procedure until all values of the image
have been calculated.
• Example of convolution
– Mask 1 2 3
– Let’s take our mask
to be this.
4 5 6
7 8 9
11/30/2019 Image filtering 8
• Step 1 is to flip the mask.
• Flipping the mask horizontally Flipping the mask vertically
3 2 1 9 8 7
6 5 4 6 5 4
9 8 7 3 2 1
Image
Let’s consider an image 2 4 6
to be like this 8 10 12
14 16 18

11/30/2019 Image filtering 9


• Convolution
• To convolve a mask over image, place the center
of the mask at each element of an image.
• Multiply the corresponding elements and then
add them, and paste the result onto the element
of the image on which you placed the center of
mask. Mask

Image

11/30/2019 Image filtering 10


• Computations
• First image pixel = 5∗2 + 4∗4 + 2∗8 + 1∗10
= 10 + 16 + 16 + 10 = 52
Place 52 in the original image at the first index and
repeat this procedure for each pixel of the image.

Reasons for convolution as opposed to histogram


and transformations
Helps in achieving: blurring, sharpening, edge
detection, noise reduction etc

11/30/2019 Image filtering 11


• CONCEPT OF MASK
– A mask is a filter. Concept of masking is also known as
spatial filtering. Masking is also known as filtering. In
this concept we just deal with the filtering operation
that is performed directly on the image.
-1 0 1
– A sample is -1 0 1
-1 0 1
– Filtering:- The process of filtering is also known as
convolving a mask with an image. As this process is
same as convolution so filter masks are also known as
convolution masks.

11/30/2019 Image filtering 12


• How filtering is done
• The general process of filtering and applying masks
consists of moving the filter mask from point to
point in an image.
• At each point x,y of the original image, the
response of a filter is calculated by a pre defined
relationship.
• All the filters’ values are pre defined and are a
standard.

11/30/2019 Image filtering 13


• Types of filters
– Linear filters or smoothing filters
– Frequency domain filters.
• Why filters are used?
– Filters are used for Blurring and noise reduction
– Filters are used for edge detection and sharpness
• Blurring and noise reduction
– Blurring is used in pre processing steps, such as
removal of small details from an image prior to large
object extraction.

11/30/2019 Image filtering 14


• Masks for blurring
• The common masks for blurring are.
– Box filter
– Weighted average filter
• In the process of blurring we reduce the edge
content in an image and try to make the
transitions between different pixel intensities as
smooth as possible.
• Noise reduction is also possible with the help of
blurring.

11/30/2019 Image filtering 15


• Edge Detection and sharpness
– Masks or filters can also be used for edge
detection in an image and to increase sharpness
of an image.
• What are edges?
– Edges are sudden changes of discontinuities in an
image.
– Significant transitions in an image are called as
edges. A picture with edges is shown below.
– Original Same image
image with edges

11/30/2019 Image filtering 16


• CONCEPT OF BLURRING
• In blurring, we simply blur an image.
• An image looks more sharp or more detailed if we
are able to perceive all the objects and their
shapes correctly in it.
• For example, an image with a face, looks clear
when we are able to identify eyes, ears, nose,
lips, forehead etc very clearly.
• This clarity of an object is due to its edges.
• In blurring, we simply reduce the edge content
and make the transition from one color to the
other very smooth.
11/30/2019 Image filtering 17
• Blurring vs Zooming
– You might have seen a blurred
image when you zoom an image.
– When you zoom an image using pixel replication,
and zooming factor is increased, you see a blurred
image.
– The image also has less details, but it is not true
blurring.
– Because in zooming, you add new pixels to an
image, that increases the overall number of pixels in
an image, whereas in blurring, the number of pixels
of a normal image and a blurred image remains the
same.
11/30/2019 Image filtering 18
• Types of filters
– The common type of filters that are used to perform
blurring are.
• Mean filter
• Weighted average filter
• Gaussian filter
– Out of these three, we are going to discuss the first
two here and Gaussian will be discussed later on in
the upcoming sessions.

11/30/2019 Image filtering 19


• Mean filter
– Mean filter is also known as Box filter and average filter.
A mean filter has the following properties.
• It must be odd ordered
• The sum of all the elements should be 1
• All the elements should be same
– If we follow this rule, then for a mask of 3x3, we get the
following result. 1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9

– Since it is a 3x3 mask, that means it has 9 cells.


– The condition that all the element sum should be equal
to 1 can be achieved by dividing each value by 9.
– i.e. 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 + 1/9 =
9/9 = 1
11/30/2019 Image filtering 20
• The result of a mask of 3x3 on an image is shown below
• Original Image Blurred Image

• May be the results are not much clear.


• Let’s increase the blurring. The blurring can be increased
by increasing the size of the mask.
• The more is the size of the mask, the more is the
blurring.
• Because with greater mask, greater number of pixels are
scatterred and one smooth transition is defined.
11/30/2019 Image filtering 21
• The result of a mask of 5x5 on an image is shown below
• Original Image Blurred Image
Same way if we
increase the mask,
the blurring would be
more.
The result of a mask of 7x7 on an image is shown below.
Original Image Blurred Image

11/30/2019 Image filtering 22


• The result of a mask of 9x9 on an image is shown below.
– Original Image Blurred Image

• The result of a mask of 11x11 on an image is shown below.


– Original Image Blurred Image

11/30/2019 Image filtering 23


Mean Filter

Sometime we need to manipulate values obtained from


neighboring pixels
Example: How can we compute an average value of pixels
in a 3x3 region center at a pixel z?

Pixel z
2 4 1 2 6 2

9 2 3 4 4 4

7 2 9 7 6 7

5 2 3 6 1 5

7 4 2 5 1 2
2 5 2 3 2 8
Image
11/30/2019 24
Mean Filter

Step 1. Selected only needed pixels

Pixel z

2 4 1 2 6 2


9 2 3 4 4 4 3 4 4
… …
7 2 9 7 6 7 9 7 6

5 2 3 6 1 5 3 6 1

7 4 2 5 1 2


2 5 2 3 2 8

11/30/2019 25
Mean Filter

Step 2. Multiply every pixel by 1/9 and then sum up the values

3 4 4
… …
9 7 6
1 1 1
3 6 1 y  3 4  4
9 9 9
1 1 1

 9  7  6
X 9 9 9
1 1 1
1 1 1 Mask or   3   6  1
1 Window or
9 9 9
1 1 1
9 Template
11/30/2019
1 1 1 26
Mean Filter

Question: How to compute the 3x3 average values at every pixels?

Solution: Imagine that we have


2 4 1 2 6 2 a 3x3 window that can be placed
9 2 3 4 4 4 everywhere on the image
7 2 9 7 6 7

5 2 3 6 1 5

7 4 2 5 1 2

Masking Window
11/30/2019 27
Mean Filter

Step 1: Move the window to the first location where we want to


compute the average value and then select only pixels
inside the window.

Step 2: Compute
2 4 1 2 6 2 2 4 1
the average value
9 2 3 4 4 4 9 2 3
3 3
1
7 2 9 7 6 7 7 2 9 y    p(i, j )
i 1 j 1 9
5 2 3 6 1 5 Sub image p

7 4 2 5 1 2 Step 3: Place the


result at the pixel
Original image
in the output image

Step 4: Move the 4.3


window to the next
location and go to Step 2
11/30/2019
Output image 28
Mean Filter

The 3x3 averaging method is one example of the mask


operation or Spatial filtering.
w The mask operation has the corresponding mask (sometimes
called window or template).
w The mask contains coefficients to be multiplied with pixel
values.

Example : moving averaging


w(1,1) w(2,1) w(3,1)
1 1 1
w(1,2) w(2,2) w(3,2) 1
1 1 1
9
w(3,1) w(3,2) w(3,3) 1 1 1

Mask coefficients The mask of the 3x3 moving average


filter has all coefficients = 1/9
11/30/2019 29
Mean Filter

The mask operation at each point is performed by:


1. Move the reference point (center) of mask to the
location to be computed
2. Compute sum of products between mask coefficients
and pixels in subimage under the mask.

Mask frame

p(1,1) p(2,1) p(3,1) w(1,1) w(2,1) w(3,1)

… …
p(2,1) p(2,2) p(3,2) w(1,2) w(2,2) w(3,2)

p(1,3) p(2,3) p(3,3) w(3,1) w(3,2) w(3,3)

Mask coefficients

Subimage
N M
The reference point y   w(i, j )  p(i, j )
of the mask
11/30/2019 i 1 j 1 30
Mean Filter

The spatial filtering on the whole image is given by:

1. Move the mask over the image at each location.


2. Compute sum of products between the mask coefficients
and pixels inside subimage under the mask.
3. Store the results at the corresponding pixels of the
output image.
4. Move the mask to the next location and go to step 2
until all pixel locations have been used.

11/30/2019 31
• Weighted average filter
– In weighted average filter, more weight is given to
the center value. Due to this, the contribution of
center becomes more than the rest of the values.
Due to weighted average filtering, blurring can
actually be controlled.
– Properties of the weighted average filter are.
• It must be odd ordered
• The sum of all the elements should be 1
• The weight of center element should be more than all of
the other elements

11/30/2019 Image filtering 32


• Filter 1 1 1 1
1 2 1
1 1 1
• The two properties are satisfied which are 1
and 3, but the property 2 is not satisfied.
• To satisfy 2, simply divide the whole filter by 10,
or multiply it with 1/10.
• Filter 2 1 1 1
1 10 1
1 1 1

– Dividing factor = 18.

11/30/2019 Image filtering 33


• CONCEPT OF EDGE DETECTION
– Edges are sudden changes of discontinuities in an
image.
– Significant transitions in an image are called as
edges
• Types of edges
– Horizontal edges
– Vertical Edges
– Diagonal Edges

11/30/2019 Image filtering 34


• Why detect edges?
– Most of the shape information of an image is enclosed
in edges.
– So first we detect these edges in an image using filters,
enhance areas of image which contains edges. This
increases sharpness of the image making it clearer.
– Here are some of the masks for edge detection:
• Prewitt Operator
• Sobel Operator
• Robinson Compass Masks
• Krisch Compass Masks
• Laplacian Operator.
– These filters are all linear filters or smoothing filters

11/30/2019 Image filtering 35


• Prewitt operator-Prewitt operator is used for
detecting edges horizontally and vertically.
• Sobel operator- It is very similar to Prewitt
operator. It is also a derivate mask used for
edge detection. It calculates edges in both
horizontal and vertical direction.
• Robinson Compass Masks-This operator is
also known as direction mask. In this operator
we take one mask and rotate it in all the 8
compass major directions to calculate edges
of each direction.

11/30/2019 Image filtering 36


• Kirsch Compass Masks-Kirsch Compass Mask
is also a derivative mask which is used for
finding edges. Kirsch mask is also used for
calculating edges in all the directions.
• Laplacian Operator-Laplacian Operator is also
a derivative operator which is used to find
edges in an image. Laplacian is a second order
derivative mask. It can be further divided into
positive laplacian and negative laplacian.
• The next concept that comes after this is
sharpening which can be done once the
edges are extracted from the image
11/30/2019 Image filtering 37
• Sharpening
– Sharpening is opposite to the blurring.
– In blurring, we reduce the edge content and in
Sharpening, we increase the edge content.
– To increase the edge content in an image, we have to
find edges first.
– Edges can be found by any method described above
by using any operator.
– After finding edges, they are added to an image, thus
making the image to have more edges, and to look
sharpened.
– Adding more edges is one way of sharpening an
image.
11/30/2019 Image filtering 38
• The sharpened image is shown below.
• Original Image Sharpened Image

11/30/2019 Image filtering 39


• Prewitt Operator
– It detects two types of edges
• Horizontal edges
• Vertical Edges
– Edges are calculated by using differences between
corresponding pixel intensities of an image.
– All the masks that are used for edge detection are
also known as derivative masks.
– Because image is a signal, changes in a signal can
only be calculated using differentiation.
– So that’s why these operators are also called as
derivative operators or derivative masks.

11/30/2019 Image filtering 40


• All the derivative masks should have the following
properties:
– Opposite sign should be present in the mask.
– Sum of mask should be equal to zero.
– More weight means more edge detection.
• Prewitt operator provides two masks, for detecting
edges in horizontal direction and for detecting edges in
vertical direction.
• Vertical direction Horizontal direction
-1 0 1 -1 -1 -1
-1 0 1 0 0 0
-1 0 1 1 1 1
11/30/2019 Image filtering 41
• Vertical direction
– This mask finds the edges in vertical direction because the
zeros column is in the vertical direction.
– When this mask is convolved on an image, it gives the vertical
edges in the image.
• When we apply this mask on the image it prominent vertical
edges.
• It simply works like as first order derivate and calculates the
difference of pixel intensities in an edge region.
• As the center column is of zero so it does not include the
original values of an image but rather it calculates the
difference of right and left pixel values around that edge.
• Thus increase in the edge intensity makes it more enhanced
comparatively to the original image.

11/30/2019 Image filtering 42


• Horizontal Direction
– This mask finds the edges in horizontal direction because the
zeros column is in the horizontal direction.
– When this mask is convolved on an image, it gives the
horizontal edges in the image.
• When we apply this mask on the image it prominent
horizontal edges.
• It simply works like as first order derivate and calculates the
difference among pixel intensities of a particular edge.
• As the center column is of zero so it does not include the
original values of an image but rather it calculates the
difference of above and below pixel intensities of a
particular edge.
• Thus increasing the sudden change of intensities, makes
the edge more visible.
11/30/2019 Image filtering 43
• Both vertical and horizontal masks
– Follow the principle of derivate mask.
– Have opposite sign
– Sum equals to zero
• The third condition is not applicable in this operator
as both masks are standardized and their values can’t
be changed.
• Sample Image

11/30/2019 Image filtering 44


• After applying Vertical Mask
– After applying vertical mask on the above
sample image, following image is obtained.
This image contains vertical
edges.
After applying Horizontal Mask
– After applying horizontal mask on
the above sample image, following
image is obtained.

• Comparison
– In the first picture, all the vertical edges are more visible than
the original image.
– In the second picture, all the horizontal edges are visible.
11/30/2019 Image filtering 45
• Sobel Operator
– Like Prewitt operator sobel operator is used to detect two
kinds of edges in an image:
• Vertical direction
• Horizontal direction
– The major difference is that in sobel operator the coefficients
of masks are not fixed and they can be adjusted according to
user requirement unless they do not violate any property of
derivative masks.
• Vertical Mask Horizontal Mask
-1 0 1 -1 -2 -1
-2 0 2 0 0 0
-1 0 1 1 2 1
11/30/2019 Image filtering 46
• Vertical Mask:-Works exactly same as the Prewitt operator
vertical mask.
• The difference, it has “2” and “-2” values in center of first and
third column.
• When applied on an image this mask highlights the vertical
edges.
• It works like as first order derivate and calculates the
difference of pixel intensities in a edge region
• The center column is of zero, thus does not include the
original values of an image but rather it calculates the
difference of right and left pixel values around that edge.
• The center values of both the first and third column is 2 and -2
respectively.
• This give more weight age to the pixel values around the edge
region.
• This increase the edge intensity and it become enhanced
comparatively to the original image.
11/30/2019 Image filtering 47
• Horizontal Mask:-Works exactly same as the Prewitt
operator horizontal mask.
• The difference, it has “2” and “-2” values in center of first
and third row.
• When applied on an image this mask highlights the vertical
edges.
• It works like as first order derivate and calculates the
difference of pixel intensities in a edge region
• The center column is of zero, thus does not include the
original values of an image but rather it calculates the
difference of above and below pixel values around that
edge.
• The center values of both the first and third rows is 2 and -2
respectively.
• This give more weight age to the pixel values around the
edge region.
• This increase the edge intensity and it become enhanced
comparatively to the original image.
11/30/2019 Image filtering 48
• Sample Image
– After applying vertical mask on
the image, following image is
obtained.
-All the vertical edges are more visible
than the original image.
– After applying vertical mask on
the image, following image is
obtained.
-All the horizontal edges are more visible
than the original image.

11/30/2019 Image filtering 49


• Sobel operator vs. Prewitt operator
– Sobel operator finds more edges or make edges more
visible as compared to Prewitt Operator.
– In sobel operator more weight is allotted to the pixel
intensities around the edges.
• Applying more weight to the mask, yields more
edges.
• The operator has no fixed coefficients.
-1 0 1
-5 0 5
-1 0 1
• This mask will yield more edges compared to Prewitt
operator vertical mask. It has more weight.

11/30/2019 Image filtering 50


• Robinson Compass Mask / Direction mask.
– In this operator, one mask is rotated in all 8 compass major
directions thus:
• North
• North West
• West
• South West
• South
• South East
• East
• North East
– There is no fixed mask. Any mask can be rotated to find
edges in all directions.
– All the masks are rotated on the bases of direction of zero
columns.
11/30/2019 Image filtering 51
• Example for Mask in North Direction -1 0 1
-2 0 2
rotated to make all directions masks -1 0 1
• North West Direction Mask South East Direction Mask
0 1 2 0 -1 -2
-1 0 1 1 0 -1
-2 -1 0 2 1 0
• West Direction Mask East Direction Mask
1 2 1 -1 -2 -1
0 0 0 0 0 0
1 2 1
-1 -2 -1
• South West Direction Mask North East Direction Mask
2 1 0 -2 -1 0
1 0 -1 -1 0 1
0 -1 -2 0 1 2
• South Direction Mask
•All the directions are covered on
1 0 -1 the basis of zeros direction.
2 0 -2 • Each mask gives the edges on its
11/30/2019 1 0 -1 direction
Image filtering 52
• Sample Picture West Direction Edges South East Direction

• North Direction Edges South West Direction East Direction

• North West Direction South Direction North East Direction

• Applying the masks yields edges are in all directions


• Results depend on the image.
• If an image lacks one direction edges, the mask becomes ineffective
11/30/2019 Image filtering 53
• Krisch Compass Mask
– In this operator, just like Robinson compass, one mask is
rotated in all 8 compass major directions to find edges.
– The only difference between Robinson and kirsch
compass masks is that Kirsch has a standard mask but
in Robinson Compass, the mask is changed according
to user’s own requirements.

11/30/2019 Image filtering 54


• Example for Mask in North Direction -3 -3 5
-3 0 5
rotated to make all directions masks -3 -3 5

• North West Direction Mask South East Direction Mask


-3 5 5 -3 -3 -3
-3 0 5 5 0 -3
-3 -3 -3 5 5 -3
• West Direction Mask East Direction Mask
5 5 5 -3 -3 -3
-3 0 -3 -3 0 -3
-3 -3 -3 5 5 5
• South West Direction Mask North East Direction Mask
5 5 -3 -3 -3 -3
5 0 -3 -3 0 5
-3 -3 -3 -3 5 5
• South Direction Mask
5 -3 -3
•All the directions are covered.
5 0 -3 • Each mask gives the edges on its
5 -3 -3 direction
11/30/2019 Image filtering 55
• Sample Picture West Direction Edges South East Direction

• North Direction Edges South West Direction East Direction

• North West Direction South Direction North East Direction

• Applying the masks yields edges are in all directions


• Results depend on the image.
• If an image lacks one direction edges, the mask becomes ineffective
11/30/2019 Image filtering 56
• Laplacian Operator
– The major difference between Laplacian and other
operators like Prewitt, Sobel, Robinson and Kirsch is
that all these are first order derivative masks but
Laplacian is a second order derivative mask.
– In this mask we have two further classifications one
is Positive Laplacian Operator and other is Negative
Laplacian Operator.
– Another difference between Laplacian and other
operators is that unlike other operators, Laplacian
don’t take out edges in any particular direction but
it takes out edges in following classification.
• Inward Edges
• Outward Edges

11/30/2019 Image filtering 57


First order derivative Spatial filters

► The first-order derivative of a one-dimensional function f(x) is the


difference

f
 f ( x  1)  f ( x)
x

► The second-order derivative of f(x) as the difference

2 f
 f ( x  1)  f ( x  1)  2 f ( x)
x 2

11/30/2019 58
Second order derivative Spatial Filters: Laplace
Operator
The second-order isotropic derivative operator is the Laplacian for
a function (image) f(x,y)
 f  f 2 2
 f  2  2
2

x y
2 f
 f ( x  1, y )  f ( x  1, y )  2 f ( x, y )
x 2

2 f
 f ( x, y  1)  f ( x, y  1)  2 f ( x, y )
y 2

 2 f  f ( x  1, y )  f ( x  1, y )  f ( x, y  1)  f ( x, y  1)
- 4 f ( x, y )

11/30/2019 59
Sharpening Spatial Filters: Laplace Operator

Image sharpening in the way of using the Laplacian:

g ( x, y )  f ( x, y )  c  2 f ( x, y ) 
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c  -1 if  2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c  1 if either of the other two filters is used.

11/30/2019 60
• Positive Laplacian Operator
– Positive Laplacian has a standard 0 1 0
mask in which center element of the
1 -4 1
mask should be negative and corner
elements of mask should be zero. 0 1 0
-Positive Laplacian Operator is used to take out outward edges
in an image.
• Negative Laplacian Operator
– Negative Laplacian operator also has a 0 -1 0
standard mask, in which center element
should be positive. All the elements in the
-1 4 -1
corner should be zero and rest of all the 0 -1 0
elements in the mask should be -1.
- Negative Laplacian operator is used to take out inward edges
in an image
11/30/2019 Image filtering 61
Sharpening Spatial Filters: Laplace Operator

11/30/2019 62
• Laplacian is a derivative operator; its uses highlight gray
level discontinuities in an image and try to deemphasize
regions with slowly varying gray levels.
• This operation produces images which have grayish edge
lines and other discontinuities on a dark background.
• This produces inward and outward edges in an image
• The important thing is how to apply these filters onto
image.
• Both positive and negative Laplacian operators can’t be
applied on the same image.
• When positive Laplacian operator is applied on the
image, the resultant image is subtracted from the original
image to get the sharpened image.
• When negative Laplacian operator is applied, the
resultant image is added onto original image to get the
sharpened image.
11/30/2019 Image filtering 63
• Sample Image After applying negative Laplacian
operator , the following image is
the output

• After applying positive Laplacian


operator , the following image is
the output.

11/30/2019 Image filtering 64


Laplacian Masks

 2
P  2
P
Used for estimating image Laplacian  P 2  2
2

x y
-1 -1 -1 0 -1 0
The center of the mask
-1 8 -1 -1 4 -1 is positive
-1 -1 -1 0 -1 0

or

1 1 1 0 1 0
The center of the mask
1 -8 1 1 -4 1 is negative
1 1 1 0 1 0

Application: Enhance edge, line, point

Disadvantage: Enhance noise


11/30/2019 65
Laplacian Sharpening Example

p
2 P

2 P P  2 P

11/30/2019 66
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Laplacian Sharpening (cont.)

Mask for

P P 2

0 -1 0 -1 -1 -1
-1 5 -1 or -1 9 -1
Mask for 0 -1 0 -1 -1 -1
2 P

1 1 1
1 -8 1
1 1 1
or

0 1 0
1 -4 1
0 1 0
11/30/2019 67
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Unsharp Masking and High-Boost Filtering

-1 -1 -1 0 -1 0

-1 k+8 -1 -1 k+4 -1

-1 -1 -1 0 -1 0

Equation:

kP( x, y )  2 P( x, y ) The center of the mask is negative


Phb ( x, y )  
kP( x , y )   2
P( x, y ) The center of the mask is positive

11/30/2019 68
Unsharp Masking and High-Boost Filtering (cont.)

11/30/2019 69
(Images from Rafael C. Gonzalez and Richard E.
nd
Wood, Digital Image Processing, 2 Edition.
Unsharp Masking and Highboost Filtering

► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed) version
of an image from the original image
e.g., printing and publishing industry

► Steps
1. Blur the original image

2. Subtract the blurred image from the original

3. Add the mask to the original

11/30/2019 70
Unsharp Masking and Highboost Filtering

Let f ( x, y ) denote the blurred image, unsharp masking is


g mask ( x, y )  f ( x, y )  f ( x, y )
Then add a weighted portion of the mask back to the original
g ( x, y )  f ( x, y )  k * g mask ( x, y ) k 0

when k  1, the process is referred to as highboost filtering.

11/30/2019 71
Image Sharpening based on First-Order Derivatives

For function f ( x, y ), the gradient of f at coordinates ( x, y )


is defined as
 f 
 g x   x 
f  grad( f )      
 g y   f 
 y 

The magnitude of vector f , denoted as M ( x, y )


Gradient Image M ( x, y )  mag(f )  g x 2  g y 2

11/30/2019 72
Image Sharpening based on First-Order Derivatives

The magnitude of vector f , denoted as M ( x, y )


M ( x, y )  mag(f )  g x 2  g y 2

M ( x, y ) | g x |  | g y |

z1 z2 z3
M ( x, y) | z8  z5 |  | z6  z5 |
z4 z5 z6
z7 z8 z9

11/30/2019 73
Image Sharpening based on First-Order Derivatives

Roberts Cross-gradient Operators


M ( x, y ) | z9  z5 |  | z8  z6 |

Sobel Operators
M ( x, y) | ( z7  2 z8  z9 )  ( z1  2 z2  z3 ) |
z1 z2 z3  | ( z3  2 z6  z9 )  ( z1  2 z4  z7 ) |
z4 z5 z6
z7 z8 z9
11/30/2019 74
Image Sharpening based on First-Order Derivatives

11/30/2019 75
Example

11/30/2019 76
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

11/30/2019 77
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

11/30/2019 78

Das könnte Ihnen auch gefallen