Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

Analyzing Images

Analyzing Images

In this section...

“Detecting Edges Using the edge Function” on page 11-11 “Detecting Corners Using the corner Function” on page 11-13 “Tracing Object Boundaries in an Image” on page 11-15 “Detecting Lines Using the Hough Transform” on page 11-20

“Analyzing Image Homogeneity Using Quadtree Decomposition” on page 11-24

The toolbox also includes functions that return information about the texture of an image. See “Analyzing the Texture of an Image” on page 11-27 for more information.

Detecting Edges Using the edge Function

In an image, an edge is a curve that follows a path of rapid change in image intensity. Edges are often associated with the boundaries of objects in a scene. Edge detection is used to identify the edges in an image.

To find edges, you can use the edge function. This function looks for places in the image where the intensity changes rapidly, using one of these two criteria:

Places where the first derivative of the intensity is larger in magnitude than some threshold

Places where the second derivative of the intensity has a zero crossing

edge provides a number of derivative estimators, each of which implements one of the definitions above. For some of these estimators, you can specify whether the operation should be sensitive to horizontal edges, vertical edges, or both. edge returns a binary image containing 1’s where edges are found and 0’s elsewhere.

The most powerful edge-detection method that edge provides is the Canny method. The Canny method differs from the other edge-detection methods in that it uses two different thresholds (to detect strong and weak edges), and

11-11

11 Analyzing and Enhancing Images

includes the weak edges in the output only if they are connected to strong edges. This method is therefore less likely than the others to be fooled by noise, and more likely to detect true weak edges.

The following example illustrates the power of the Canny edge detector by showing the results of applying the Sobel and Canny edge detectors to the same image:

1Read image and display it.

I = imread('coins.png'); imshow(I)

2Apply the Sobel and Canny edge detectors to the image and display them.

BW1 = edge(I,'sobel'); BW2 = edge(I,'canny'); imshow(BW1)

figure, imshow(BW2)

11-12

Analyzing Images

Detecting Corners Using the corner Function

Corners are the most reliable feature you can use to find the correspondence between images. The following diagram shows three pixels—one inside the object, one on the edge of the object, and one on the corner. If a pixel is inside an object, its surroundings (solid square) correspond to the surroundings

of its neighbor (dotted square). This is true for neighboring pixels in all directions. If a pixel is on the edge of an object, its surroundings differ from the surroundings of its neighbors in one direction, but correspond to the surroundings of its neighbors in the other (perpendicular) direction. A corner pixel has surroundings different from all of its neighbors in all directions.

The corner function identifies corners in an image. Two methods are available—the Harris corner detection method (the default) and Shi and Tomasi’s minimum eigenvalue method. Both methods use algorithms that depend on the eigenvalues of the summation of the squared difference matrix

11-13

11 Analyzing and Enhancing Images

(SSD). The eigenvalues of an SSD matrix represent the differences between the surroundings of a pixel and the surroundings of its neighbors. The larger the difference between the surroundings of a pixel and those of its neighbors, the larger the eigenvalues. The larger the eigenvalues, the more likely that a pixel appears at a corner.

The following example demonstrates how to locate corners with the corner function and adjust your results by refining the maximum number of desired corners.

1Create a checkerboard image, and find the corners.

I = checkerboard(40,2,2); C = corner(I);

2Display the corners when the maximum number of desired corners is the default setting of 200.

subplot(1,2,1);

imshow(I); hold on

plot(C(:,1), C(:,2), '.', 'Color', 'g') title('Maximum Corners = 200')

hold off

3Display the corners when the maximum number of desired corners is 3.

corners_max_specified = corner(I,3); subplot(1,2,2);

imshow(I); hold on

plot(corners_max_specified(:,1), corners_max_specified(:,2), ...

'.', 'Color', 'g') title('Maximum Corners = 3') hold off

11-14

Соседние файлы в папке 2read