HAUSDORFFDISTANCE Hausdorff distance between two point sets. HD = hausdorffDistance(PTS1, PTS2) Computes the Hausdorff distance between the two point sets PTS1 and PTS2. The Hausdorf distance can be used to compare two shapes. The distance between a point x and a set Y is given by: d(x, Y) = inf { d(x,y) | y in Y } The distance between two non empty sets X and Y is given by: d(X, Y) = sup { d(x,Y) | x in X } The Hausdorff distance between sets X and Y distance is defined as the maximum of d(X,Y) and d(Y,X): HD(X,Y) = max { d(X,Y), d(Y,X) } Example % Compute Hausdorff distance between an ellipse and a rectangle % first define two shapes rect = resamplePolygon(orientedBoxToPolygon([20 30 80 40 30]), 60); poly = ellipseToPolygon([20 30 40 20 30], 500); % display the shapes figure; hold on drawPolygon(poly, 'b'); drawPolygon(rect, 'g'); axis equal; % compute hausdorff distance [hd ind1 ind2] = hausdorffDistance(poly, rect); p1h = poly(ind1, :); p2h = rect(ind2, :); drawPoint([p1h;p2h], 'mo'); drawEdge([p1h p2h], 'm') See also points2d, minDistancePoints References http://en.wikipedia.org/wiki/Hausdorff_distance
Package: matgeom