digital image processing lecture 4: image enhancement: point processing prof. charlene tsai

19
Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

Upload: ginger-brooks

Post on 02-Jan-2016

228 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

Digital Image Processing Lecture 4: Image Enhancement: Point ProcessingProf. Charlene Tsai

Page 2: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

2

Review

Point operations: A pixel’s gray value is changed without any knowledge of its surroundings.

Gray-level slicing Bit-plane slicing

Page 3: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

3

Arithmetic Operations

May perform arithmetic operations (+,-,*,/,neg) on an image.

Always make sure the new value, as well as the intermediate value, is within the intensity range.

Operations are straightforward. Matlab commands: imadd, imsubtract, etc..

Page 4: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

4

Image Subtraction

A more interesting arithmetic operation is pixel-wise subtraction of two images.

Refer to the fractal image again.

),(),(),( yxhyxfyxg

original 4 lower-order bit planes zeroed out

difference contrast enhanced

Page 5: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

5

(con’d)

Mask mode radiography The mask image is taken before injection of the contrast

medium into patient’s bloodstream Areas different between 2 images appear enhanced.

Mask: h(x,y) Result: g(x,y)

Page 6: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

6

What is a histogram? A graph indicating the number of times each gray

level occurs in the image, i.e. frequency of the brightness value in the image

The histogram of an image with L gray levels is represented by a one-dimensional array with L elements.

Algorithm: Assign zero values to all

elements of the array hf; For all pixels (x,y) of the

image f, increment

hf[f(x,y)] by 1.

Page 7: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

7

Histogram Examples

Page 8: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

8

Histogram/Contrast Stretching To increase the dynamic range of the gray

levels in the image. Piecewise linear function (r1, s1) & (r2, s2) control the shape of the

mapping, where

r1<r2 & s1<s2. What if

r1=s1 & r2=s2? r1=r2, s1=0 &

s2=L-1?

Page 9: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

9

Examples of Histogram Stretching

What is the problem here?

Original (r1=s1&r2=s2)

Contrast stretched (r1=rmin, r2=rmax, s1=0,s2=L-1)

Thresholding (r1=r2,s1=0&

s2=L-1)

Page 10: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

10

Histogram Equalization: Intuition Goal: to produce an image with equally distributed

brightness levels over the whole brightness scale. Effect: enhancing contrast for brightness values

close to histogram maxima, and decreasing contrast near minima.

Result is better than just stretching, and method fully automatic.

Page 11: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

11

Histogram equalization: How it works? Let be the input histogram and that the

input gray-scale is . The intention is to find a monotonic pixel

brightness mapping such that the output histogram is uniform over the whole output brightness scale

The monotonic property of the transform T implies

)( pH],[ 0 kpp

)( pTq )(qG

],[ 0 kqq

j

i

j

iii pHqG

0 0

)()(

Page 12: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

12

(con’d)

The histogram is a discrete probability density function.

The sum in the above equation can be interpreted as discrete distribution function.

Assume that the image has M rows and N columns. The equalized histogram corresponding to a uniform probability density function is:

0

)(qq

MNqG

k

Page 13: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

13

(con’d)

The equalized histogram can be obtained precisely only for the ``idealized'' continuous probability density, in which case the sum equation becomes

The desired pixel brightness transformation T can then be derived as

p

pk

q

qk

q

qdssH

qq

qqMNds

qq

MNdssG

000

)(0

0

0

00

0

)()( qdssHMN

qqpTq

p

p

k

Cumulative histogram

Page 14: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

14

(con’d)

The discrete approximation of the continuous pixel brightness transformation from the above equation is

00

0

)()( qiHMN

qqpTq

p

pi

k

Page 15: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

15

Histogram equalization - Algorithm For an NxM image of G gray-levels (often

256), compute the image histogram H. For the cumulative histogram Hc:

Set

Rescan the image and write an output image with gray-levels

1-G1,...,p ,][]1[][

]0[]0[

pHpHpH

HH

cc

c

][1

][ pHNM

GroundpT c

][ pq gTg

Page 16: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

16

Histogram equalization: Example

Original Equalized

Page 17: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

17

Histogram Matching/Specification The generalization of histogram equalization

is called histogram matching. The aim is to produce an image with desired

distributed brightness levels over the whole brightness scale, as opposed to uniform distribution.

Assume the histogram of the desired probability density function is G(q).

Let the desired pixel brightness transform be q=T[p].

Page 18: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

18

(con’d)

Similarly, the cumulative histogram of the input image is

From the above eqn, it is possible to find T. E.g. if G is the exponential distribution,

We have Then,

][

0

][][pTq

qc dssGpH

0)( for ,][ 0 qqeqG qq

)][( 01][ qpTc epH

][1log1

][ 0 pHqpT c

Page 19: Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai

19

Summary

Enhancement using point operations Arithmetic operations Histogram stretching Histogram equalization Histogram matching/specification