mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 11:26:25 +02:00
[BV] Assignment2 3-5 finished
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
18
bv/hist_dist_Euclidean.m
Normal file
18
bv/hist_dist_Euclidean.m
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
function [ distance ] = hist_dist_Euclidean( h1, h2 )
|
||||||
|
%HIST_DIST_EUCLIDEAN Calculates euclidean distance between histograms
|
||||||
|
|
||||||
|
sum_of_differences = 0;
|
||||||
|
s = size(h1);
|
||||||
|
if s(1) > 1
|
||||||
|
n = s(1);
|
||||||
|
else
|
||||||
|
n = s(2);
|
||||||
|
end
|
||||||
|
for i = 1:n
|
||||||
|
sum_of_differences = sum_of_differences + (h1(i) - h2(i))^2;
|
||||||
|
end
|
||||||
|
|
||||||
|
distance = sqrt(sum_of_differences);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
14
bv/hist_dist_Manhattan.m
Normal file
14
bv/hist_dist_Manhattan.m
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
function [ distance ] = hist_dist_Manhattan( h1, h2 )
|
||||||
|
%HIST_DIST_MANHATTAN Calculates the Manhattan distance between 2 histograms
|
||||||
|
distance = 0;
|
||||||
|
s = size(h1);
|
||||||
|
if s(1) > 1
|
||||||
|
n = s(1);
|
||||||
|
else
|
||||||
|
n = s(2);
|
||||||
|
end
|
||||||
|
for i = 1:n
|
||||||
|
distance = distance + abs(h1(i) - h2(i));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
15
bv/hist_dist_intersection.m
Normal file
15
bv/hist_dist_intersection.m
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
function [ intersection ] = hist_dist_intersection( h1, h2 )
|
||||||
|
%HIST_DIST_INTERSECTION Calculates intersection between 2 histograms
|
||||||
|
|
||||||
|
intersection = 0;
|
||||||
|
s = size(h1);
|
||||||
|
if s(1) > 1
|
||||||
|
n = s(1);
|
||||||
|
else
|
||||||
|
n = s(2);
|
||||||
|
end
|
||||||
|
for i = 1:n
|
||||||
|
intersection = intersection + min(h1(i), h2(i));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Reference in New Issue
Block a user