Hw3 Problem Session

32
1. License Plate Recognition In this problem, we study how to recognize the characters on a license plate using morphological image processing. Please download the following two test images hw 3_license_plate_clean.png and hw 3_license_plate_noisy.png from the handouts webpage. Please also download the file hw 3_character_templates.zip, which contains 36 separate images of the alphanumeric characters “ABC…XYZ0123456789in the same font as the “EIBLT8H” written on the license plate.

description

Stanfard assignment for license plate recognition

Transcript of Hw3 Problem Session

Page 1: Hw3 Problem Session

1. License Plate Recognition

In this problem, we study how to recognize the characters on a license plate using

morphological image processing. Please download the following two test images

hw3_license_plate_clean.png and hw3_license_plate_noisy.png from the handouts webpage.

Please also download the file hw3_character_templates.zip, which contains 36 separate

images of the alphanumeric characters “ABC…XYZ0123456789” in the same font as the

“EIBLT8H” written on the license plate.

Page 2: Hw3 Problem Session

Part A:

Binarize the clean license plate image, the noisy license plate image, and the template

images, so that the large characters in the middle of the plate appear as white and the

background appears as black. Use the same threshold for all binarization operations. Submit

the binarized clean and noisy license plate images.

Page 3: Hw3 Problem Session

Part B:

Perform character detection by erosion in the binarized clean license (MATLAB function:

imerode). To eliminate the effects of slight mismatches along the character boundaries,

compute a slightly eroded template which is erode(template, 3x3 square), and then use the

eroded template as the SE in the erosion detector. For each template that generates a nonzero

detection result, dilate the eroded license plate image (MATLAB function: imdilate) by the

template.

True Positives

False Positives

Page 4: Hw3 Problem Session

Part C:

Repeat Part B, except use a hit-miss filter in place of erosion for the detector (MATLAB

function: bwhitmiss). Use the same SE as in Part B for the foreground SE. For the

background SE, use the difference dilate(template, 5x5 square) – dilate(template, 3x3

square) which extracts a thin outline around the character. Comment on the advantages of

the hit-miss detector compared to the erosion detector.

Page 5: Hw3 Problem Session

Part D:

Repeat Part C, except replace the clean license plate image by the noisy license plate image.

Comment on how the noise affects the hit-miss detector’s accuracy.

Noise specks

prevent exact

matching with

foreground and

background SE’s of

the hit-miss filter.

Page 6: Hw3 Problem Session

Part E:

Repeat Part C, except replace the clean license plate image by the noisy license plate image

and replace the hit-miss filter by the minimum of two rank filters: rank-filter(binary

image, p1, SE1) and rank-filter(NOT[binary image], p2, SE2). Here, SE1 and SE2 are the

same foreground and background SEs used in Part C, and p1 and p2 indicate the two ranks.

Note that if p1 = p2 = 1, then the minimum of the two rank filters is the same as the hit-miss

filter. Choose and report the ranks p1 and p2 that enable correct detection of the characters in

the noisy license plate without false positives. The MATLAB function for rank filtering is

ordfilt2.

Page 7: Hw3 Problem Session

2. Duplicate Key Detection

In a large set of keys, we would like to use image processing to automatically detect if two

keys are duplicates of each other. Two keys can be considered duplicates even if they have

different bows, as long as their blades are identical. Please download the images

hw3_keys_set.png and hw3_key.png from the handouts webpage.

Design and implement an image processing algorithm to automatically determine which key

(if any) in hw3_keys_set.png is a duplicate of the key in hw3_key.png. Clearly describe the

steps of your algorithm, including intermediate results if they help to explain the process.

Report which key (if any) in hw3_keys_set.png is determined by your algorithm to be a

duplicate of the key in hw3_key.png.

Page 8: Hw3 Problem Session

Foreground SE

erode(template, 1x3 rect)

Background SE

dilate(template, 1x7 rect) –

dilate(template, 1x5 rect)

Page 9: Hw3 Problem Session

3. Sharpness Enhancement by Grayscale Dilation and Erosion

In this problem, we use an iterative grayscale morphological image processing algorithm to

enhance the sharpness of structures in a blurry image.

Page 10: Hw3 Problem Session

Part A:

Please download the image hw3_road_sign_school_blurry.jpg from the homework webpage.

This image shows a school crossing road sign taken by an out-of-focus camera. Apply 10

iterations of the following algorithm. Design and report your structuring element. Submit the

resulting image after 10 iterations. Comment on which features in the image have been made

sharper.

Im := Input Image

For Iteration = 1:NumIterations

Im_d = dilate(Im, W) % Note that this is grayscale dilation

Im_e = erode(Im, W) % and erosion with structuring element W

Im_h = 0.5(Im_d + Im_e)

% Perform the following test for each pixel

If Im > Im_h

Im := Im_d

Else

Im := Im_e

End

End

Page 11: Hw3 Problem Session
Page 12: Hw3 Problem Session

Part B:

Submit plots of the intensity profile in row 338 after iterations 1, 2, …, 10. For example, the

following is a plot of the intensity profile in row 338 in the original image. Comment on

how the algorithm iteratively changes the intensity profile.

Page 13: Hw3 Problem Session

4. Noise Reduction by Median Filtering

In this problem, we study how to use different types of median filtering to reduce salt-and-

pepper noise in vintage photographs.

Page 14: Hw3 Problem Session

Part A:

Please download the images hw3_building.jpg and hw3_train.jpg from the homework

webpage. Apply median filtering with a 3x3 window and a 5x5 window (MATLAB

function: medfilt2). Display and submit the resulting images. For each window size,

comment on how effectively the noise is reduced while sharp edges and features in the

image are preserved.

Page 15: Hw3 Problem Session

3x3 Median Filtering

Page 16: Hw3 Problem Session

5x5 Median Filtering

Page 17: Hw3 Problem Session

3x3 Median Filtering

Page 18: Hw3 Problem Session

5x5 Median Filtering

Page 19: Hw3 Problem Session

Part B:

Given a set of input values f1, f2,…, fN and weights w1, w2,…, wN, weighted median filtering

repeats fi by wi times and then computes the median of all the repeated values:

Perform weighted median filtering with the following 5x5 window of weights, where the

brackets around 4 indicate the center of the window:

1 1 2 2, , , N Ng median w f w f w f

times

, , ,

w

w f f f f

0 1 1 1 0

1 2 2 2 1

1 2 4 2 1

1 2 2 2 1

0 1 1 1 0

Page 20: Hw3 Problem Session

5x5 Weighted Median Filtering

Page 21: Hw3 Problem Session

5x5 Weighted

Median Filtering

5x5 Median

Filtering

3x3 Median

Filtering

Page 22: Hw3 Problem Session
Page 23: Hw3 Problem Session

5x5 Weighted Median Filtering

Page 24: Hw3 Problem Session

5x5 Weighted

Median Filtering

5x5 Median

Filtering

3x3 Median

Filtering

Page 25: Hw3 Problem Session
Page 26: Hw3 Problem Session

Bonus #1: Android with OpenCV

Read Tutorial #2 (OpenCV for Android Setup) on the class Android webpage.

Download and install all the necessary software as explained in Tutorial #2.

Select one of the examples found on the class Android webpage that uses OpenCV:

(1) local feature keypoint extraction

(2) edges/lines/circle detection

(3) locally adaptive binarization

(4) human face detection

Run the example on an Android device and take a screenshot. The screenshot should clearly

demonstrate a result of the underlying method or algorithm (e.g., local feature keypoints

overlaid on an object). Submit your screenshot.

Page 27: Hw3 Problem Session

Bonus #2: OpenCV Library

This problem guides you through the process of setting up the OpenCV library on your

computer. After the installation, you will be able to apply image processing functions

implemented in OpenCV on images/videos you load into MATLAB.

Options:

• Human face detection

• Local feature extraction

• Locally adaptive binarization

Page 28: Hw3 Problem Session
Page 29: Hw3 Problem Session
Page 30: Hw3 Problem Session
Page 31: Hw3 Problem Session
Page 32: Hw3 Problem Session