Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
hausdorff distance

Subject: hausdorff distance

From: DHIKRA

Date: 11 Dec, 2012 14:31:08

Message: 1 of 3

hello,
i have a problem with the code of Hassan RADVAR-ESFAHLAN; Université du Québec; ÉTS; Montréal; CANADA "hausdorff distance" , i d'ont interestand this part of code:
f
%% Compute distance
function[dist] = compute_dist(A, B)
m = size(A, 1);
n = size(B, 1);
dim= size(A, 2);
for k = 1:m
    C = ones(n, 1) * A(k, :);
    D = (C-B) * (C-B);
    
    D = sqrt(D * ones(dim,1));
    dist(k) = min(D);

end
 WHAT MEAN OF (C-B),c is a vector of a ligne and B???
could you please help me to explain this part of code

Subject: hausdorff distance

From: Roger Stafford

Date: 12 Dec, 2012 02:22:16

Message: 2 of 3

"DHIKRA " <hamdi.dhikra5@gmail.com> wrote in message <ka7g3c$dna$1@newscl01ah.mathworks.com>...
> hello,
> i have a problem with the code of Hassan RADVAR-ESFAHLAN; Université du Québec; ÉTS; Montréal; CANADA "hausdorff distance" , i d'ont interestand this part of code:
> f
> %% Compute distance
> function[dist] = compute_dist(A, B)
> m = size(A, 1);
> n = size(B, 1);
> dim= size(A, 2);
> for k = 1:m
> C = ones(n, 1) * A(k, :);
> D = (C-B) * (C-B);
> D = sqrt(D * ones(dim,1));
> dist(k) = min(D);
> end
> WHAT MEAN OF (C-B),c is a vector of a ligne and B???
> could you please help me to explain this part of code
- - - - - - - - -
  I believe the assumption here is that A and B are matrices with equal numbers of columns, namely, 'dim'. Also I strongly suspect the line

 D = (C-B) * (C-B);

is meant to be

 D = (C-B) .* (C-B);

Otherwise, unless n = dim, C-B will not be a square matrix and the matrix product would fail. Also a matrix product here would make no sense.

  With this understanding, the for-loop calculates the square roots of the row-sums of the squares of the differences between the k-th row of A and each of the rows of B. The quantity dist(k) is then set to the minimum of these square roots. (I think this code could be improved upon.)

  This isn't the Hausdorff distance yet. The maximum of dist(:) over all rows of B will have to be calculated. Then A and B must be interchanged and the whole process repeated. Finally the largest of these two results will be the Hausdorff distance, based on the Euclidean metric distance between the rows of A and B.

  (Note that taking the square root could just as well be postponed until the very last step where only one would need to be performed.)

Roger Stafford

Subject: hausdorff distance

From: DHIKRA

Date: 12 Dec, 2012 07:57:08

Message: 3 of 3

"Roger Stafford" wrote in message <ka8poo$i9t$1@newscl01ah.mathworks.com>...
> "DHIKRA " <hamdi.dhikra5@gmail.com> wrote in message <ka7g3c$dna$1@newscl01ah.mathworks.com>...
> > hello,
> > i have a problem with the code of Hassan RADVAR-ESFAHLAN; Université du Québec; ÉTS; Montréal; CANADA "hausdorff distance" , i d'ont interestand this part of code:
> > f
> > %% Compute distance
> > function[dist] = compute_dist(A, B)
> > m = size(A, 1);
> > n = size(B, 1);
> > dim= size(A, 2);
> > for k = 1:m
> > C = ones(n, 1) * A(k, :);
> > D = (C-B) * (C-B);
> > D = sqrt(D * ones(dim,1));
> > dist(k) = min(D);
> > end
> > WHAT MEAN OF (C-B),c is a vector of a ligne and B???

> > could you please help me to explain this part of code
> - - - - - - - - -
> I believe the assumption here is that A and B are matrices with equal numbers of columns, namely, 'dim'. Also I strongly suspect the line
>
> D = (C-B) * (C-B);
>
> is meant to be
>
> D = (C-B) .* (C-B);
>
> Otherwise, unless n = dim, C-B will not be a square matrix and the matrix product would fail. Also a matrix product here would make no sense.
>
> With this understanding, the for-loop calculates the square roots of the row-sums of the squares of the differences between the k-th row of A and each of the rows of B. The quantity dist(k) is then set to the minimum of these square roots. (I think this code could be improved upon.)
>
> This isn't the Hausdorff distance yet. The maximum of dist(:) over all rows of B will have to be calculated. Then A and B must be interchanged and the whole process repeated. Finally the largest of these two results will be the Hausdorff distance, based on the Euclidean metric distance between the rows of A and B.
>
> (Note that taking the square root could just as well be postponed until the very last step where only one would need to be performed.)
>
> Roger Stafford

thanks a lot mr Roger , I'am grateful for your help

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us