Hi, anyone can help me, I have 200 images and I calculate for each image the GLCM and I save it in a *.mat files then I recuperate the data from the file to calculate the distance between the img query and display the 12 most similar img

1 view (last 30 days)
resulat=[];
disp (a);
I = rgb2gray(a);
t=glcm(I);
j=1;
list = dir('index\indexation texture\.mat');
for i = 1:length(list)
data =eval(['load ' list(i).name ' -ascii']);
valeur=(t-data)/t;
resulat(j)=valeur;
j=j+1;
end
resultatFinal=sort(resulat,'descend')
for k=1:j-1
X=find(resultatFinal(k)==resulat);
indice(k)=X(1);
end
n=2;
for k=1:12
nomImage=strcat('base\',list(i).name,'.jpg');
I=imread(nomImage);
axes(handles.(sprintf('axes%d', n)));
n=n+1;
imshow(I);
end

Answers (1)

Image Analyst
Image Analyst on 30 Mar 2016
First of all, instead of useing the hated eval()L:
data =eval(['load ' list(i).name ' -ascii']);
you can do this
storedStructure = load (list(i).name, 'ascii'); % Get everything in the file.
data = storedStructure.data; % Convert structure member into array.
Secondly, it's hard to read your code because the indentation is messed up. in MATLAB, type control-a followed by control i, to fix the indenting. Then paste back here, highlight it, and finally click the {}Code button above the comment box.
You can also use find() to return 12 elements. Or you can just extract 12 elements from what sort() returned.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!