Image similarity by Euclidean distance in hsv color space in MATLAB -


the code included below calculates euclidean distance between 2 images in hsv color space , if result under threshold (here set 0.5) 2 images similar , group them in 1 cluster.

this done group of images (video frames actually).

it worked on group of sample images when change sample starts work odd, e.g result low 2 different images , high (like 1.2) 2 similar images.

for example result these 2 similar images relatively high: first pic , second pic when should under 0.5.

what wrong?

in code below, f divided 100 allow comparison values near 0.5.

im1 = imread('1.jpeg'); im2 = imread('2.jpeg'); hsv = rgb2hsv(im1); hn1 = hsv(:,:,1); hn1=hist(hn1,16); hn1=norm(hn1); hsv = rgb2hsv(im2); hn2 = hsv(:,:,1); hn2=hist(hn2,16); hn2=norm(hn2); f = norm(hn1-hn2,1) f=f/100 

these 2 lines:

hn1=hist(hn1,16); hn1=norm(hn1); 

convert 2d image scalar. suspect not you're interested in doing.....

edit:

probably better approach be:

hn1 = hist(hn1(:),16) / numel(hn1(:)); 

but, haven't given on math, guess.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -