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

10 Morphological Operations

Distance Transform

The distance transform provides a metric or measure of the separation of points in the image. The bwdist function calculates the distance between each pixel that is set to off (0) and the nearest nonzero pixel for binary images.

The bwdist function supports several distance metrics, listed in the following table.

Distance Metrics

 

Distance Metric

Description

Illustration

 

 

 

 

 

 

Euclidean

The Euclidean distance is the

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

straight-line distance between

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

 

0

 

1.41

1.0

1.41

 

 

 

 

two pixels.

 

 

 

 

 

 

 

 

 

0

 

1

 

0

 

1.0

0.0

1.0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

 

0

 

1.41

1.0

1.41

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Distance Transform

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

City Block

The city block distance metric

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

measures the path between the

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

 

 

0

 

2

1

2

 

 

 

 

pixels based on a 4-connected

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

neighborhood. Pixels whose

 

0

 

1

 

0

 

1

0

1

 

 

 

 

 

 

 

 

 

 

 

 

edges touch are 1 unit apart;

 

0

 

0

 

0

 

2

1

2

 

 

 

 

pixels diagonally touching are

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Distance Transform

 

 

 

2 units apart.

 

 

 

 

 

 

 

 

 

 

 

 

 

10-36

Distance Transform

Distance Metrics (Continued)

 

Distance Metric

Description

Illustration

 

 

 

 

 

 

 

 

 

 

 

 

Chessboard

The chessboard distance metric

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

measures the path between the

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

0

 

 

 

1

1

1

 

 

 

 

 

 

 

 

pixels based on an 8-connected

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

neighborhood. Pixels whose

 

0

 

1

0

 

 

 

1

0

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

edges or corners touch are 1

 

0

 

0

0

 

 

 

1

1

1

 

 

 

 

 

 

 

 

unit apart.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Distance Transform

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Quasi-Euclidean

The quasi-Euclidean metric

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

0

 

0

0

 

2.8

2.4

2.0

 

2.4

2.8

 

 

 

 

measures the total Euclidean

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

distance along a set of

 

0

 

0

0

 

0

0

 

2.4

1.4

1.0

 

1.4

2.4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

horizontal, vertical, and

 

0

 

0

1

 

0

0

 

2.0

1.0

0

 

1.0

2.0

 

 

 

 

diagonal line segments.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

0

 

0

0

 

2.4

1.4

1.0

 

1.4

2.4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

0

 

0

0

 

2.8

2.4

2.0

 

2.4

2.8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Image

 

 

 

 

 

 

Distance Transform

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This example creates a binary image containing two intersecting circular objects.

center1 = -10; center2 = -center1;

dist = sqrt(2*(2*center1)^2); radius = dist/2 * 1.4;

lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)]; [x,y] = meshgrid(lims(1):lims(2));

bw1 = sqrt((x-center1).^2 + (y-center1).^2) <= radius; bw2 = sqrt((x-center2).^2 + (y-center2).^2) <= radius; bw = bw1 | bw2;

figure, imshow(bw), title('bw')

10-37

10 Morphological Operations

To compute the distance transform of the complement of the binary image, use the bwdist function. In the image of the distance transform, note how the centers of the two circular areas are white.

D = bwdist(~bw);

figure, imshow(D,[]), title('Distance transform of ~bw')

10-38

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