3.point operation and histogram based image enhancement

36
Amity School of Engineering & Technology 1 Amity School of Engineering & Technology Digital Image Processing Credit Units: 4 Mukesh Bhardwaj

description

digital image processing

Transcript of 3.point operation and histogram based image enhancement

Page 1: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

1

Amity School of Engineering & Technology

Digital Image Processing

Credit Units: 4

Mukesh Bhardwaj

Page 2: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

Image Enhancement

Point operations&

Histogram based Image Enhancement

2

Page 3: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

Image is NOT Perfect Sometimes

3

Page 4: 3.point operation and histogram based image enhancement

Amity School of Engineering & TechnologyImage Enhancement for Visually Impaired Patients

4

http://www.eri.harvard.edu/faculty/peli/projects/enhancement.html

Page 5: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

5

Image Enhancement IntroductionSpatial domain techniques

Point operations Histogram equalization and

matching Applications of histogram-based

enhancementFrequency domain techniques

Unsharp masking Homomorphic filtering*

Page 6: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

6

Recall: • There is no boundary of imagination in the virtual world• In addition to geometric transformation (warping)

techniques, we can also photometrically transform images– Ad-hoc tools: point operations– Systematic tools: histogram-based methods– Applications: repair under-exposed or over-exposed

photos, increase the contrast of iris images to facilitate recognition, enhance microarray images to facilitate segmentation.

Page 7: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

7

Point Operations OverviewPoint operations are zero-memory operations wherea given gray level x[0,L] is mapped to anothergray level y[0,L] according to a transformation

)(xfy

L

L

x

y

L=255: for grayscale images

Page 8: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

8

Lazy Man Operation

L

L

x

y

xy

No influence on visual quality at all

Page 9: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

9

Digital Negative

xLy

L x0

L

Page 10: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

10

Contrast Stretching

Lxbybx

bxayax

axx

y

b

a

)(

)(

0

L x0 a b

ya

yb

200,30,1,2,2.0,150,50 ba yyba

Page 11: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

11

Clipping

Lxbab

bxaax

ax

y

)(

)(

00

L x0 a b

2,150,50 ba

Page 12: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

12

Range Compression)1(log10 xcy

L x0

c=100

Page 13: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

13

Summary of Point Operation

• So far, we have discussed various forms of mapping function f(x) that leads to different enhancement results– MATLAB function >imadjust

• The natural question is: How to select an appropriate f(x) for an arbitrary image?• One systematic solution is based on the histogram information of an image

– Histogram equalization and specification

Page 14: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

14

Histogram based EnhancementHistogram of an image represents the relative frequency of occurrence of various gray levels in the image

0 50 100 150 2000

500

1000

1500

2000

2500

3000

MATLAB function >imhist(x)

Page 15: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

15

Why Histogram?

Histogram information reveals that image is under-exposed

0 50 100 150 200 250

0

0.5

1

1.5

2

2.5

3

3.5

4

x 104

It is a baby in the cradle!

Page 16: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

16

Another Example

0 50 100 150 200 250

0

1000

2000

3000

4000

5000

6000

7000

Over-exposed image

Page 17: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

17

How to Adjust the Image?• Histogram equalization

– Basic idea: find a map f(x) such that the histogram of the modified (equalized) image is flat (uniform).

– Key motivation: cumulative probability function (cdf) of a random variable approximates a uniform distribution

x

t

thxs0

)()(Suppose h(t) is the histogram (pdf)

Page 18: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

18

Histogram Equalization

x

t

thLy0

)(Uniform

Quantization

L

t

th0

1)(Note:

L

1

x

t

ths0

)(

x

L

y

0

cumulative probability function

http://en.wikipedia.org/wiki/Inverse_transform_sampling

Page 19: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

19

MATLAB Implementationfunction y=hist_eq(x)

[M,N]=size(x);for i=1:256 h(i)=sum(sum(x= =i-1));End

y=x;s=sum(h);for i=1:256 I=find(x= =i-1); y(I)=sum(h(1:i))/s*255;end

Calculate the histogramof the input image

Perform histogramequalization

Page 20: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

20

Image Example

before after

Page 21: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

21

Histogram Comparison

0 50 100 150 2000

500

1000

1500

2000

2500

3000

0 50 100 150 200 250 3000

500

1000

1500

2000

2500

3000

before equalization after equalization

Page 22: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

Adaptive Histogram Equalization

22

http://en.wikipedia.org/wiki/Adaptive_histogram_equalization

Page 23: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

23

Histogram Specification/Matching

ST

S-1*T

histogram1 histogram2

?

Given a target image B, how to modify a given image A such thatthe histogram of the modified A can match that of target image B?

Page 24: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

24

Application (I): Digital Photography

Page 25: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

25

Application (II): Iris Recognition

before after

Page 26: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

26

Application (III): Microarray Techniques

before after

Page 27: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

27

Application (IV)

Page 28: 3.point operation and histogram based image enhancement

Amity School of Engineering & TechnologyApplication (V): Entertainment

28

LDR videoHistogram-equalizedAdaptive histogram-equalized1

1Eric P. Bennett and Leonard McMillan. “Video enhancement using per-pixel virtual exposures,” In ACM SIGGRAPH 2005

Page 29: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

29

Image Enhancement IntroductionSpatial domain techniques

Point operations Histogram equalization and

matching Applications of histogram-based

enhancementFrequency domain techniques

Unsharp masking Homomorphic filtering

Page 30: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

30

Frequency-Domain Techniques (I): Unsharp Masking

0),,(),(),( nmgnmxnmy

g(m,n) is a high-pass filtered version of x(m,n)

• Example (Laplacian operator)

)]1,()1,(

),1(),1([4

1),(),(

nmxnmx

nmxnmxnmxnmg

Page 31: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

31

MATLAB Implementation% Implementation of Unsharp masking

function y=unsharp_masking(x,lambda)

% Laplacian operationh=[0 -1 0;-1 4 -1;0 -1 0]/4;dx=filter2(h,x);y=x+lambda*dx;

Page 32: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

32

0 50 100 150 200 2500

50

100

150

200

250

1D Example

0 50 100 150 200 2500

50

100

150

200

250

0 50 100 150 200 250 300-8

-6

-4

-2

0

2

4

6

8

0 50 100 150 200 250 30080

100

120

140

160

180

200

220

x(n) xlp(n)

g(n)=x(n)-xlp(n) )()()( ngnxny

Page 33: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

33

2D Example

>roidemoMATLAB command

Page 34: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

34

Frequency-Domain Techniques (II): Homomorphic filtering

),(),(),( yxryxiyxf

Illumination(low freq.)

reflectance(high freq.)

Basic idea:

),(ln),(ln),(ln yxryxiyxf

freq. domain enhancement

Page 35: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

35

Image Example

before after

Page 36: 3.point operation and histogram based image enhancement

Amity School of Engineering & Technology

36

Summary of Nonlinear Image Enhancement

• Understand how image degradation occurs first– Play detective: look at histogram distribution, noise statistics, frequency-domain coefficients…– Model image degradation mathematically and try inverse-engineering

• Visual quality is often the simplest way of evaluating the effectiveness, but it will be more desirable to measure the performance at a system level – Iris recognition: ROC curve of overall system– Microarray: ground-truth of microarray image segmentation result provided by biologists