57
Digital Image Processing COSC 6380/4393 Lecture – 5 Sept 12 th , 2017 Pranav Mantini Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

  • Upload
    lydien

  • View
    230

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Digital Image ProcessingCOSC 6380/4393

Lecture – 5

Sept 12th, 2017

Pranav MantiniSlides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Page 2: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: IMAGING Formation

• Image formation (pinhole, add lens)

• Image acquisition

object

lens

image

sensingplate,

emulsion, etc

light source(point source)

emitted rays

reflectedrays

focallength

2

Page 3: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Weeks 1 & 2 4

Review: Sensor Response Waveform

Page 4: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Weeks 1 & 2 5

Review: Response from a raster scan

Page 5: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: A / D CONVERSION

• For computer processing, the analog image must

undergo ANALOG / DIGITAL (A/D) CONVERSION -

Consists of sampling and quantization

Page 6: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: A / D CONVERSION

• For computer processing, the analog image must

undergo ANALOG / DIGITAL (A/D) CONVERSION -

Consists of sampling and quantization

Sampling• Each video raster is converted from a continuous

voltage waveform into a sequence of voltage samples:

Page 7: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: Sampling: Example

VS

169 Samples 67,600 Samples

Page 8: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Weeks 1 & 2 9

Review: Quantization

Page 9: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Resampling

• Once the image is acquired.

• How to

– Enlarge an image

– Shrink an image

– Zoom in

• Zooming Example:

– Initial image size = 500 X 500

– Required image size (= X 1.5) = 750 X 750

Page 10: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Weeks 1 & 2 11

Image Interpolation

• Interpolation — Process of using known data to estimate unknown values

e.g., zooming, shrinking, rotating, and geometric correction

• Interpolation (sometimes called resampling) — an imaging method to increase (or decrease) the number of pixels in a digital image.

Some digital cameras use interpolation to produce a larger image than the

sensor captured or to create digital zoom

http://www.dpreview.com/learn/?/key=interpolation

Page 11: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Interpolation: Nearest Neighbor5 X 8 Image

3 X 3 Image

Fill in values preserving spatial relationship

Page 12: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Linear Interpolation

Solve for 𝐼𝐼2 − 𝐼1𝐼 − 𝐼1

=𝑥2 − 𝑥1𝑥 − 𝑥1

(𝐼2−𝐼1)𝑥 − 𝑥1𝑥2 − 𝑥1

= 𝐼 − 𝐼1

𝐼 = 𝐼1 + (𝐼2−𝐼1)𝑥 − 𝑥1𝑥2 − 𝑥1

𝑥1 𝑥2

𝐼1 𝐼2

𝑥

𝐼

Page 13: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Bi-Linear Interpolation(2D)Q11 = (x1, y1),Q12 = (x1, y2),Q21 = (x2, y1),and Q22 = (x2, y2)

Find the value at 𝑃

https://en.wikipedia.org/wiki/Bilinear_interpolation

Page 14: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: DIGITAL IMAGE

REPRESENTATION

• Once an image is digitized (A/D) and stored it is an array of voltage or magnetic potentials

• Not easy to work with from an algorithmic point of view

• The representation that is easiest to work with from an algorithmic perspective is that of a matrix of integers

Matrix Image Representation• Denote a (square) image matrix I = [I(i, j); 0 < i, j < N-1]

where

• (i, j) = (row, column)

• I(i, j) = image value at coordinate or pixel (i, j)

Page 15: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: DIGITAL IMAGE

REPRESENTATION (contd.)

• Example - Matrix notation

• Example - Pixel notation - an N x N image

What’s the minimum number

of bits/pixel allocated?

Page 16: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Review: DIGITAL IMAGE

REPRESENTATION (contd.)• Example - Binary Image

(2-valued, usually

BLACK and WHITE)

• Another way of depicting the

image:

Page 17: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

18

BINARY IMAGES

• How do binary images arise?

• Since binary = bi-valued, the (logical) values ’0’ or ’1’usually indicate the absence or presence of an image

property in an associated gray-level image:

– Points of high or low intensity (brightness)

– Points where an object is present or absent

– More abstract properties, such as smooth vs. nonsmooth, etc.

• Convention - We will make the associations

• ’1’ = BLACK

• ’0’ = WHITE

Page 18: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

19

BINARY IMAGE GENERATION

• Tablet-Based Input:

• Binary images can derive from simple sensors with binary output

• Simplest example: tablet, resistive pad, or light pen

• All pixels initially assigned value ’0’:

I = [I(i, j)], I(i, j) = ’0’ for all (i, j) = (row column)

• When pressure or light is applied at (i0 , j0 ), the image is assigned the value ’1’: I(i0 , j0 ) = ’1’

• This continues until the user completes the drawing

Page 19: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

20

BINARY IMAGE

• Usually a binary image is obtained from a gray-level image

• Advantages:– B-fold reduction in required storage

– Simple abstraction of information

– Fast processing - logical operators

– Can be further compressed

Page 20: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

8X8 image white box on black background

Page 21: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Grey scale Pixels values

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Binary image

Page 22: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

23

GRAY-LEVEL THRESHOLDING

Simple Thresholding

• The simplest of image processing operations

• An extreme form of gray-level quantization

• Define an integer threshold T (in the gray-scale range)

• Compare each pixel intensity to T

Page 23: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

24

THRESHOLDING

• Suppose gray-level image I has K gray-levels: 0, 1, 2, ...., K-1

• Select threshold T { 0, 1, 2, ...., K-1}

• Compare every gray-level in I to T

• Define a new binary image J as follows:

• J(i, j) = ’0’ if I(i, j) >= T

• J(i, j) = '1' if I(i, j) < T

• A new binary image J is created from a gray-level image I

Page 24: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Grey scale Pixels values

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Binary image

𝑇ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑(T)

Page 25: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 255 255 255 255 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Grey scale Pixels values

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 1 1 1 1 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Binary image

𝑇ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑(T)

What is good value of T?

Page 26: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

8X8 image grey box on black background

What is good value of T?

Page 27: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

8X8 image grey box on black background

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

8X8 image light white box on white background

What is good value of T? What is good value of T?

Page 28: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

29

THRESHOLD SELECTION

• The quality of the binary image J obtained by thresholding I

depends very heavily on the threshold T

• Indeed it is instructive to observe the result of thresholding an

image at many different levels in sequence

• Different thresholds can produce different valuable abstractions

of the image

• Some images do not produce any interesting results when

thresholded by any T

Page 29: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

30

THRESHOLD SELECTION

• The quality of the binary image J obtained by thresholding I

depends very heavily on the threshold T

• Indeed it is instructive to observe the result of thresholding an

image at many different levels in sequence

• Different thresholds can produce different valuable abstractions

of the image

• Some images do not produce any interesting results when

thresholded by any T

• So: How does one decide if thresholding is possible ?

• How does one decide on a threshold T ?

Page 30: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Grey Level Binary Image

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

8X8 image grey box on black background

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

8X8 image light white box on white background

How does one determine 𝑇?

Page 31: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Determine modes

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

0

20

40

60

0 1 …

24

0

24

1

24

2 …

25

5

Pixel Count

0

20

40

60

0 1 2 …. 10 11 12 …

Pixel Count

Page 32: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Determine modes0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 10 10 10 10 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 240 240 240 240 255 255

255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255

0

20

40

60

0 1 …

24

0

24

1

24

2 …

25

5

Pixel Count

0

20

40

60

0 1 2 …. 10 11 12 …

Pixel Count

𝑚𝑜𝑑𝑒1 = 0;𝑚𝑜𝑑𝑒2 = 10𝑇 = 𝑎𝑣𝑔 𝑚𝑜𝑑𝑒 = 𝟓

𝑚𝑜𝑑𝑒1 = 240;𝑚𝑜𝑑𝑒2 = 255𝑇 = 𝑎𝑣𝑔 𝑚𝑜𝑑𝑒 = 𝟐𝟒𝟕.5

Page 33: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

34

GRAY-LEVEL IMAGE

HISTOGRAM

• The histogram HI of image I is a plot or

graph of the frequency of occurrence of

each gray level in I

• HI is a one-dimensional function with

domain 0, ... , K-1

• HI(k) = n if I contains exactly n

occurrences of gray level k, for each k = 0,

... K-1

Page 34: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Histogram Example

input imageintensity

pix

el

co

un

t

Black = 0

Gray = 190

White = 254

Page 35: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

36

HISTOGRAM APPEARANCE

• The appearance of a histogram suggests much about the image

Page 36: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

37

HISTOGRAM APPEARANCE

• The appearance of a histogram suggests much about the image

• These could be histograms of underexposed and overexposed images, respectively

predominantly

dark imagepredominantly

light image

Page 37: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

38

HISTOGRAM APPEARANCE

• This histogram may show better use of the gray-scale range

• Well-distributed histogram

Page 38: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Histogram Example

input imageintensity

pix

el

co

un

t

Black = 0

Gray = 190

White = 254

Page 39: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Histogram Example

Prof. Shishir Shah 40

input image

• Reality

intensityp

ixel

co

un

t

Page 40: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

41

BIMODAL HISTOGRAM

• Thresholding usually works best when there are dark objects on a light background

• Or when there are light objects on a dark background

• Images of this type tend to have histograms with multiple distinct peaks or modes in them

Page 41: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

42

BIMODAL HISTOGRAM

• If the peaks are well-separated, threshold selection can be easy

• Set the threshold T somewhere between the peaks

• It may be an interactive trial-and-error process

bimodal histogram

poorly separatedbimodal histogram

well separated peaks

Page 42: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

43

THRESHOLD SELECTION FROM

HISTOGRAM• Placing threshold T between

modes may yield acceptable

results

• Exactly where in between can be

difficult to determine

• An image histogram may contain

multiple modes. Placing the

threshold in different places will

produce very different results

• Histogram may be "flat," making

threshold selection difficult

Page 43: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Histogram Example

Prof. Shishir Shah 44

input image

• Reality

intensityp

ixel

co

un

t

Page 44: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Example: How to find T

• Microscopic image

• Grey level binary image

• Binary: 1-cell present, 0-cell absent

Page 45: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑝𝑒𝑎𝑘1

𝑻

𝑝𝑒𝑎𝑘2

Page 46: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑻

How to estimate/ approximate peaks?

𝑝𝑒𝑎𝑘1 𝑝𝑒𝑎𝑘2

Page 47: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Recap: Probability

• Data: {5,5,6,6,6,7,7,7,7,7,7,8,8,8,9,9,10,10}

• 𝑋: random variable

• P: probability function

• 𝑃 𝑋 = 7 = ?

Page 48: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Recap: Probability

• Data: {5,5,6,6,6,7,7,7,7,7,7,8,8,8,9,9,10,10}

• 𝑋: random variable

• P: probability function

• 𝑃(𝑋 = 7) = 0.33

Page 49: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Recap: Histogram

• Data: {5,5,6,6,6,7,7,7,7,7,7,8,8,8,9,9,10,10}

• 𝑋: random variable

• P: probability function

• 𝑃(𝑋 = 7) = 0.33

• Histogram0

2

4

6

8

1 2 3 4 5 6 7 8 9 10 11 12

freq.

Page 50: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Recap: Probability Distribution

• Data: {5,5,6,6,6,7,7,7,7,7,7,8,8,8,9,9,10,10}

• 𝑋: random variable

• P: probability function

• 𝑃(𝑋 = 7) = 0.33

• PNormalize(Histogram)

• What is a single value that represents this distribution

0

1/10

1/5

3/10

2/5

1 2 3 4 5 6 7 8 9 10 11 12

P

Probability distribution

Page 51: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Expectation

• 𝐸(𝑋)Expected value of random variable X

• ~Average of all the expected values of random variable X

• 𝐸 𝑋 =?

Page 52: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Expectation

• 𝐸(𝑋)Expected value of random variable X

• ~Average of all the expected values of random variable X

• 𝐸 𝑋 = σ𝑋𝑃(𝑋)

• Example: X outcome of rolling a dice

• Sample space: {1,2,3,4,5,6}

• P(X=1) = 1/6, P(X=2) = 1/6, …

• E[X] = ?

Page 53: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Expectation

• 𝐸(𝑋)Expected value of random variable X

• ~Average of all the expected values of random variable X

• 𝐸 𝑋 = σ𝑋𝑃(𝑋)

• Example: X outcome of rolling a dice

• Sample space: {1,2,3,4,5,6}

• P(X=1) = 1/6, P(X=2) = 1/6, …

• E[X] = 1*1/6 + 2*1/6 +…. = 3.5

Page 54: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Recap: Probability Distribution

• Data: {5,5,6,6,6,7,7,7,7,7,7,8,8,8,9,9,10,10}• 𝑋: random variable• P: probability function

• 𝑃(𝑋 = 7) = 0.33• PNormalize(Histogram)

• How to represent this data using a single value?• E(X) = 5 * 0.11 + 6*0.17 + 7*0.33 +… = 7.33

0

1/10

1/5

3/10

2/5

1 2 3 4 5 6 7 8 9 10 11 12

P

Probability distribution

Page 55: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑻

How to estimate/ approximate peaks?

𝑝𝑒𝑎𝑘1 𝑝𝑒𝑎𝑘2

Page 56: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

57

Algorithm

𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒 𝑇 = 𝐾/2𝐷𝑜

𝐶𝑜𝑚𝑝𝑢𝑡𝑒 μ1 = 𝐸 𝑋 ∀𝑋 <𝐾

2

𝐶𝑜𝑚𝑝𝑢𝑡𝑒 μ2 = 𝐸 𝑋 ∀𝑋 ≥𝐾

2

𝑆𝑒𝑡 𝑇 =𝜇1 + 𝜇2

2𝑊ℎ𝑖𝑙𝑒 ∆𝜇1! = 0 &∆𝜇2! = 0

bimodal histogram

well separated peaks

AKA: Expectation Maximization (simple version)

Page 57: Digital Image Processing - University of Houstonqil.uh.edu/dip/media/Lecture_-_5.pdf · Digital Image Processing COSC 6380/4393 Lecture –5 Sept 12th, 2017 ... Consists of sampling

58

BIMODAL HISTOGRAM

bimodal histogram

poorly separatedbimodal histogram

well separated peaks