Top Banner
Digital Image Processing using Matlab Introduction Eng.Amr Ez El_Din Rashed Assistant Lecturer Taif university. Tel:0554404723 e-mail:[email protected]
209
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Digital image processing using matlab

Digital Image Processing using Matlab

Introduction

Eng.Amr Ez El_Din Rashed

Assistant Lecturer

Taif university.

Tel:0554404723 e-mail:[email protected]

Page 2: Digital image processing using matlab

2

of

38 Introduction

“One picture is worth more than ten thousand words”

Anonymous

Page 3: Digital image processing using matlab

3

of

38 References

“Digital Image Processing using Matlab”, Rafael

C. Gonzalez & Richard E. Woods,

Addison-Wesley, 2004

or

“Computer Vision and image processing

processing A practical approach using cvip tools

Scott E umbaugh

Prentice hall 1998

Page 4: Digital image processing using matlab

4

of

38

An Introduction to Digital Image Processing with

Matlab,2004

School of Computer Science And Mathematics

Victoria University of Technology

Biosignal and Biomedical Image Processing

Matlab-Based Application,

JOHN L. SEMMLOW

Page 5: Digital image processing using matlab

5

of

38 Course

• This course will cover:

Introduction to Image Processing And Computer

Vision.

Image Fundamentals.

Intensity Transformation and Spatial Filtering

Frequency Domain Processing

Image Restoration

Wavelets

Morphological Image Processing

Image Segmentation

Page 6: Digital image processing using matlab

6

of

38 Contents

This lecture will cover:

– What is a digital image?

– What is digital image processing?

– History of digital image processing

– State of the art examples of digital image

processing

– Key stages in digital image processing

Page 7: Digital image processing using matlab

7

of

38 Images

an image is a single picture which represents

something. It may be a picture of a person, of people

or animals, or of an outdoor scene, or a

microphotograph of an electronic component, or the

result of medical imaging.

Even if the picture is not immediately recognizable, it

will not be just a random blur.

Page 8: Digital image processing using matlab

8

of

38 Computer imaging

• It’s defined as the acquisition and processing

of visual information by computer.

• The ultimate receiver of information is:

– Computer

– Human visual system

• So we have two categories:-

– Computer vision

– Image processing

Page 9: Digital image processing using matlab

9

of

38

Computer vision and image

processing

• In computer vision:

–The processed output images

are for use by computer.

• In Image processing:

–The output images are for

human consumption

Page 10: Digital image processing using matlab

10

of

38 Computer vision

• One of the computer vision fields is image

analysis.

• It involves the examination of image data

to facilitate solving a vision problem.

• Image analysis has 2 topics:

– Feature extraction: acquiring higher level

image information

– Pattern classification taking these higher level

of information and identifying objects within

the image

Page 11: Digital image processing using matlab

11

of

38 What is a Digital Image?

A digital image is a representation of a two-

dimensional image as a finite set of digital

values, called picture elements or pixels

Page 12: Digital image processing using matlab

12

of

38 What is a Digital Image? (cont…)

Pixel values typically represent gray levels,

colours, heights, opacities etc

Remember digitization implies that a digital

image is an approximation of a real scene

1 pixel

Page 13: Digital image processing using matlab

13

of

38 What is a Digital Image? (cont…)

Common image formats include:

– 1 sample per point (B&W or Grayscale)

– 3 samples per point (Red, Green, and Blue)

For most of this course we will focus on grey-scale

images

Page 14: Digital image processing using matlab

14

of

38 What is Digital Image Processing?

Digital image processing involves changing

the nature of an image in order to either

– Improve it’s pictorial information for human

interpretation(image ehancement)

– Processing of image data for storage,

transmission and representation for

autonomous machine perception(ادراك)

Some argument about where image

processing ends and fields such as image

analysis and computer vision start

Page 15: Digital image processing using matlab

15

of

38 DIP(cont…)

• It is necessary to realize that these two aspects

represent two separate but equally important

aspects of image processing. A procedure

which satisfies condition.

• (1)a procedure which makes an image look

better may be the very worst procedure for

satisfying condition

• (2). Humans like their images to be sharp, clear

and detailed; machines prefer their images to

be simple and uncluttered.

Page 16: Digital image processing using matlab

16

of

38 Example of (1)

Enhancing the edges of an image to make it appear sharper

Page 17: Digital image processing using matlab

17

of

38 Example of (1)

Page 18: Digital image processing using matlab

18

of

38 Example of (1)

Page 19: Digital image processing using matlab

19

of

38 Example of (2)

Page 20: Digital image processing using matlab

20

of

38 Example of (2)

Page 21: Digital image processing using matlab

21

of

38 What is DIP? (cont…)

The continuum ( متسلسل -متصل )from image

processing to computer vision can be

broken up into low-, mid- and high-level

processes Low Level Process

Input: Image

Output: Image

Examples: Noise

removal, image

sharpening

Mid Level Process

Input: Image

Output: Attributes

Examples: Object

recognition,

segmentation

High Level Process

Input: Attributes

Output: Understanding

Examples: Scene

understanding,

autonomous navigation

In this course we will

stop here

Page 22: Digital image processing using matlab

22

of

38 History of Digital Image Processing

Early 1920s: One of the first applications of

digital imaging was in the news-

paper industry

– The Bartlane cable picture

transmission service (5 tones)

– Images were transferred by submarine cable

between London and New York

– Pictures were coded for cable transfer and

reconstructed at the receiving end on a

telegraph printer

Early digital image

Page 23: Digital image processing using matlab

23

of

38 History of DIP (cont…)

Mid to late 1920s: Improvements to the

Bartlane system resulted in higher quality

images

– New reproduction

processes based

on photographic

techniques

– Increased number

of tones in

reproduced images

Improved

digital image Early 15 tone digital

image

Page 24: Digital image processing using matlab

24

of

38 History of DIP (cont…)

1960s: Improvements in computing

technology and the onset of the space race

led to a surge of work in digital image

processing

– 1964: Computers used to

improve the quality of

images of the moon taken

by the Ranger 7 probe

– Such techniques were used

in other space missions

including the Apollo landings

A picture of the moon taken

by the Ranger 7 probe

minutes before landing

Page 25: Digital image processing using matlab

25

of

38 History of DIP (cont…)

1970s: Digital image processing begins to

be used in medical applications

– 1979: Sir Godfrey N.

Hounsfield & Prof. Allan M.

Cormack share the Nobel

Prize in medicine for the

invention of tomography,

the technology behind

Computerised Axial

Tomography (CAT) scans Typical head slice CAT

image

Page 26: Digital image processing using matlab

26

of

38 History of DIP (cont…)

1980s - Today: The use of digital image

processing techniques has exploded and

they are now used for all kinds of tasks in all

kinds of areas

– Image enhancement/restoration

– Artistic effects

– Medical visualisation

– Industrial inspection

– Law enforcement

– Human computer interfaces

Page 27: Digital image processing using matlab

27

of

38 Examples: Image Enhancement

One of the most common uses of DIP

techniques: improve quality, remove noise

etc

Page 28: Digital image processing using matlab

28

of

38 Examples: The Hubble Telescope

Launched in 1990 the Hubble

telescope can take images of

very distant objects

However, an incorrect mirror

made many of Hubble’s

images useless

Image processing

techniques were

used to fix this

Page 29: Digital image processing using matlab

29

of

38 Examples: Artistic Effects

Artistic effects are

used to make

images more

visually appealing,

to add special

effects and to make

composite images

Page 30: Digital image processing using matlab

30

of

38 Examples: Medicine

Take slice from MRI scan of canine heart,

and find boundaries between types of tissue

– Image with gray levels representing tissue

density

– Use a suitable filter to highlight edges

Original MRI Image of a Dog Heart Edge Detection Image

Page 31: Digital image processing using matlab

31

of

38 Examples: GIS

Geographic Information Systems

– Digital image processing techniques are used

extensively to manipulate satellite imagery

– Terrainتضاريس classification

– Meteorology األرصاد الجوية

Page 32: Digital image processing using matlab

32

of

38 Examples: GIS (cont…)

Night-Time Lights of the World data set

– Global inventory of

human settlement

– Not hard to imagine

the kind of analysis

that might be done

using this data

Page 33: Digital image processing using matlab

33

of

38 Examples: Industrial Inspection

Human operators are

expensive, slow and

unreliable

Make machines do the

job instead

Industrial vision systems

are used in all kinds of

industries

Can we trust them?

Page 34: Digital image processing using matlab

34

of

38 Examples: PCB Inspection

Printed Circuit Board (PCB) inspection

– Machine inspection is used to determine that

all components are present and that all solder

joints are acceptable

– Both conventional imaging and x-ray imaging

are used

Page 35: Digital image processing using matlab

35

of

38 Examples: Law Enforcement

Image processing

techniques are used

extensively by law

enforcers

– Number plate

recognition for speed

cameras/automated

toll systems

– Fingerprint recognition

– Enhancement of

CCTV images

Page 36: Digital image processing using matlab

36

of

38 Examples: HCI

Try to make human computer

interfaces more natural

– Face recognition

– Gesture ايماءةrecognition

Does anyone remember the

user interface from “Minority

Report”?

These tasks can be

extremely difficult

Page 37: Digital image processing using matlab

37

of

38 Key Stages in Digital Image Processing

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 38: Digital image processing using matlab

38

of

38

Key Stages in Digital Image Processing:

Image Aquisition

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 39: Digital image processing using matlab

39

of

38

Image Enhancement:

taking an image and improving it visually

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 40: Digital image processing using matlab

40

of

38

Image Restoration : taking an image with some known or estimated degradation and restoring

it to its original appearing

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 41: Digital image processing using matlab

41

of

38

Key Stages in Digital Image Processing:

Morphological Processing

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 42: Digital image processing using matlab

42

of

38

Key Stages in Digital Image Processing:

Segmentation

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 43: Digital image processing using matlab

43

of

38

Key Stages in Digital Image Processing:

Object Recognition

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 44: Digital image processing using matlab

44

of

38

Key Stages in Digital Image Processing:

Representation & Description

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 45: Digital image processing using matlab

45

of

38

Image compression: reducing the massive amount of data needed to represent an image

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 46: Digital image processing using matlab

46

of

38

Key Stages in Digital Image Processing:

Colour Image Processing

Image

Acquisition

Image

Restoration

Morphological

Processing

Segmentation

Representation

& Description

Image

Enhancement

Object

Recognition

Problem Domain

Colour Image

Processing

Image

Compression

Page 47: Digital image processing using matlab

47

of

38 Sampling

• Sampling refers to the process of digitizing a continuous function. For

example, suppose we take the function

• and sample it at ten evenly spaced values of x only. The resulting sample

points are shown in figure 1.6. This shows an example of under sampling,

where the number of points is not sufficient to reconstruct the function.

Suppose we sample the function at 100 points, as shown in figure 1.7. We

can clearly now reconstruct the function; all its properties can be determined

from this sampling. In order to ensure that we have enough sample points,

we require that the sampling period is not greater than one-half the finest

detail in our function. This is known as the Nyquist criterion, and can be

formulated more precisely in terms of “frequencies”. The Nyquist criterion

can be stated as the sampling theorem, which says, in effect, that a

continuous function can be reconstructed from its samples provided

that the sampling frequency is at least twice the maximum frequency in

the function. A formal account of this theorem is provided by

Castleman

Page 48: Digital image processing using matlab

48

of

38 Image Acquisition and Sampling

Page 49: Digital image processing using matlab

49

of

38 Effect of Sampling

Sampling an image requires that we consider the Nyquist criterion, when we consider an

image as a continuous function of two variables, and we wish to sample it to produce a

digital image. An example is shown ,where an image is shown, and then with an under

sampled version. The jagged edges in the under sampled image are examples of

aliasing. The sampling rate will of course affect the final resolution of the image. In order

to obtain a sampled (digital) image, we may start with a continuous representation of a

scene. To view the scene, we record the energy reflected from it; we may use visible

light, or some other energy source.

Page 50: Digital image processing using matlab

50

of

38 Data Classes

Page 51: Digital image processing using matlab

51

of

38 Types of digital images

The toolbox supports four types of images:

1-intensity images.

2-binary images.

3-Indexed images.

4-RGB images.

Page 52: Digital image processing using matlab

52

of

38 Intensity images(grayscale images)

• An intensity image is a data matrix whose values have

been scaled to represent intensities.

• Class uint8 :range [0,255]

• Class uint16:range[0,65535]

• Double: floating point[0,1]

Page 53: Digital image processing using matlab

53

of

38 Binary image

Binary. Each pixel is just black or white. Since there are only two possible

values for each pixel,

we only need one bit per pixel. Such images can therefore be very efficient in

terms of storage. Images for which a binary representation may be suitable

include text (printed or handwriting), fingerprints, or architectural plans.

Page 54: Digital image processing using matlab

54

of

38 True color, or RGB image

Here each pixel has a particular color; that color being described by the amount of red,

green and blue in it. If each of these components has a range 0-255 this gives a total

of different possible colors in the image 255^3=16,777,216. This is enough colors for

any image. Since the total number of bits required for each pixel is 24, such images

are also called 24 bit color images. Such an image may be considered as consisting of

a “stack” of three matrices; representing the red, green and blue values for each pixel.

This means that for every pixel there correspond three values.

Page 55: Digital image processing using matlab

55

of

38 Indexed image

Most color images only have a small subset of the more than sixteen million

possible colors. For convenience of storage and file handling, the image has

an associated color map, or color palette, which is simply a list of all the

colors used in that image. Each pixel has a value which does not give its

color (as for an RGB image), but an index to the color in the map.

Page 56: Digital image processing using matlab

56

of

38 Converting between Image Classes andTypes

Page 57: Digital image processing using matlab

57

of

38 Cont.

Page 58: Digital image processing using matlab

58

of

38 Cont.

Page 59: Digital image processing using matlab

59

of

38 Reading Images

Page 60: Digital image processing using matlab

60

of

38 Displaying Images

Page 61: Digital image processing using matlab

61

of

38 Cont.

Page 62: Digital image processing using matlab

62

of

38 Cont.

Page 63: Digital image processing using matlab

63

of

38 Writing Images

Page 64: Digital image processing using matlab

64

of

38 Image Information

Page 65: Digital image processing using matlab

65

of

38 Image File Sizes

• Image files tend to be large. We shall investigate the amount of information

used in different image type of varying sizes. For example, suppose we

consider a binary image. The number of bits used in this image (assuming

no compression, and neglecting, for the sake of discussion, any Header

information) is

512×512×1=262,144

=32768 bytes

• If we now turn our attention to color images, each pixel is associated with 3

bytes of color Information. A 512×512×3 image thus requires

512×512×3=786,432Byte

• =786.43Kb

• =0.786 Mb.

Page 66: Digital image processing using matlab

66

of

38 Import pixel information

Page 67: Digital image processing using matlab

67

of

38 Indexed and RGB images

Page 68: Digital image processing using matlab

68

of

38 ind2gray

Page 69: Digital image processing using matlab

69

of

38 gray2ind

Page 70: Digital image processing using matlab

70

of

38 Image perception

• Much of image processing is concerned with making an image

appear better to human beings. We should therefore be aware

of the limitations of the human visual system. Image perception

consists of two basic steps:

• 1. Observed intensities vary as to the background. A single

block of grey will appear darker if placed on a white background

than if it were placed on a black background.

Page 71: Digital image processing using matlab

71

of

38 Cont.

• 2.We may observe non-existent intensities as bars in

continuously varying grey levels. This image varies

continuously from light to dark as we travel from left to

right. However, it is impossible for our eyes not to see a

few horizontal edges in this image.

Page 72: Digital image processing using matlab

72

of

38 Cont.

3. Our visual system tends to undershoot or overshoot

around the boundary of regions of different intensities.

For example, suppose we had a light grey blob on a

dark grey background. As our eye travels from the

dark background to the light region, the boundary of

the region appears lighter than the rest of it.

Conversely, going in the other direction, the boundary

of the background appears darker than the rest of it.

Page 73: Digital image processing using matlab

73

of

38 image

50 100 150 200 250

50

100

150

200

250

Page 74: Digital image processing using matlab

74

of

38 Cont.

• will certainly display the cameraman, but possibly in an odd

mixture of colors, and with some stretching. The strange

colors come from the fact that the image command uses the

current color map to assign colours to the matrix elements.

The default color map is called jet, and consists of 64 very

bright colours, which is inappropriate for the display of a

grayscale image.

• To display the image properly, we need to add several extra

commands to the image line.

• 1.truesize.

• 2.axis off

• 3. colormap(gray(247)), which adjusts the image colour map

to use shades of grey only. We can find the number of grey

levels used by the cameraman image with

Page 75: Digital image processing using matlab

75

of

38 Cont.

Page 76: Digital image processing using matlab

76

of

38

image(x),truesize,axis off,

colormap(gray(512))

will produce a dark image. This happens because only

the first 247 elements of the color map will be used by the

image for display, and these will all be in the first half of

the color map; thus all dark greys.

Page 77: Digital image processing using matlab

77

of

38

image(x),truesize,axis off,

colormap(gray(128))

• will produce a very light image, because any

pixel with grey level higher than 128 will simply

pick that highest grey value (which is white) from

the color map.

Page 78: Digital image processing using matlab

78

of

38 Indexed color images

Page 79: Digital image processing using matlab

79

of

38 RGB images

Page 80: Digital image processing using matlab

80

of

38 imshow

Page 81: Digital image processing using matlab

81

of

38 Cont.

To display the matrix cd, we need to scale it to the range

[0,1]. This is easily done simply by dividing all values by 255:

Page 82: Digital image processing using matlab

82

of

38 im2double

We can convert the original image to double more properly

using the function im2double. This applies correct scaling so

that the output values are between 0 and 1.

Page 83: Digital image processing using matlab

83

of

38 Bit planes

• Grayscale images can be transformed into a sequence of

binary images by breaking them up into their bit-planes. If we

consider the grey value of each pixel of an 8-bit image as an 8-

bit binary word,

• then the 0th bit plane consists of the last bit of each grey

value.Since this 0th bit plane has the least effect in terms of the

magnitude of the value, it is called the least significant bit, and

the plane consisting of those bits the least significant bit plane.

• Similarly the 7th bit plane consists of the first bit in each value.

This bit has the greatest effect in terms of the magnitude of the

value, so it is called the most significant bit, and the plane

consisting of those bits the most significant bit plane.

Page 84: Digital image processing using matlab

84

of

38 Cont.

Page 85: Digital image processing using matlab

85

of

38 Spatial Resolution

• Spatial resolution is the density of pixels over

the image: the greater the spatial resolution, the

more pixels are used to display the image. We

can experiment with spatial resolution with

Matlab's

Page 86: Digital image processing using matlab

86

of

38 Cont.

Page 87: Digital image processing using matlab

87

of

38 Another solution

Page 88: Digital image processing using matlab

88

of

38 imdemos

Page 89: Digital image processing using matlab

89

of

38 Point Processing

• Any image processing operation transforms the grey

values of the pixels. However, image processing

operations may be divided into three classes based on

the information required to perform the transformation.

From the most complex to the simplest, they are:

• 1.Transforms.

• 2. Neighborhood processing.

• 3.Point operations : They are especially useful in

image pre-processing, where an image is required to

be modified before the main job is attempted.

Page 90: Digital image processing using matlab

90

of

38 Arithmetic operations

Page 91: Digital image processing using matlab

91

of

38 Cont.

imadd output

Page 92: Digital image processing using matlab

92

of

38 Cont.

Page 93: Digital image processing using matlab

93

of

38 Cont.

y=x/2 y=x*2 y=x/2+128

Page 94: Digital image processing using matlab

94

of

38 Complements

The complement of a grayscale image is its

photographic negative. If an image matrix m is of type

double and so its grey values are in the range [0,1].

If the image is binary, we can use

• If the image is of type uint8, the best approach is the

imcomplement function he complement function y=255-x

Page 95: Digital image processing using matlab

95

of

38 Cont.

Page 96: Digital image processing using matlab

96

of

38 Part Complementation(Solarization)

Page 97: Digital image processing using matlab

97

of

38 Cont.

Page 98: Digital image processing using matlab

98

of

38 Histograms

Given a grayscale image, its histogram consists of

the histogram of its grey levels; that is, a graph

indicating the number of times each grey level

occurs in the image.

1-In a dark image, the grey levels (and hence the

histogram) would be clustered at the lower end.

2-In a uniformly bright image, the grey levels would

be clustered at the upper end.

3-In a well contrasted image, the grey levels would

be well spread out over much of the range.

Page 99: Digital image processing using matlab

99

of

38 Cont.

0

200

400

600

800

1000

1200

1400

1600

0 50 100 150 200 250

Page 100: Digital image processing using matlab

100

of

38

Histogram Stretching (Contrast stretching)

• Given a poorly contrasted image, we would like

to enhance its contrast, by spreading out its

histogram. There are two ways of doing this.

1.Histogram stretching (contrast stretching).

2.Histogram equalization

2Histogram Stretching (Contrast stretching)

Histogram Stretching (Contrast stretching)

Page 101: Digital image processing using matlab

101

of

38 Cont.

Suppose we have an image with the histogram shown , associated

with a table of the numbers ni of gray values

Page 102: Digital image processing using matlab

102

of

38 Cont.

We can stretch the grey levels in the centre of the range out by

applying the piecewise linear function shown at the right in figure.

This function has the effect of stretching the grey levels 5-9 to

gray levels 2-14 according to the equation

Where I is the original gray level and j its result after the

transformation .This yields

Page 103: Digital image processing using matlab

103

of

38 Cont.

which indicates an image with greater contrast than the original.

Page 104: Digital image processing using matlab

104

of

38 Use of imadjust

Page 105: Digital image processing using matlab

105

of

38 Cont.

Page 106: Digital image processing using matlab

106

of

38 Cont.

Page 107: Digital image processing using matlab

107

of

38 Cont.

Page 108: Digital image processing using matlab

108

of

38 Cont.

Page 109: Digital image processing using matlab

109

of

38 Cont.

50 100 150 200 250

50

100

150

200

250

Page 110: Digital image processing using matlab

110

of

38

A piecewise linear stretching function

The heart of our function will be the lines

Page 111: Digital image processing using matlab

111

of

38 2.Histogram equalization

• The trouble with any of the above methods of

histogram stretching is that they require user input.

Sometimes a better approach is provided by

histogram equalization, which is an entirely automatic

procedure. The idea is to change the histogram to one

which is uniform; that is that every bar on the

histogram is of the same height, or in other words that

each grey level in the image occurs with the same

frequency. In practice this is generally not possible,

although as we shall see the result of histogram

equalization provides very good results.

Page 112: Digital image processing using matlab

112

of

38 Cont.

Suppose a 4-bit gray scale image has the histogram shown in figure associated

with a table of the numbers

Page 113: Digital image processing using matlab

113

of

38 Cont.

Page 114: Digital image processing using matlab

114

of

38 Cont.

We now have the following transformation of grey values, obtained by reading o

the first and last columns in the above table:

This is far more spread out than the original histogram, and so the resulting image

should exhibit greater contrast.

Page 115: Digital image processing using matlab

115

of

38 Cont.

0

500

1000

1500

2000

2500

3000

3500

0 50 100 150 200 250

0

200

400

600

800

1000

1200

1400

1600

0 50 100 150 200 250

Page 116: Digital image processing using matlab

116

of

38 Cont.

We give one more example, that of a very dark image. We can obtain a dark image by

taking an image and using imdivide.

0

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

0 50 100 150 200 250

Page 117: Digital image processing using matlab

117

of

38 Cont.

0

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

0 50 100 150 200 250

Page 118: Digital image processing using matlab

118

of

38 Lookup tables

Page 119: Digital image processing using matlab

119

of

38 Cont.

Page 120: Digital image processing using matlab

120

of

38 Example

Page 121: Digital image processing using matlab

121

of

38 Neighborhood Processing

Page 122: Digital image processing using matlab

122

of

38 Spatial domain filtering

Page 123: Digital image processing using matlab

123

of

38 Linear filter

A diagram illustrating the process for performing spatial filtering is

given in figure.

Spatial filtering thus requires three steps:

1. position the mask over the current pixel.

2. form all products of filter elements with the corresponding

elements of the neighborhood.

3. add up all the products. This must be repeated for every pixel in

the image.

Page 124: Digital image processing using matlab

124

of

38 Convolution

Page 125: Digital image processing using matlab

125

of

38 Mean filter

Page 126: Digital image processing using matlab

126

of

38 Cont.

Page 127: Digital image processing using matlab

127

of

38 Cont.

If we continue in this manner, the following output is obtained:

Page 128: Digital image processing using matlab

128

of

38 Cont.

Page 129: Digital image processing using matlab

129

of

38 Cont.

mean filter output

50 100 150 200 250

50

100

150

200

250

original image

Page 130: Digital image processing using matlab

130

of

38 Another solution

Page 131: Digital image processing using matlab

131

of

38 Another solution

Page 132: Digital image processing using matlab

132

of

38 Edge of the image

Page 133: Digital image processing using matlab

133

of

38 Filtering in Matlab

Page 134: Digital image processing using matlab

134

of

38 Cont.

• filter2(filter,image,'valid') applies the mask only to

inside pixels. The result will always be smaller than

the original:

Page 135: Digital image processing using matlab

135

of

38 Cont.

• The result of 'same' above may also be obtained by

padding with zeros and using 'valid':

Page 136: Digital image processing using matlab

136

of

38 Cont.

filter2(filter,image,'full') returns a result larger than the original;

it does this by padding with zero, and applying the filter at all

places on and around the image where the mask intersects

the image matrix.

Page 137: Digital image processing using matlab

137

of

38 Cont.

• The shape parameter, being optional, can be omitted; in which

case the default value is 'same'. There is no single best

approach; the method must be dictated by the problem at hand;

by the filter being used, and by the result required.

We can create our filters by hand, or by using the fspecial

function; this has many options which makes for easy creation

of many different filters. We shall use the average option, which

produces averaging filters of given size; thus

Page 138: Digital image processing using matlab

138

of

38 Cont.

Page 139: Digital image processing using matlab

139

of

38 Note.

Page 140: Digital image processing using matlab

140

of

38 Cont.

Page 141: Digital image processing using matlab

141

of

38 Notes.

• The resulting image after these filters may appear to

be much worse than the original. However, applying

a blurring filter to reduce detail in an image may the

perfect operation for autonomous machine

recognition, or if we are only concentrating on the

gross aspects of the image: numbers of objects;

amount of dark and light areas. In such cases, too

much detail may obscure the outcome.

Page 142: Digital image processing using matlab

142

of

38 Separable filters

Page 143: Digital image processing using matlab

143

of

38 Frequencies; low and high pass filters

Page 144: Digital image processing using matlab

144

of

38 Cont.

Page 145: Digital image processing using matlab

145

of

38 Cont.

Page 146: Digital image processing using matlab

146

of

38 Cont.

laplacian log

In each case, the sum of all the filter elements is zero.

High pass filtering

Page 147: Digital image processing using matlab

147

of

38 Cont.

Page 148: Digital image processing using matlab

148

of

38 Cont.

Page 149: Digital image processing using matlab

149

of

38 Cont.

Page 150: Digital image processing using matlab

150

of

38 Cont.

Page 151: Digital image processing using matlab

151

of

38 imfilter

Page 152: Digital image processing using matlab

152

of

38 Edge sharpening

Page 153: Digital image processing using matlab

153

of

38 Cont.

Page 154: Digital image processing using matlab

154

of

38 Cont.

Page 155: Digital image processing using matlab

155

of

38 Cont.

Page 156: Digital image processing using matlab

156

of

38 Cont.

Page 157: Digital image processing using matlab

157

of

38 Cont.

Page 158: Digital image processing using matlab

158

of

38 High boost filtering

Page 159: Digital image processing using matlab

159

of

38 Non-linear filters

Page 160: Digital image processing using matlab

160

of

38 Cont.

Page 161: Digital image processing using matlab

161

of

38 colfilt

Page 162: Digital image processing using matlab

162

of

38 Rank order filter

Page 163: Digital image processing using matlab

163

of

38

geometric mean filter, alpha-trimmed

mean filter

Page 164: Digital image processing using matlab

164

of

38 The Fourier Transform

Page 165: Digital image processing using matlab

165

of

38 Background

Page 166: Digital image processing using matlab

166

of

38 Cont.

Page 167: Digital image processing using matlab

167

of

38 1D-DFT

Page 168: Digital image processing using matlab

168

of

38 FFT

Page 169: Digital image processing using matlab

169

of

38 2D –DFT,Properties

Page 170: Digital image processing using matlab

170

of

38 Cont.

Page 171: Digital image processing using matlab

171

of

38 Convolution

Page 172: Digital image processing using matlab

172

of

38 DC Coefficient

Page 173: Digital image processing using matlab

173

of

38 shifting

Page 174: Digital image processing using matlab

174

of

38

Page 175: Digital image processing using matlab

175

of

38 trouble

Page 176: Digital image processing using matlab

176

of

38 Fourier transforms in Matlab

Page 177: Digital image processing using matlab

177

of

38 Example

Page 178: Digital image processing using matlab

178

of

38 Example 2.

Now we'll take a matrix consisting of a single corrugation:

Page 179: Digital image processing using matlab

179

of

38 Example 3

• We will take here a single step edge:

Page 180: Digital image processing using matlab

180

of

38 Fourier transforms of images(spectrum)

Page 181: Digital image processing using matlab

181

of

38 FFTshow function

Page 182: Digital image processing using matlab

182

of

38 Example 1

Page 183: Digital image processing using matlab

183

of

38 Example 2(box)

Page 184: Digital image processing using matlab

184

of

38 Example 3(box rotated 45)

Page 185: Digital image processing using matlab

185

of

38 Example 4.(circle)

Page 186: Digital image processing using matlab

186

of

38 Notes

• Note the ringing in the Fourier transform. This is an

artifact associated with the sharp cut off of the circle.

As we have seen from both the edge and box images

in the previous examples, an edge appears in the

transform as a line of values at right angles to the

edge. We may consider the values on the line as

being the coefficients of the appropriate corrugation

functions which sum to the edge. With the circle, we

have lines of values radiating out from the circle;

these values appear as circles in the transform.

Page 187: Digital image processing using matlab

187

of

38 Example 5

Page 188: Digital image processing using matlab

188

of

38 Filtering in the frequency domain

• Ideal filtering(low pass filter)

Page 189: Digital image processing using matlab

189

of

38 Cont.

Page 190: Digital image processing using matlab

190

of

38 Cont.

Page 191: Digital image processing using matlab

191

of

38 Notes

• Note that even though cfli is supposedly a matrix of real

numbers, we are still using fftshow to display it. This is because

the fft2 and fft2 functions, being numeric, will not produce

mathematically perfect results, but rather very close numeric

approximations . So using fftshow with the 'abs' option rounds

out any errors obtained during the transform and its inverse.

Note the ringing about the edges in this image. This is a direct

result of the sharp cutoff of the circle. The ringing as shown in

figure is transferred to the image.

• We would expect that the smaller the circle, the more blurred

the image, and the larger the circle; the less blurred.

Page 192: Digital image processing using matlab

192

of

38 Cont.

Page 193: Digital image processing using matlab

193

of

38 High pass filtering

Page 194: Digital image processing using matlab

194

of

38 Example

Page 195: Digital image processing using matlab

195

of

38 Image Restoration

• Image restoration concerns the removal or reduction of

degradations which have occurred during the acquisition

of the image. Such degradations may include noise,

which are errors in the pixel values, or optical effects

such as out of focus blurring, or blurring due to camera

motion. We shall see that some restoration techniques

can be performed very successfully using neighborhood

operations, while others require the use of frequency

domain processes. Image restoration remains one of the

most important areas of image processing, but in this

chapter the emphasis will be on the techniques for

dealing with restoration, rather than with the

degradations themselves, or the properties of electronic

equipment which give rise to image degradation.

Page 196: Digital image processing using matlab

196

of

38 Noise

• We may define noise to be any degradation in the image signal,

caused by external disturbance. If an image is being sent

electronically from one place to another, via satellite or wireless

transmission, or through networked cable, we may expect

errors to occur in the image signal. These errors will appear on

the image output in different ways depending on the type of

disturbance in the signal.

• Usually we know what type of errors to expect, and hence the

type of noise on the image; hence we can choose the most

appropriate method for reducing the effects. Cleaning an image

corrupted by noise is thus an important area of image

restoration.

Page 197: Digital image processing using matlab

197

of

38 Salt and pepper noise

• Also called impulse noise, shot noise, or

binary noise. This degradation can be

caused by sharp, sudden disturbances in

the image signal; its appearance is

randomly scattered white or black (or both)

pixels over the image.

Page 198: Digital image processing using matlab

198

of

38 Cont.

Page 199: Digital image processing using matlab

199

of

38 Gaussian noise

Page 200: Digital image processing using matlab

200

of

38 Speckle noise

Page 201: Digital image processing using matlab

201

of

38 Periodic noise

• If the image signal is subject to a periodic, rather than a random

disturbance, we might obtain an image corrupted by periodic

noise. The effect is of bars over the image. The function

imnoise does not have a periodic option, but it is quite easy to

create our own, by adding a periodic matrix(using a

trigonometric function).

• Salt and pepper noise, Gaussian noise and speckle noise can

all be cleaned by using spatial filtering techniques. Periodic

noise, however, requires the use of frequency domain filtering.

This is because whereas the other forms of noise can be

modelled as local degradations, periodic noise is a global

effect.

Page 202: Digital image processing using matlab

202

of

38 Cleaning salt and pepper noise

Page 203: Digital image processing using matlab

203

of

38 Cont.

Page 204: Digital image processing using matlab

204

of

38 Removal of periodic noise

Page 205: Digital image processing using matlab

205

of

38 Segmentation

Page 206: Digital image processing using matlab

206

of

38 label2rgb

Page 207: Digital image processing using matlab

207

of

38 bwconncomp

Page 208: Digital image processing using matlab

208

of

38 Cont.

Page 209: Digital image processing using matlab

209

of

38 labelmatrix