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

olfa abdalah
olfa abdalah 2016년 2월 4일
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')

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

 채택된 답변

Geoff Hayes
Geoff Hayes 2016년 2월 4일

0 개 추천

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

olfa abdalah
olfa abdalah 2016년 2월 5일
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

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2016년 2월 4일

댓글:

2016년 2월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by