hi, please I'm doing my project about image processing and I want to calculate the distance between the query image and the images in the base, I try this code but it didn't work, I appreciate any help

2 次查看(过去 30 天)
r1=a(:,:,1);
v1=a(:,:,2);
b1=a(:,:,3);
couleur1=(r1+v1+b1)/3;
i1 = rgb2gray(a);
t1=glcm(i1);
I1=invmoments(a);
X1={(couleur1),(t1),(I1)};
j=1;
projectdir = 'index\fusion';
list = dir(projectdir);
list([list.isdir]) = [];
filenames = natsort( {list.name});
for K = 1 : length(filenames)
ch = filenames{K};
nomImage = fullfile(projectdir, ch);
storedStructure = load (nomImage);
data{K} = storedStructure.X;
valeur = isequal(data{K},X1); end

回答(1 个)

Walter Roberson
Walter Roberson 2016-4-10
You measured some things producing couler1, t1, and I1, but you do not appear to have defined any way of calculating a "distance" between these and equivalent stored values for any particular image.
Even if you are thinking of "Euclidean distance" you need to consider: are these values even on the same scale? If there is a contribution to the distance of 10 units from the colour portion, should that count the same as a distance of 10 units from the glcm portion?
If you took the RGB image and added 1 to every pixel component, resulting in a coleur1 array that was 1 higher at each location, the total difference over an M x N array would be (M * N), but the glcm might be exactly the same and the image moments might be exactly the same, contributing 0 from each. On the other hand, you could take a subsection of the original image and change it notably, such that the total change in colour was less than M*N but the glcm and image moments are fairly different: do you really want minor changes in colour to outweigh the other two components just because the image has so many more locations to contribute from than the glcm or image moments do?
  12 个评论

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by