digital image fundamentals and image enhancement in the...

126
8/28/20 04 University of Louisville University of Louisville Digital Image Processing Digital Image Processing Digital Image Processing Digital Image Fundamentals and Image Enhancement in the Spatial Domain Mohamed N. Ahmed, Ph.D.

Upload: duongdan

Post on 13-Apr-2019

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Digital Image Fundamentals and Image Enhancement in the

Spatial Domain

Mohamed N. Ahmed, Ph.D.

Page 2: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Introduction

• An image may be defined as 2D function f(x,y), where x and y are spatial coordinates.

• The amplitude of f at any pair (x,y) is called the intensity at that point.

When x, y, and f are all finite, discrete quantities, we call the image a digital image.

So, a digital image is composed of finite numberof elements called picture elements or pixels

Page 3: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• The field of image processing is related to two other fields:image analysis and computer vision

Introduction

Image Processing Computer Vision

Page 4: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Introduction

• There are three of processes in the continuum• Low Level Processes

» Preprocessing, filtering, enhancement» sharpening

Low Levelimageimage

Page 5: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Introduction

• There are three of processes in the continuum• Low Level Processes

» Preprocessing, filtering, enhancement» sharpening

• Mid Level Processes» segmentation

Low Levelimageimage

Mid Levelimageattributes

Page 6: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Introduction

• There are three of processes in the continuum• Low Level Processes

» Preprocessing, filtering, enhancement» sharpening

• Mid Level Processes» segmentation

• High Level Processes» Recognition

Low Levelimageimage

Mid Levelimageattributes

High Levelattributesrecognition

Page 7: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Origins of DIP

• Newspaper Industry: pictures were sent by Bartlane cable picture between London and New York in early 1920.

The introduction of the Bartlane Cable reduced the transmission time from a weekto three hours

Specialized printing equipment coded picturesfor transmission and then reconstructed them at the receiving end.

Visual Quality problems

1921

Page 8: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

In 1922, a technique based on photographic reproduction made from tapes perforated at the

telegraph receiving terminal was used.

This method had better tonal quality and Resolution

Had only five gray levels

Origins of DIP

1922

Page 9: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Origins of DIP

Unretouched cable picture of Generals Pershing and Foch transmittedBetween London and New York in 1929 Using 15-tone equipment

Page 10: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Origins of DIP

The first picture of the moon by a US Spacecraft.

Ranger 7 took this image On July 31st in 1964.

This saw the first use of a digital computer to correct for various types of image distortions inherent in the on-board television camera

Page 11: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Applications

• X-ray ImagingX-rays are among the oldest sourcesof EM radiation used for imaging

Main usage is in medical imaging (X-rays, CAT scans, angiography)

The figure shows some of the applications of X-ray imaging

Page 12: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Applications

• Inspection SystemsSome examples of manufactured goods

often checked using digital image processing

Page 13: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Applications

• Finger Prints• Counterfeiting• License Plate

Reading

Page 14: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Components of an Image Processing System

Page 15: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Steps in Digital Image Processing

Page 16: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

2. Digital Image Fundamentals

Page 17: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Structure of the Human Eye

The eye is nearly a sphere with an Average diameter of 20mm

Three membranes enclose the eye:Cornea/Sclera, choroid, and retina.

The Cornea is a tough transparent tissueCovering the anterior part of the eyeSclera is an opaque membrane that Covers the rest of the eye

The Choroid has the blood supply to the eye

Page 18: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Continuous with the choroid is the iris which contracts or expands to control the amount of light entering the eye

• The lens contains 60 to 70 % water, 6% fat, and protein.

• The lens is colored slightly yellow that increases with age

• The Lens absorbs 8% of the visible light. The lens also absorbs high amount of infrared and ultra violet of which excessive amounts can damage the eye

Structure of the Human Eye

Page 19: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• The innermost membrane is the retina

• When light is properly focused, the image of an outside object is imaged on the retina

• There are discrete light receptors that line the retina: cones and rods

The Retina

Page 20: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Rods and Cones

• The cones (7 million) are located in the central portion of the retina (fovea). They are highly sensitive to color

• The rods are much larger (75-150 million). They are responsible for giving a general overall picture of the field of view. They are not involved in color vision

Page 21: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Formation in the Eye

Page 22: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Electromagnetic Spectrum

Page 23: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Acquisition

Page 24: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Single Imaging Sensor

Line sensor

Array of Sensors

Page 25: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Single Imaging Sensor

Photo Diode

Sensor

Film

Page 26: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Line sensor

Image Area

Linear Motion

Page 27: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Line sensor

Image Area

Linear Motion

Page 28: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Line sensor

Image Area

Linear Motion

Page 29: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Line sensor

Image Area

Linear Motion

Page 30: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Line sensor

Image Area

Linear Motion

Page 31: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sensors

Array of Sensors

CCD Camera

Page 32: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Formation Model

f(x,y)=i(x,y)r(x,y)

where1) i(x,y) the amount of illumination

incident to the scene

2) r(x,y) the reflectance from the objects 1),(0

),(0

<<

∞<<

yxr

yxi

Page 33: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Formation Model

• For Monochrome Images : l = f(x,y)where

» l_min < l < l_max» l_min > 0» l_max should be finite

The Interval [l_min, l_max] is called the gray scaleIn practice, the gray scale is from 0 to L-1, where L is the # of gray levels

0 > BlackL-1 > White

Page 34: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sampling and Quantization

• Sampling is the quantization of coordinates• Quantization is the quantization of gray

levels

Sampling &Quantization

Continuous Discrete

Page 35: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Sampling and Quantization

Page 36: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Sampling and Quantization

Continuous Image projected onto a sensor array

Results of Sampling andQuantization

Page 37: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Effect of Sampling

A 1024x1024 image is sub-sampled to 32x32. Number of gray levels is the same

Images up-sampled to 1024x1024Starting from 1024, 512,256,128,64, and 32

Page 38: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Effect of Quantization

An X-ray Image represented by different number of gray levels: 256, 128, 64, 32, 16, 8, 4, and 2.

Page 39: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Representing Digital Images

The result of Sampling and Quantization is a matrix of realNumbers. Here we have an image f(x,y) that was sampled To produce M rows and N columns.

⎥⎥⎥⎥

−−

⎢⎢⎢⎢

=

)1,1(......

)1,0(

...)0,1(

......

...)1,1(...

...)1,0()0,0(

),(

NMf

Nf

Mf

fff

yxf

Page 40: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Representing Digital Images

• There is no requirements about M and N• Usually L= 2k

• Dynamic Range : [0, L-1]

The number of bits required to store an image

b = M x N x k where k is the number of bits/pixel

Example : The size of a 1024 x 1024 8bits/pixel image is 220 bytes = 1 MBytes

Page 41: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Storage

The number of storage bits depending on width and height (NxN), and the number Of bits/pixel k.

The number of bits required to store an image

b = M x N x k where k is the number of bits/pixel

Page 42: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

File Formats

• PGM/PPM• RAW• JPEG• GIF• TIFF• PDF• EPS

Page 43: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

File Formats

• The TIFF FileTIFF -- or Tag Image File Format -- was developed by Aldus Corporation in 1986, specifically for saving images from scanners, frame grabbers, and paint/photo-retouching programs.

Today, it is probably the most versatile, reliable, and widely supported bit-mapped format. It is capable of describing bi-level, grayscale, palette-color, and full-color image data in several color spaces.

It includes a number of compression schemes and is not tied to specific scanners, printers, or computer display hardware.

The TIFF format does have several variations, however, which means that occasionally an application may have trouble opening a TIFF file created by another application or on a different platform

Page 44: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

File Formats

• The GIF FileGIF -- or Graphics Interchange Format -- files define a protocol intended for

the on-line transmission and interchange of raster graphic data in a way that is independent of the hardware used in their creation or display.

• The GIF format was developed in 1987 by CompuServe for compressing eight-bit images that could be telecommunicated through their service and exchanged among users.

• The GIF file is defined in terms of blocks and sub-blocks which contain relevant parameters and data used in the reproduction of a graphic. A GIF data stream is a sequence of protocol blocks and sub-blocks representing a collection of graphics

Page 45: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

File Formats• The JPEG File

JPEG is a standardized image compression mechanism. The name derives from the Joint Photographic Experts Group, the original name of the committee that wrote the standard. In reality, JPEG is not a file format, but rather a method of data encoding used to reduce the size of a data file. It is most commonly used within file formats such as JFIF and TIFF.

• JPEG File Interchange Format (JFIF) is a minimal file format which enables JPEGbitstreams to be exchanged between a wide variety of platforms and applications. This minimal format does not include any of the advanced features found in the TIFF JPEG specification or any application specific file format.

• JPEG is designed for compressing either full-color or grayscale images of natural, real-world scenes. It works well on photographs, naturalistic artwork, and similar material, but not so well on lettering or simple line art. It is also commonly used for on-line display/transmission; such as on web sites.

• A 24-bit image saved in JPEG format can be reduced to about one-twentieth of its original size.

Page 46: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Neighbors of a Pixel

• A pixel p at coordinates (x,y) has 4 neighbors: (x-1,y), (x+1,y), (x,y-1), (x,y+1).

• These pixels are called N4(p)

• N8(p) are the eight immediate neighbors of p

p

Page 47: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Adjacency and Connectivity

• Two pixels are connected if:• They are neighbors• Their gray levels satisfy certain conditions (e.g. :

g1= g2)

∗Two pixels p, q are 4 adjacent if *Two pixels p, q are 8 adjacent if

)(4 pNq∈)(8 pNq∈

Page 48: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Adjacency and Connectivity

• Path :– A digital path from p to q is the set of pixel

coordinates linking p and q.

• Region:– A region is a connected set of pixels

q

p

Page 49: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Distance Measures

Assume we have 3 pixels: p:(x,y), q:(s,t) and z:(v,w)A distance function D is a metric that satisfies the following

conditions:

Example: Euclidean Distance :

),(),(),()),(),()

0),(,0),()

zqDqpDzpDcpqDqpDb

qpiffqpDqpDa

+≤=

==≥

22 )()(),( tysxqpD −+−=

Page 50: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Distance Measures

• City Block Distance :

• Chess Board Distance

|)|,max(|),(

||||),(

8

4

tysxqpD

tysxqpD

−−=

−+−=

2 2 1 2

2 1 0 1 22 1 2

2

2 2 1 2

2 1 0 1 22 1 2

2

2 2 2 2 2 2 1 1 1 22 1 0 1 22 1 1 1 22 2 2 2 2

2 2 2 2 2 2 1 1 1 22 1 0 1 22 1 1 1 22 2 2 2 2

44 1 ND ⇔=

88 1 ND ⇔=

Page 51: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Pixel Replication• Bilinear Interpolation• Bicubic Interpolation

Image Scaling

Page 52: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Pixel Replication:Use the nearest neighbor to construct the zoomed image

Useful in doubling the image size

Image Interpolation

Page 53: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Bilinear InterpolationUse 4 nearest neighbors to calculate the image value.

Image Interpolation

(u,v)

(i+1,j+1)

(i,j+1)(i,j)

(i+1,j)

))(1,1())(1)(1,(),1())(,1())(1)(,(),(

))(,1())(1)(,(),(

jvjifjvjifvifjvjifjvjifvif

iuvifiuvifvuf

−+++−−+=+−++−−=

−++−−=

(i,v)

(i+1,v)

Page 54: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Interpolation

• Cubic InterpolationUse 16 nearest neighborsThe contribution of each pixel depends on its distance from the output pixelUsually we use spline curve to give smoother output.

where

1,0

)()()()(

)(

)()(),(

4

3

2

1

<<

⎥⎥⎥⎥

⎢⎢⎢⎢

=

=

vu

upupupup

uP

uPFvPvuf T

Page 55: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Interpolation

• Cubic Interpolation

2/)()(

2/)43()(

2/)253()(

2/)2()(

234

233

232

231

2,1,2

,

,11,1

tttp

ttttp

tttp

ttttp

ff

f

ff

F

jiji

ji

jiji

−=

++−=

+−=

−+−=

⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢

=

+++

−−−

Page 56: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Interpolation

4x Bilinear Interpolation 4x Bicubic Interpolation

Page 57: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Interpolation

4x BiCubic Interpolation 4x Edge Directed Interpolation

Page 58: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Interpolation

Page 59: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

3. Image Enhancement in the Spatial Domain

Page 60: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Enhancement

The objective of Image Enhancement is to process image data so that the result is more suitable than the original image

EnhancementOperator

Original Image EnhancedImage

Page 61: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image EnhancementImage Enhancement

Spatial Domain Frequency Domain

Page 62: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Spatial Domain Enhancement

• Let f(x,y) be the original imageand g(x,y) be the processed image

Then

where T is an operator over a certain neighborhood of the image centered at (x,y)

Usually, we operate on a small rectangular region around (x,y)

)),((),( yxfTyxg =

Page 63: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Intensity Mapping

• The simplest form of T is when the neighborhood is 1 x 1 pixel (single pixel)

• In this case, g depends only on the gray level at (x,y)

)),((),( yxfTyxg =

)(rTs =

Input Gray levelOutput Gray level

Intensity Mapping

Page 64: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Intensity MappingIntensity mapping is used to :

a)Increase Contrastb)Vary range of gray Levels

Page 65: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Mapping

• A) Image Negative

Example: L=256

rLs −−= )1(

rs −= 255

This operation enhances details in dark regions

Page 66: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Mapping

• B) Log Transformations

)1log( rcs +=

Page 67: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Mapping

Fourier Spectrum and Result of applying log transformation c=1

Page 68: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Mapping

• C) Power Transformation

γcrs =

Page 69: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Gamma Correction

Page 70: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Gamma Correction6.0=γ

4.0=γ 3.0=γ

Page 71: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Gamma Correction3=γ

4=γ 5=γ

Page 72: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Contrast Stretching

Page 73: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Contrast Stretching

Page 74: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Workshop

Using Photoshop1. Image ->Adjustments->

perform: a) Image negative, b) Approx gamma=0.3, gamma=2.4, c) Clipping at 200

2. Use the Brightness and Contrast curves to increase the level of brightness of the image

4. Threshold Image: Image->Adjustments->Threshold

Page 75: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram

• The Histogram of a digital image is a function :

where rk is the kth gray levelnk is the number of pixels having gray level rk

kk nrh =)(

Page 76: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram

• Example:

4322431152112200

0

1

2

3

4

5

0 1 2 3 4 5 6

#of pixels

Page 77: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Normalized Histogram

• Normally, we normalize h(rk) by

• So, we have

• p(rk) can be sought of as the probability of a pixel to have a certain value rk

1)(

)()(

1

0

1

0==

==

∑∑−

=

=

L

k

kL

kk

kkk

nnrp

nn

nrhrp

Page 78: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Normalized Histogram

• Example: n=16

4322431152112200

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0 1 2 3 4 5 6

#of pixels

Page 79: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram

Note: Images with uniformly Distributed histograms have higherContrast and high dynamic range

Page 80: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

• Define a transformation s= T(r)with

where pr(r) is the probability histogram of image r

dwwprTr

r )()(0∫=

Page 81: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

• Now lets calculate ps(s)

)(

)()(

)()(

0

rpdrds

dwwpdrdrT

drd

drds

dsdrrpsp

r

r

r

rs

=

==

=

Page 82: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

• So,

Then

Which means that using the transformation the resulting probability is uniform independent of the original image

1)(

1)()(

)(1

=⋅=

=

rprpsp

rpdsdr

rrs

r

dwwprTr

r )()(0∫=

Page 83: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

∑∑==

−≤≤==k

j

jj

k

jrk Lk

nn

rps00

10)(

In discrete form :

Page 84: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

Transformation Functions

Page 85: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

Page 86: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Histogram Equalization

Page 87: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Workshop

2. Calculate the Histogram: Image->Histogram

3. Perform Histogram Equalization

43224311521122001. Obtain the histogram equalization

curve for the following example

Using PhotoShop

Page 88: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Local Enhancement

• Instead of calculating the histogram for the whole image and then do histogram equalization, – First divide the image into blocks– Perform histogram equalization on each block

Page 89: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Local Histogram Equalization

Page 90: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Local Statistics

• From the local histogram, we can compute the nth moment

where

( )

( ) 21

0

22

1

0

1

0

1

0

)(

01

)(

)()(

σµ

µµ

µ

=−=

==

=

−=

=

=

=

i

L

ii

i

L

ii

i

L

i

nin

rpmr

rprm

rpmrr

Variance

Page 91: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Assume we want to change only dark areas in the image and leave light areas unchanged

Enhancement By Local Statistics

⎩⎨⎧

=),(

),(),(

yxfyxf

yxgα Thmmif xyxy ≤≤ σ

otherwise

Page 92: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Enhancement By Local Statistics

Page 93: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Enhancement By Arithmetic Operations

Page 94: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image Averaging

),(1),(1

yxfK

yxgK

ii∑

=

=

Page 95: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Spatial filtering is performed by convolving the image with a mask or a kernel

• Spatial filters include sharpening, smoothing, edge detection, noise removal, etc.

Spatial Filtering

Page 96: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Basics of Spatial Filtering

Page 97: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• In general, linear filtering of an image f of size M x N with filter size m x n is given by the expression

Basics of Spatial Filtering

2/)1(,2/)1(

),(),(),(

−=−=

++= ∑ ∑−= −=

nbma

tysxftswyxga

as

b

bt

Page 98: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• The output of a smoothing spatial filter is simply the average of the pixels contained in the neighborhood of the filter mask.

• These filters are sometimes called averaging filters and also lowpass filters

• By replacing the value of the pixel with the average of a window around it, the result is a n image with reduced sharp transitions

Smoothing Spatial Filters

Page 99: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Smoothing Spatial Filters

∑ ∑

∑ ∑

−= −=

−= −=

++= a

as

b

bt

a

as

b

bt

tsw

tysxftswyxg

),(

),(),(),(

In general

Page 100: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Smoothing Spatial Filters

Page 101: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Smoothing Spatial Filters

Page 102: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

• Order statistics filters are nonlinear spatial filters whose response is based on ordering (ranking) the pixels contained in an area covered by the filter

• The best known example in this category in median filter

• Median filters replace the value of the pixel by the median of the gray levels in the neighborhood of that pixel

Order Statistics Filters

Page 103: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Median Filter

• Example10 20 20 20 15 20

20 25 100

Order10 15 20 20 20 20 20 25 100

Median value

10 20 20 20 20 20

20 25 100

Page 104: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Median Filter

Page 105: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Multi Pass Median Filter

Page 106: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Image+Pepper Noise Image+Salt Noise

Other Order Statistics Filters

Page 107: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Other Order Statistics Filters

Max Filter Min Filter

Page 108: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Adaptive Median Filter

• We want to preserve the detail while smoothing non impulse noise.• Vary the size of the window.• Algorithm:

Let

xymed

xy

xy

Singraylevelmedianz

Singraylevelz

Singraylevelz

=

=

=

max

min

max

min

Page 109: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

med

xy

xy

xy

xy

med

med

zoutputElse

zoutputBANDBif

zzB

zzB

zoutputElseAGotoSsizewindowIf

sizewindowincreaseElseBGotoAANDAif

zzAzzA

,0201

2

1

,

020121

max

min

max

max

min

<>

−=

−=

<

<>−=−=A:

B:

Adaptive Median Filter

Page 110: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Adaptive Median Filter

Page 111: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Sharpening Spatial Filters

• The principal objective of sharpening is to highlight fine details in an image or to to enhance details that has been blurred.

• We saw before that image blurring could be accomplished by pixel averaging, which is analogous to integration.

• Sharpening could be accomplished by spatial differentiation

• In this section, we will define operators for sharpening by digital differentiation

• Fundamentally, the strength of the response of the operator should be proportional to the degree of discontinuity (presence of edges).

Page 112: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Digital Differentiation

• A basic definition of the first-order derivative at one dimensional function f(x) is the difference

• The second order derivative

)()1( xfxfxf

−+=∂∂

)1()(2)1(2

2

−+−+=∂∂ xfxfxf

xf

Page 113: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Digital Differentiation

Page 114: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

The Laplacian

• The Laplacian of an image is define as

),(4)]1,()1,(),1(),1([

)1,(),((2)1,(

),1(),((2),1(

2

2

2

2

2

2

2

2

22

yxfyxfyxfyxfyxff

yxfyxfyxfy

f

yxfyxfyxfx

fy

fx

ff

−−+++−++=∇

−+−+=∂∂

−+−+=∂∂

∂∂

+∂∂

=∇

f2∇

Page 115: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

The Laplacian f2∇

Page 116: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Sharpening Mask

⎪⎩

⎪⎨⎧

++∇

+−∇=+

)()(

)(2

2

yxffyxff

yxg

Page 117: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Page 118: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Sharpening Spatial Filters

Page 119: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Unsharp Masking

• A process used for many years in the publishing industry to sharpen images.

• It consists of subtracting a blurred version of the image from the image itself

),(~),(),( yxfyxfyxfs −=

Page 120: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

High Boost Filters

),(~),(),( yxfyxfAyxfhb −=

A slight generalization of unsharp masking is called high boost filters

Page 121: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

High Boost Filters

Page 122: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Edge Detection

Page 123: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Edge Detection

Page 124: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

The idea is to filter within the object not across boundaries

Therefore, image details remain unblurred while achieving Smoothness within objects

The filtering is modeled as a diffusion process that stops at image boundaries

Anisotropic Diffusion Filter

Page 125: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Anisotropic Diffusion Filter

2),(

)(

)),().((),(

⎥⎦⎤

⎢⎣⎡∇−

=

∇=∂

Ktxf

exc

txfxcdivt

txf

Page 126: Digital Image Fundamentals and Image Enhancement in the ...dylucknow.weebly.com/uploads/6/7/3/1/6731187/spatial_domain... · 8/28/20 04 University of Louisville Digital Image ProcessingDigital

8/28/2004 University of LouisvilleUniversity of Louisville

Digital Image ProcessingDigital Image ProcessingDigital Image Processing

Thank You