KostasRim
KostasRim

Reputation: 2053

Matlab pixel and histogram distance

are there any matlab functions that perform the following : enter image description here

NxM are the dimensions of the image. I,j are the pixel value(Red for chanel 1, Green for chanel 2, Blue for chanel 3).

Upvotes: 0

Views: 95

Answers (1)

hbaderts
hbaderts

Reputation: 14316

You can calculate the first distance by

d1 = sqrt(sum((A(:)-B(:)).^2));

and the second by

% Create histograms
hA = hist(A(:),255);
hB = hist(B(:),255);

% Calculate distance
d2 = sqrt(sum((hA-hB).^2));

Upvotes: 1

Related Questions