EE465 Midterm Review Mar. 23, 2010. MATLAB-based Midterm Exam Research-oriented learning Just like...

Preview:

Citation preview

EE465 Midterm Review

Mar. 23, 2010

MATLAB-based Midterm Exam

• Research-oriented learning

• Just like MATH, MATLAB is another tool (use it wisely)

• All Roads Lead to Rome

• The principle of finding out the answers is applicable to other engineering disciplines

• I hope it will be a FUN experience

Logistics• Part I (106=60 points)

– Test correct understanding of basic DIP concepts and flexible use of MATLAB tools

• Part II (106=60 points)– Test correct understanding of basic DIP algorithms

and their MATLAB implementations

• Part III (203=60 points)– Test advanced problem solving skills under

MATLAB

Part I• Image-related basics

– Spatial resolution, bit-depth resolution, color channels, basic matrix-related operations under MATLAB

• Image acquisition– sampling and quantization, CCD vs CMOS, Bayer

pattern, color demosaicing

• Image perception– Brightness vs. lightness, optical illusions

EE465: Introduction to Digital Image Processing

5

Bit-depth Resolution

If you want tohide somethinginto an image,which bitplaneis appropriate?

EE465: Introduction to Digital Image Processing

6

Block-based Processing

Are you good at the puzzle?

EE465: Introduction to Digital Image Processing

7

Sampling and Quantization(1D)

EE465: Introduction to Digital Image Processing

8

2D Sampling and Quantization

EE465: Introduction to Digital Image Processing

9

3D Visualization of an Image

0

20

40

60

80

100

120

0

20

40

60

80

100

0

100

200

300

400

Which Matlab function does 3D visualization?

Color Imaging: Bayer Pattern

EE465: Introduction to Digital Image Processing

10

US3,971,065

$38,990

$309

Why do we want Bayer pattern and why green is more denselysampled?

Demosaicing (CFA Interpolation)

EE465: Introduction to Digital Image Processing

11

EE465: Introduction to Digital Image Processing

12

Another Lightness Illusion

You will verify that A and B have exactly the same value in CA3.

EE465: Introduction to Digital Image Processing

13

Optical Illusions

$500000• Which of the following statement is NOT true?

– A) Fourier transform of a Guassian function is still Gaussian

– B) Histogram equalization is a nonlinear operation

– C) Median filtering is NOT translation invariant

– D) The total number of green pixels in a Bayer pattern is twice as many as that of red or blue ones

$1000000

• Which of the following pair of matlab codes is NOT equivalent to each other?– A) y=imnoise(x,’gaussian’,0,0.1) vs.

y=x+randn(size(x))*0.1

– B) imshow(x/255,[]) vs. imshow(x/1000,[]); % x is an image in double format

– C) imresize(x,2) vs. interp2(x,2)

– D) for i=1:length(x);if x(i)>128; x(i)=1;else x(i)=0; end;end; vs. x=(x>128);

Part II• Image-related algorithms

– Interpolation (imresize, interp2, griddata)• Replication, bilinear, bicubic, spline, advanced* (ESI,

NEDI)

– Denoising (imnoise, medfilt2, filter2, imfilter)• Salt & pepper vs. Gaussian vs. periodic, Hammer-Nail match

– Deblurring (please see deblurring.zip)• Why do we need FT? How to avoid divided-by-zero?

– Edge detection (edge, bwareaopen*, belabel*)• How to calculate the area and length of some object?

EE465: Introduction to Digital Image Processing

17

Resolution Enhancement based on Pixel Repetition

a b

c d

a a b b

a a b b

c c d d

c c d d

zero-order

first-order

a (a+b)/2b(a+c)/2 (a+b+c+d)/4(b+d)/2c (c+d)/2 d

EE465: Introduction to Digital Image Processing

18

Bilinear Interpolation of ImageBilinear Interpolation of Image

X(m,n)row m

row m+1

Col n Col n+1

X(m,n+1)

X(m+1,n+1)X(m+1,n)

Ya 1-ab

1-b

Q: what is the interpolated value at Y?Ans.: (1-a)(1-b)X(m,n)+(1-a)bX(m+1,n)+a(1-b)X(m,n+1)+abX(m+1,n+1)

EE465: Introduction to Digital Image Processing

19

Bicubic Interpolation*

Which matlab function implements bicubic interpolation?

EE465: Introduction to Digital Image Processing

20

Edge-Sensitive InterpolationStep 1: interpolate the missing pixels along the diagonal

black or white?

Step 2: interpolate the other half missing pixels

a b

c d

Since |a-c|=|b-d|x

x has equal probabilityof being black or white

a

b

c

dSince |a-c|>|b-d|

x=(b+d)/2=blackx

Please refer to esi1.m and esi2.m in interp.zip

EE465: Introduction to Digital Image Processing

21

Point Operations Overview

Point 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

EE465: Introduction to Digital Image Processing

22

Histogram Equalization

x

t

thLy0

)(Uniform

Quantization

L

t

th0

1)(Note:

L

1

x

t

ths0

)(

x

L

y

0

cumulative probability function

Can you write your own matlab function to implement this?

EE465: Introduction to Digital Image Processing

23

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

EE465: Introduction to Digital Image Processing

24

2D Median Filtering

225 225 225 226 226 226 226 226 225 225 255 226 226 226 225 226 226 226 225 226 0 226 226 255 255 226 225 0 226 226 226 226 225 255 0 225 226 226 226 255 255 225 224 226 226 0 225 226 226 225 225 226 255 226 226 228 226 226 225 226 226 226 226 226

0 225 225 226 226 226 226 226 225 225 226 226 226 226 226 226 225 226 226 226 226 226 226 226 226 226 225 225 226 226 226 226 225 225 225 225 226 226 226 226 225 225 225 226 226 226 226 226 225 225 225 226 226 226 226 226 226 226 226 226 226 226 226 226

Y X̂

Sorted: [0, 0, 0, 225, 225, 225, 226, 226, 226]

EE465: Introduction to Digital Image Processing

25

Median Filtering with Noise Detection

Noisy image Y

x=medfilt2(y,[2*T+1,2*T+1]);Median filtering

Noise detectionC=(y==0)|(y==255);

xx=c.*x+(1-c).*y;Obtain filtering results

Why do we want to introduce noise detection?

EE465: Introduction to Digital Image Processing

26

Image Example

clean noisy(p=0.2)

w/onoisedetection

withnoisedetection

EE465: Introduction to Digital Image Processing

27

Image Deblurring: Inverse Filtering

h(m,n)

blurring filter

hI(m,n)x(m,n)

y(m,n)

inverse filter

k l

I

Icombi

nmnmlkhlnkmh

nmhnmhnmh

),(),,(),(),(

),(),(),(

),(

1),(

2121 wwH

wwH I

To compensate the blurring, we requirehcombi (m,n)

x(m,n)^

EE465: Introduction to Digital Image Processing

28

Inverse Filtering (Con’t)

h(m,n) +x(m,n) y(m,n)

),( nmw

hI(m,n)

inverse filter

x(m,n)^

Spatial:),()),(),(),((),(),(),(ˆ nmhnmwnmhnmxnmhnmynmx II

Frequency:

),(

),(),(

),(

),(),(),(),(),(),(ˆ

21

2121

21

212121212121

wwH

wwWwwX

wwH

wwWwwHwwXwwHwwYwwX I

amplified noise (what if H→0?)

EE465: Introduction to Digital Image Processing

29

Image Example

Q: Why does the amplified noise look so bad?A: zeros in H(w1,w2) correspond to poles in HI (w1,w2)

motion blurred image at BSNR of 40dB

deblurred image afterinverse filtering

EE465: Introduction to Digital Image Processing

30

Pseudo-inverse Filter

Basic idea:

To handle zeros in H(w1,w2), we treat them separatelywhen performing the inverse filtering

|),(|0

|),(|),(

1),(

21

212121

wwH

wwHwwHwwH

Why do we want to introduce this threshold parameter ?

EE465: Introduction to Digital Image Processing

31

Image Example

motion blurred image at BSNR of 40dB

deblurred image afterPseudo-inverse filtering

(=0.1)

EE465: Introduction to Digital Image Processing Copyright Xin Li

32

Gradient Operators

• Motivation: detect changes

change in the pixel value large gradient

Gradient operator

image Thresholdingedgemap

x(m,n) g(m,n) I(m,n)

otherwise

thnmgnmI

0

|),(|1),(

MATLAB function: > help edge

EE465: Introduction to Digital Image Processing Copyright Xin Li

33

Examples of Different Gradient Operators

horizontal edge vertical edge

Prewitt operator (th=48)

original image

EE465: Introduction to Digital Image Processing Copyright Xin Li

34

Effect of Thresholding Parameters

thresholdsmall large

$125000

100row m

row m+1

Col n Col n+1

200

100200

Ya 1-ab

1-b

a=0.25b=0.25

What is Y?A)112.5B)125C)137.5D)150

Bilinear Interpolation Numerical Example

$250000

225 225 225 226 226 226 226 226 225 225 255 226 226 226 225 226 226 226 225 226 0 226 226 255 255 226 225 0 226 226 226 226 225 255 0 225 226 226 226 255 255 225 224 226 226 0 225 226 226 225 225 226 255 226 226 228 226 226 225 226 226 226 226 226

What is the pixel value at red zeroafter median filter (window size 5-by5)?A)224B)225C)226D)0

Part III

• Image-related tasks– A collection of “bonus problems” which can be

solved by different tools– Mentally solve it vs. experimentally solve it– Designed like interview questions of major IT

companies (except the default computing language)

Final-Jeopardy

What are the angles of tripod in the image cameraman.tif?

Final-Jeopardy

Process the baby.bmp image in CA5 so you can see baby clearly

Final-Jeopardy

Turn Cameran image from grayscale to a greenish color image.

Recommended