@Shaan, One way would be to treat those images as vectors of pixels, and use the code on those vectors, however, many more nuanced implementations of HD for image comparison have been developed.
Comment only
06 Nov 2014
Hausdorff Distance
Calculates the Hausdorff Distance between two sets of points in a Euclidean metric space.
if the input data vector is a double vector, the following line will run error
X = imdilate(x,se);
how do i modify this function to the double vector case?
Comment only
16 May 2014
Hausdorff Distance
Calculates the Hausdorff Distance between two sets of points in a Euclidean metric space.
It is great code, but you need to fix your bugs: in order to achieve the same column for your both images, you can fix number of columns with the following codes:
nrows = max(size(I1,1), size(I2,1));
ncols = max(size(I1,2), size(I2,2));
nchannels = size(I1,3);
extendedI1 = [ I1, zeros(size(I1,1), ncols-size(I1,2), nchannels); ...
zeros(nrows-size(I1,1), ncols, nchannels)];
extendedI2 = [ I2, zeros(size(I2,1), ncols-size(I2,2), nchannels); ...
zeros(nrows-size(I2,1), ncols, nchannels)];
I1=extendedI1;
I2=extendedI2;
Also, Binary images don't give us the minimum numbers for Hausdorff Distance. I checked your codes with several binary images and all of the times the max Hausdorff Distance numbers were the correct answer, not the minimum number.
Comment only