please I have a problem in this code i want to convert an image and to compare it with other images:
function Couleur_Callback(hObject, eventdata, handles)
global a;
disp (a);
I1=rgb2gray(a);
histo=imhist(I1);
r=dir('base');
[I c]=size(r);
j=1;
for i=3:1
ch1=r(i).name;
disp(ch1);
img=stract('base\',ch1);
disp(img);
imagetestt=imread(img);
imagetest2=rgb2gray( imagetestt);
imagetest=imhist(imagetest2);
valeur=intersectionhisto(histo,imagetest);
resulat(j)=valeur;
j=j+1;
end
resultatFinal=sort(resulat,'descend')
for i=1:j-1
X=find(resultatFinal(i)==resultat)
indice(i)=X(1);
end
for i=1:6
nomImage=stract('base\',num2str(indice(i)),'.jpg');
I=imread(nomImage);
subplot(6,1,i);
imshow(I);
end

2 comentarios

olfa abdalah
olfa abdalah el 4 de Feb. de 2016
this's my problem please I need a solution
Undefined function or variable "resulat".
Error in file>Couleur_Callback (line 112) resultatFinal=sort(resulat,'descend')

Iniciar sesión para comentar.

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 4 de Feb. de 2016

0 votos

olfa - look closely at your for loop
for i=3:1
Your indexing variable i begins at three and ends at one. I expect that the body of the for loop is not being executed because 3 is greater than the 1 and so resulat is not initialized. From for loop, for index=initVal:endVal — Increment the index variable from initVal to endVal by 1, and repeat execution of statements until index is greater than endVal. If you want your indexing variable to take on values of 3,2,1 then you need to use a negative step size as
for k=3:-1:1
Try the above and see what happens! Note that the above code is using k as an indexing variable since MATLAB uses i and j to represent the imaginary number. It is also good practice to initialize your variables before you begin to use them. In your case, you can initialize resulat as an array with three variables or just as an empty vector
resulat = []; % or
resulat = zeros(3,1);
for k=3:-1:1
% etc.
end

1 comentario

olfa abdalah
olfa abdalah el 5 de Feb. de 2016
can you give me an other code witch can compare a query image with other image in the base using according to the Grayscale because this does not work

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Feb. de 2016

Comentada:

el 5 de Feb. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by