understanding the Earth Mover’s Distance (EMD) from the MATLAB

$\begingroup$

I found difficulty in understanding the Earth Mover’s Distance (EMD) from the MATLAB implementation. The method is actually implemented in this paper. Anyone help me to where EMD is implemented in this code.

cyclic_dist_matrix=zeros(256,256);
for ix=0:255 ix_bin_vec = [0,de2bi(ix,8)]; for jx=0:255 jx_bin_vec = [0,de2bi(jx,8)]; dist1=pdist2(ix_bin_vec,jx_bin_vec,'emd'); dist2=pdist2(wrev(ix_bin_vec),jx_bin_vec,'emd'); dist3=pdist2(ix_bin_vec,wrev(jx_bin_vec),'emd'); cyclic_dist_matrix(ix+1,jx+1) = min([dist1,dist2,dist3]); end
end
%mds
Y=mdscale(cyclic_dist_matrix,3);
Y2=Y + abs(min(Y(:)));
Y2 = Y2 * (255/max(Y2(:)));
cyclic_map=uint8(Y2);
$\endgroup$ 1

1 Answer

$\begingroup$
dist1=pdist2(ix_bin_vec,jx_bin_vec,'emd');

The MATLAB function pdist2(X,Y, metric) calculates the distance between vectors X and Y using the metric in the third argument. Specifying 'emd' as the metric tells MATLAB to use the earth movers distance metric.

$\endgroup$ 2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like