Hi,I'm doing my project about image processing, using the co-occurrence matrix but I don't know the algorithm of the co-occurrence(glcm) matrix can any one help me to get this algorithm and to get results like this. thank you a lot

Respuestas (2)

It basically tells you how often each gray level occurs next to each of the other gray levels.

8 comentarios

I use this function to calculate the glcm of each image but I don't get good result
function [t]= glcm(I)
glcmm = graycomatrix(I,'Offset',[0 1, -1 1, -1 0, -1 -1]);
stats = graycoprops(glcmm,{'contrast','homogeneity','Correlation','Energy'})
t = struct2array(stats);
If you are getting an error message, you need to post it.
If the values are not useful for your purpose, then it could be that you need to pass different Offset or different options.
No I don't get any error message but when I calculate the distance between the query image and the other images I get the same result for each query image. I use this formula to calculate the distance:
valeur=sqrt(abs(m1(1)-data{K}(1))+abs(m1(2)-data{K}(2))+abs(m1(3)-data{K}(3))+abs(m1(4)-data{K}(4)));
It is not obvious that that calculation has anything to do with glcm .
What is class(m1), class(data{K}) ?
this is my code
I = rgb2gray(a);
t1=glcm(I);
j=1;
projectdir = 'img\texture';
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.t;
valeur=sqrt(abs(m1(1)-data{K}(1))+abs(m1(2)-data{K}(2))+abs(m1(3)-data{K}(3))+abs(m1(4)-data{K}(4)));
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('image\',num2str(indice(k)),'.jpg');
I=imread(nomImage);
axes(handles.(sprintf('axes%d', n)));
n=n+1;
imshow(I);
end
end
You do not show any definition for m1, but whatever it is, it is not changing with the results of glcm .
We cannot tell from your code what class(m1) or class(storedStructure.t) are.
I'm sorry it's not this formula, this is mine :
valeur=sum(abs((data{K})- t1));
(storedStructure.t): it's the composite where we find the glcm of the images of the data base
for k=0:999
a=imread(sprintf('image\\%d.jpg',k));
I1 = rgb2gray(a);
t=glcm(I1);
save(sprintf('img\\texture\\%d.mat',k),'t');
end

Iniciar sesión para comentar.

Categorías

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

Preguntada:

el 26 de Abr. de 2016

Editada:

el 28 de Abr. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by