23
240-373 Image Processing 1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

Embed Size (px)

Citation preview

Page 1: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 1

Statistical Operations

• Gray-level transformation• Histogram equalization• Multi-image operations

Page 2: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 2

Histogram

• If the number of pixels at each gray level in an image is counted (may use the follo

wing code fragment)

0for (row= ; row<rowmax; roww++) (=0; =; ++) {

count[image[row,col]]++; }

Page 3: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 3

Histogram

• The array “count” can be plotted to represent a “histogram” of the image as the number of pixels at particular gray level

• The histogram can yield useful information about the nature of the image. An image may be too bright or too dark.

Page 4: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 4

Histogram Illustration

0 1 2 3 4 50

1

2

3

4

5

6

7

8

9

10

1 2 3 2 3 2 0 0 1 2 1 4 4 4 2 1 2 1 1 2 1 2 1 2 5 4 2 1 4 0

Histogram

Page 5: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 5

Global Attenuation in Brightness

• To alter the brightness of an image by ad ding or subtracting all pixel values with a

constant

0for (row= ; row<rowmax; roww++) (=0; =; ++) {

image[row,col] += constant; }

Page 6: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 6

Adjusted Image

0 0.5 10

0.5

1Intensity Transformation

Histogram Histogram

Page 7: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 7

Adjusted Image

0 0.5 10

0.5

1Intensity Transformation

Histogram Histogram

Page 8: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 8

Adjusted Image

0 0.5 10

0.5

1Intensity Transformation

Histogram Histogram

Page 9: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 9

Adjusted Image

0 0.5 10

0.5

1Intensity Transformation

Histogram Histogram

Page 10: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 10

Thresholding

• Use: – To remove the gray level trends in an image– To make gray level more discrete– To segment or split an image into distinct

parts

• Operation:– setting all gray levels below a certain level

to “zero”, and above a certain level to a maximum brightness

Page 11: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 11

Code for Thresholding

0for (row= ; row<rowmax; roww++) (=0; =; ++) {

if (image[row,col] > threshold) image[row,col] = MAX;

else image[row,col] = MIN;

}

Page 12: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 12

Adjusted Image

0 0.5 10

0.5

1Intensity Transformation

Histogram Histogram

Page 13: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 13

Thresholding Errors

• Rarely is it possible to identify a perfect gray level break, what we want to be background pixels become foreground or vice versa– Type 1: not all pixels caught that should be

included– Type 2: some pixels caught should not be

included in the group

Page 14: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 14

An image before and after thresholding

Page 15: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 15

Bunching (Quantizing)

• Use:– to reduce the number of different gray level

in an image– to segment an image– to remove unwanted gray level degradation

• Operation:– Close gray levels are combined, thus

removing unwanted variations in data

Page 16: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 16

Bunching (Quantizing)

• Method 1: inspecting histogram and combining close group into single gray level

• Method 2: identifying a set of gray levels allowed in the final image, then changing the gray level in every pixel to its nearest allowed value

Page 17: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 17

Bunching Example

9273958450890

1673738267483

7838304563830

5264825263481

9363969360990

0663639366393

6939303663930

6363936363390

0 ****

1 ** 2 ***

**

3 *******

**

4 *****

5 *****

6 *****

7 *****

8 *******

**

9 ***

0 ******

1 2 3 ****

******

******

***

4 5 6 ****

******

*****

7 8 9 ****

******

**

Page 18: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 18

Bunching Code

0for (row= ; row<rowmax; row++) (=0; <; ++){ *image[row,col] = bunchsize ((int)image[row,col]/bunchsi

);}

= === === == ====== == == ======= ==== ====

Page 19: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 19

Splittings

• Use:– to increase the different two groups of gray

levels so that the contrast between segments compose of one group of the other is enhanced

• Operation:– rounding the gray levels up if they are in the

range and down if they are in another

Page 20: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 20

Splitting Example

• The characters on a car number-plate are at gray level 98

• The background of the characters is at gray level 99

• Pushing 98 down to 80 and pushing 99 up to 120 will give the picture a better contrast around the number plate

Question: How to find a good splitting level?

Page 21: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 21

Automatic Selection of Splitting Level

• Use:– --to find the best gray level for splitting usuall

y for thresholding to black and white

• Operation:– ===

image in the

lessor levelgray at pixelsof number actual theis )(

and levelgray at pixelsof number theis )( where

)()(0

ggt

ggf

ifgtg

i

Page 22: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 22

Automatic Selection of Splitting Level

– Let P=NxM = === === === == ====== ===== =============

– Let m(g) ==== ==== ===== === ==== ===== ====== s containing gray level between zero and g , i . e.

== === ======= ====== == ==== ===== == G (G 0= ,…,G- 1) then evaluate the following equation (T ========= =

)

)(

)(.)( 0

gt

ifggm

g

i

1)1()()(

)(max 2

GmgmgtP

gtT

A B

Page 23: 240-373 Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations

240-373 Image

Processing 23

Example

Histogram f(g) t(g) g.f(g) g.f(g) m(g) A B A*B

0 **** 4 4 0 0 0 0.08 23.04 0.18 1 ** 2 6 2 2 03 013. 2025 283

2 ***** 5 11 10 12 11. 027 1369 370. 3 ********* 9 20 27 39 2 063. 784

494. 4 ***** 5 25 20 59 24. 093. 576. 536. 5 ***** 5 30 25 84 28. 136. 400. 544. 6 ***** 5 35 30 114 33. 206. 225. 464. 7 ***** 5 40 35 149 37. 333. 121. 403. 8 ********* 9 49 72 221 45. 1633. 009.

147. 9 *** 3 52 27 248 48. - -INF

- * 1 4T = max(A B) =