Вы находитесь на странице: 1из 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
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 ABCXYZ0123456789 in the same font as the
EIBLT8H written on the license plate.

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.


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
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.
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 detectors accuracy.

Noise specks
prevent exact
matching with
foreground and
background SEs of
the hit-miss filter.

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, p
1
, SE
1
) and rank-filter(NOT[binary image], p
2
, SE
2
). Here, SE
1
and SE
2
are the
same foreground and background SEs used in Part C, and p
1
and p
2
indicate the two ranks.
Note that if p
1
= p
2
= 1, then the minimum of the two rank filters is the same as the hit-miss
filter. Choose and report the ranks p
1
and p
2
that enable correct detection of the characters in
the noisy license plate without false positives. The MATLAB function for rank filtering is
ordfilt2.
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.

Foreground SE
erode(template, 1x3 rect)
Background SE
dilate(template, 1x7 rect)
dilate(template, 1x5 rect)
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.

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

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.
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.

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.

3x3 Median Filtering

5x5 Median Filtering
3x3 Median Filtering


5x5 Median Filtering
Part B:
Given a set of input values f
1
, f
2
,, f
N
and weights w
1
, w
2
,, w
N
, weighted median filtering
repeats f
i
by w
i
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 N
g 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
(
(
(
(
(
(
(
(

5x5 Weighted Median Filtering



5x5 Weighted
Median Filtering
5x5 Median
Filtering
3x3 Median
Filtering

5x5 Weighted Median Filtering


5x5 Weighted
Median Filtering
5x5 Median
Filtering
3x3 Median
Filtering
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.
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