# Homework Assignment 3 - whoff/courses/EENG510/homework/ آ  CSCI 510/EENG 510 Image and Multidimensional

• View
6

0

Embed Size (px)

### Text of Homework Assignment 3 - whoff/courses/EENG510/homework/ آ  CSCI 510/EENG 510 Image and...

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

1

Homework Assignment 3 - SOLUTIONS Due Wednesday, October 7, 2015

Notes: Please email me your solutions for these problems (in order) as a single Word or PDF document. If you do a problem on paper by hand, please scan it in and paste it into the document (although I would prefer it typed!). 1. (25 pts) The file “eye-hand.png1” from the course website is an image of a robot arm,

with a certain amount of periodic noise. The noise looks like a pattern of close lines running diagonally from bottom left to top right. The closeup subimage below, taken from the center of the image, shows the pattern. Using the method of notch filtering, remove this noise. Show (a) the Matlab code, (b) the mask you used, and (c) the resulting image (also please show a subimage from the result, like the one below).

Solution: The original image and its spectrum are shown below.

1 This image is from Klaus Hansen of DIKU.

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

2

Note the four distinct peaks in the spectrum, corresponding to the periodic noise. It looks like there are actually two repetitive patterns of noise, corresponding to the two pairs of symmetrical peaks. We will zero out the frequencies corresponding to the noise. We create a notch filter, composed of all 1’s except for 0’s at the locations of the peaks:

Multiplying the notch filter by the Fourier transform of the image, and then taking the inverse Fourier transform, we get the image minus the periodic noise. The image (and a closeup) is shown below. The periodic noise has been removed.

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

3

The Matlab code is given below. clear all close all I=imread('eye-hand.png'); imshow(I,[]); Fshift = fftshift(fft2(double(I))); figure, imshow(log(abs(Fshift)), []), impixelinfo; % From inspecting by hand, peaks are at (x,y): P = [ ... 385, 102; ... 128, 413; ... 128, 156; ... 385, 359; ... ]; % Make a mask with zeros at those locations M = ones(size(I,1), size(I,2)); N = 15; disk = zeros(N,N); for i=1:length(P) M(P(i,2)-floor(N/2):P(i,2)+floor(N/2), P(i,1)- floor(N/2):P(i,1)+floor(N/2)) = disk(:,:); end figure, imshow(M, []); Gshift = M .* Fshift; G = ifftshift(Gshift); g = abs(ifft2(G)); figure, imshow(g, []); Another interesting thing to see is the noise without the rest of the image. Subtracting the filtered image from the original, you get:

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

4

A closeup view:

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

5

2. (25 pts) You are given the binary image A and the structuring element B below

(assume the origin of B is its center).

A: B: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(a) Label (by hand) the 4-connected components, for foreground (1) pixels. (b) Compute (by hand) the morphological opening of A with B. (c) Demonstrate using this example that dilation and erosion are duals of each other; i.e.;

(A Ө B)c = BAc ˆ⊕ (a) The 4-connected components are shown below. Of course, you could have chosen different actual numerical labels for the components. The important thing is that there are 3 of them.

1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 2 2 2 2 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

(b) “Opening” is erosion followed by dilation. The erosion of A by B is shown on the left, and the subsequent dilation on the right:

1 1 1

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

6

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(c) Duality is ( ) BABA cc ˆθ ⊕= . The figure below is ( )cBAθ … the left figure shows the 0’s and the right figure the 1’s (note that the 1’s continue infinitely off the border of the image). 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The figure below is cA (again, 1’s continue infinitely off the border in all directions). 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

7

The figure below is BAc ˆ⊕ . Note that it is the same as ( )cBAθ above. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

3. (25 pts) On the course web site is an image2 of zirconia/silica particles called

“Particles.jpg”. Using morphological operations, determine as accurately as possible how many distinct particles are in this image (the result won’t be exact). On the original image, mark the center of each detected particle (for example, using Matlab’s “rectangle” function). Give the program, images, and the resulting count.

Solution: You first need to threshold the image to separate the particles from the background. Looking at the histogram with “imtool”, the best segmentation occurs at a threshold of about 100. Next, we do connected component labeling. However, some particles are touching each other at the edges. In order for connected component labeling to work correctly, you will have to shrink (erode) the regions. I used a disk structuring element with a radius of 3 pixels to erode the regions. Then you can do connected component labeling on the eroded images. The number of particles I found was 516. Matlab code: clear all close all I = imread('Particles.jpg'); % I found the threshold manually using imtool BW = (I>100); figure, imshow(BW); % Create a disk structuring element of radius 3. The "0" parameter % specifies that you don't want an approximation of the disk boundary using % line segments.

2 From: http://www.weck.ca/index.php?mode=16

http://www.weck.ca/index.php?mode=16

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

8

S = strel('disk', 3, 0); % Erode image using S E = imerode(BW,S); figure, imshow(E); [L,n] = bwlabel(E); blobs = regionprops(L); figure, imshow(I, []); for i=1:n rectangle('Position', blobs(i).BoundingBox); end fprintf('Found %d particles\n', n);

Note – you can show a closeup of two particles in the original thresholded image, and then the eroded image, like this:

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

9

4. (25 pts) Apply the Matlab Canny edge detector to the image below, which can be found at the website http://people.csail.mit.edu/bkph/pictures. Adjust the algorithm parameters (i.e., thresholds and sigma) to try to get the best results, in terms of finding the edges of the blocks, and no other edges. (When the field of computer vision began in the 1960’s, people thought that extracting edges and lines from real images like this would be easy, but it has proven surprisingly hard!)

a. Give the best result you can achieve and report the algorithm parameters used. Comment on where edges are missed, or false edges are found.

b. Find another real (i.e., not synthetic or computer-generated) image containing objects that you think might give better results, and repeat the steps in part (a). I suggest finding something on www.flickr.com.

Solution

(a) I achieved this result, using Thigh (threshold_high) = 0.18, and sigma = 2.5. Although I got rid of most of the non-block edges, I missed many valid edges.

(b) Here is an image that gives better results, using Thigh = 0.3 and the default sigma=1.0

http://people.csail.mit.edu/bkph/pictures

• CSCI 510/EENG 510 Image and Multidimensional Signal Processing Fall 2015

10

Even the result from this “easy” image has missing edges. Also the corners of the checks are improperly detected, as shown in this zoomed in portion:

Recommended

Documents
Documents
Documents
Documents
Technology
Documents
Documents
Documents
Documents
Documents
Documents
Documents