Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020....

50
Digital Image Processing COSC 6380/4393 Lecture – 6 Sept 10 th , 2020 Pranav Mantini Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Transcript of Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020....

Page 1: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Digital Image ProcessingCOSC 6380/4393

Lecture – 6

Sept 10th, 2020

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

Page 2: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 3: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Weeks 1 & 2 3

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 4: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Interpolation: Nearest Neighbor

5 X 8 Image3 X 3 Image

Fill in values preserving spatial relationship

Page 5: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 6: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 7: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 8: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 9: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Review: DIGITAL IMAGE REPRESENTATION

(contd.)• Example - Binary Image

(2-valued, usually

BLACK and WHITE)

• Another way of depicting the

image:

Page 10: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

10

BINARY IMAGES

• 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 11: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

11

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 12: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

12

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 13: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Grey Level Binary Image

8X8 image Black box on white background

Page 14: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 15: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

15

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 16: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

16

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 17: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 18: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Grey Level Binary Image

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?

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

Page 19: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 20: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Grey Level Binary Image

8X8 image grey box on black background

8X8 image white box on dark white background

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

240 240 240 240 240 240 240 240

240 240 240 240 240 240 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 240 240

240 240 240 240 240 240 240 240

240 240 240 240 240 240 240 240

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

Page 21: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

21

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 22: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Grey Level Binary Image

8X8 image grey box on black background

8X8 image white box on dark white background

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

240 240 240 240 240 240 240 240

240 240 240 240 240 240 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 240 240

240 240 240 240 240 240 240 240

240 240 240 240 240 240 240 240

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

Page 23: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

23

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 24: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Grey Level Binary Image

8X8 image light white box on white background

How do we determine 𝑇?

10 10 10 10 10 10 10 10

10 10 10 10 10 10 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 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

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 black box on grey background

Page 25: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Determine modes

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

10 10 10 10 10 10 10 10

10 10 10 10 10 10 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 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

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

Page 26: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Determine modes

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

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

10 10 10 10 10 10 10 10

10 10 10 10 10 10 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 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

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 27: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

27

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(x) = n if I contains exactly n occurrences of gray level

x, for each x = 0, ... K-1

Page 28: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Histogram Example

input imageintensity

pix

el

co

un

t

Black = 0

Gray = 190

White = 254

Page 29: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

29

HISTOGRAM APPEARANCE

• The appearance of a histogram suggests much about the image

Page 30: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

30

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 31: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

31

HISTOGRAM APPEARANCE

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

• Well-distributed histogram

Page 32: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Histogram Example

input imageintensity

pix

el

co

un

t

Black = 0

Gray = 190

White = 254

Page 33: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Histogram Example

Prof. Shishir Shah 33

input image

• Reality

intensity

pix

el

co

un

t

Page 34: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

34

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 35: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

35

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 36: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

36

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 37: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Example: How to find T

• Microscopic image

• Grey level binary image

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

Page 38: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑝𝑒𝑎𝑘1

𝑻

𝑝𝑒𝑎𝑘2

Page 39: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑻

How to estimate/ approximate peaks?

𝑝𝑒𝑎𝑘1 𝑝𝑒𝑎𝑘2

Page 40: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Recap: Probability

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

• 𝑋: random variable

• P: X [0,1] probability function

• 𝑃 𝑋 = 7 = ?

Page 41: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 42: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 43: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 44: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Expectation

• 𝐸(𝑋)Expected value of random variable X

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

• 𝐸 𝑋 =?

Page 45: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 46: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 47: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

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 48: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

Example: How to find T

• Determine peaks

• Choose 𝑇 between peaks(say average)

𝑻

How to estimate/ approximate peaks?

𝑝𝑒𝑎𝑘1 𝑝𝑒𝑎𝑘2

Page 49: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

49

Algorithm

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

𝐶𝑜𝑚𝑝𝑢𝑡𝑒 μ1 = 𝐸 𝑋 ∀𝑋 < 𝑇𝐶𝑜𝑚𝑝𝑢𝑡𝑒 μ2 = 𝐸 𝑋 ∀𝑋 ≥ 𝑇

𝑆𝑒𝑡 𝑇 =𝜇1 + 𝜇2

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

bimodal histogram

well separated peaks

AKA: Expectation Maximization (simple version)

Page 50: Digital Image Processing · Digital Image Processing COSC 6380/4393 Lecture – 6 Jan 30 th, 2020. Pranav Mantini. Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu

50

BIMODAL HISTOGRAM

bimodal histogram

poorly separatedbimodal histogram

well separated peaks