필터 지우기
필터 지우기

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
Walter Roberson
Walter Roberson 2016년 4월 17일
dist(K) = sqrt( sum( cellfun(@(Data, x1) sum((double(Data{1}(:)) - double(x1(:))).^2), data{K}, X1) ) );

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by