File Exchange

image thumbnail

GLCM texture features

version 1.2 (6.14 KB) by

Calculates texture features from the input GLCMs

104 Downloads

Updated

View License

The GLCMs are stored in a i x j x n matrix, where n is the number of GLCMs calculated usually due to the different orientation and displacements used in the algorithm. Usually the values i and j are equal to 'NumLevels' parameter of the GLCM computing function graycomatrix(). Note that matlab quantization values belong to the set {1,..., NumLevels} and not from {0,...,(NumLevels-1)} as provided in some references
http://www.mathworks.com/help/images/ref/graycomatrix.html

Although there is a function graycoprops() in Matlab Image Processing Toolbox that computes four parameters Contrast, Correlation, Energy, and Homogeneity. The paper by Haralick suggests a few more parameters that are also computed here. The code is not vectorized and hence is not an efficient implementation but it is easy to add new features based on the GLCM using this code. The code takes care of 3 dimensional glcms (multiple glcms in a single 3D array)

If you find that the values obtained are different from what you expect or if you think there is a different formula that needs to be used from the ones used in this code please let me know. A few questions which I have are listed in the link http://www.mathworks.com/matlabcentral/newsreader/view_thread/239608

I plan to submit a vectorized version of the code later and provide updates based on replies to the above link and this initial code.

% Features computed
% Autocorrelation: [2] (out.autoc)
% Contrast: matlab/[1,2] (out.contr)
% Correlation: matlab (out.corrm)
% Correlation: [1,2] (out.corrp)
% Cluster Prominence: [2] (out.cprom)
% Cluster Shade: [2] (out.cshad)
% Dissimilarity: [2] (out.dissi)
% Energy: matlab / [1,2] (out.energ)
% Entropy: [2] (out.entro)
% Homogeneity: matlab (out.homom)
% Homogeneity: [2] (out.homop)
% Maximum probability: [2] (out.maxpr)
% Sum of sqaures: Variance [1] (out.sosvh)
% Sum average [1] (out.savgh)
% Sum variance [1] (out.svarh)
% Sum entropy [1] (out.senth)
% Difference variance [1] (out.dvarh)
% Difference entropy [1] (out.denth)
% Information measure of correlation1 [1] (out.inf1h)
% Informaiton measure of correlation2 [1] (out.inf2h)
% Inverse difference (INV) is homom [3] (out.homom)
% Inverse difference normalized (INN) [3] (out.indnc)
% Inverse difference moment normalized [3](out.idmnc)

Haralick uses 'Symmetric' = true in computing the glcm. There is no Symmetric flag in the Matlab version I use hence I add the diagonally opposite pairs to obtain the Haralick glcm. Here it is assumed that the diagonally opposite orientations are paired one after the other in the matrix. If the above assumption is true with respect to the input glcm then setting the flag 'pairs' to 1 will compute the final glcms that would result by setting 'Symmetric' to true. If your glcm is computed using the
Matlab version with 'Symmetric' flag you can set the flag 'pairs' to 0

% References:
1. R. M. Haralick, K. Shanmugam, and I. Dinstein, Textural Features of Image Classification, IEEE Transactions on Systems, Man and Cybernetics, vol. SMC-3, no. 6, Nov. 1973
2. L. Soh and C. Tsatsoulis, Texture Analysis of SAR Sea Ice Imagery Using Gray Level Co-Occurrence Matrices, IEEE Transactions on Geoscience and Remote Sensing, vol. 37, no. 2, March 1999.
3. D A. Clausi, An analysis of co-occurrence texture statistics as a
function of grey level quantization, Can. J. Remote Sensing, vol. 28, no.1, pp. 45-62, 2002
4. http://murphylab.web.cmu.edu/publications/boland/boland_node26.html

% Example:
% Usage is similar to graycoprops() but needs extra parameter 'pairs' apart from the GLCM as input

>I = imread('circuit.tif');
>GLCM2 = graycomatrix(I,'Offset',[2 0;0 2]);
>stats = GLCM_features1(GLCM2,0)

The output is a structure containing all the features calculated from the different GLCMs

Comments and Ratings (62)

Zhengxiong Li

Please see the note in the file. All problems are mentioned. This file is excellent!

All those who are getting error as
"Error using GLCM_Features1 (line 118)
Too many or too few input arguments. Enter GLCM and pairs." should know first that the code they are trying to compile is a function, and you cant directly run the function!!
So create a new .m script and paste there the following code

I = imread('circuit.tif');
GLCM2 = graycomatrix(I,'Offset',[2 0;0 2]);
stats = GLCM_Features1(GLCM2,0)
and now run this .m file!

I hope this will help.

sairam ,
how to use this GLCM to feature extraction for thyroid image segmentation

elnaz morsali

elnaz morsali

haizhou CHEN

Elena Syerko

Dear Pasco.M
you can call GLCM_Features1 as follows:

[out] = GLCM_Features1(glcms,0);

where glcms are your input GLCMs.

Elena Syerko

Pasco.M

Hi Avinash,
I am working on a project called Image segmentation based on GLCM feature extraction.I am trying to use your code but I am getting this error:

Error using GLCM_Features1 (line 118)
Too many or too few input arguments. Enter GLCM and pairs.
any help ?? thanks

I am doing the research in MRI of brain for my MPhil. now I am using your GLCM_Features1 program for feature extraction, but can i interpret this output and i want to explain the GLCM feature.

stats =

autoc: [1.165526107594937e+001 1.154640031645569e+001]
contr: [8.202531645569622e-001 1.037974683544304e+000]
corrm: [9.136488034270794e-001 8.907284240898227e-001]
corrp: [9.136488034270794e-001 8.907284240898220e-001]
cprom: [6.642504585882369e+002 6.484053189098217e+002]
cshad: [5.851533547001618e+001 5.679582858009466e+001]
dissi: [4.155854430379747e-001 4.685917721518988e-001]
energ: [2.877546635905705e-001 2.843150605622098e-001]
entro: [2.226000754165028e+000 2.270755430632310e+000]
homom: [8.412377561784208e-001 8.310039462778784e-001]
homop: [8.293495939521626e-001 8.169324281753542e-001]
maxpr: [5.221518987341772e-001 5.195411392405064e-001]
sosvh: [1.198110722409019e+001 1.198110722409019e+001]
savgh: [5.409572784810127e+000 5.409572784810127e+000]
svarh: [3.094677463064912e+001 3.066551796736417e+001]
senth: [1.836205342683152e+000 1.845106522919650e+000]
dvarh: [8.202531645569621e-001 1.037974683544304e+000]
denth: [8.547072027811411e-001 9.120604800108463e-001]
inf1h: [-4.611449884217926e-001 -4.302056645943528e-001]
inf2h: [8.582600442898297e-001 8.437695980561157e-001]
indnc: [9.577971097116664e-001 9.534116516394999e-001]
idmnc: [9.886556165453816e-001 9.859930291854271e-001]

psychotic

Hello same error
Error using GLCM_Features1 (line 118)
Too many or too few input arguments. Enter GLCM and pairs.

hello avinash
why i am getting this error.

Error using GLCM_Features1 (line 118)
Too many or too few input arguments. Enter GLCM and pairs.

How can I compute GLCM on selected regions inside whole image?

mesa

mesa (view profile)

it didn't work and locked on mu 512X512X617 grayscale data. I wish I could find the problem and use your code?!

what is the meaning of out.someattribute(k)

Durga

Durga (view profile)

Thank u for the code,but it is giving me this error which is persisting although i have suppilied the limit within its recursionlimit :
"Error using validatestring (line 61) Maximum recursion limit of 500 reached.Be aware that exceeding your available stack space can crash MATLAB and/or your computer."

lotus whit

I am using GLCM features in image processing application,
would you please to ask you if there is ability to convert to VHDL and how to write test script for it.

ali Hasan

Thank you for this codes but I have a question about Inverse Difference Normalized and Inverse Difference Moment Normalized, could someone tell me in which reference are mentioned these two equations?

Shaila parvin

This code shows me the error:

>> GLCM_Features1
Error using GLCM_Features1 (line 118)
Too many or too few input arguments. Enter
GLCM and pairs.

>>

How to solve it?

I like it.

subbmdee

Hi,
I am trying to extract these features for different region of interests(ROIs) of size 32x32 from different images, but I am getting same(wrong) value for particular feature. If I extract these features for the whole image, then the values are different(right) for different images.
Please help
thanks

jenifer

please send me the matlab codes for glcm

Karthik

@avinash & @ will,
Hi,

I used your code and got set of Features.
But the thing is I have applied for a lung image which contains nodules.
So when i execute this program and get result i want to know whether this output is for a NODULE which i want....
(i.e)Instead of applying for an entire image, i want it for a PARTICULAR PART OF AN IMAGE WHICH I WANT..
Hope i ve made my point clear.
So any suggestions or ideas would be of great help.

Thank you,
karthik.

Karthik

Hi Avinash,

Actually am working in lung nodule detection.
I ve to extract the GLCM features of the lung nodule.
So how to apply your code for my nodule in a image. What input should i give.
How should i give input for your code & do i need to change anything if i need to apply it for a image.

Thank you,
karthik.

Preeti

Preeti (view profile)

i am not able to send the computed GLCM to this vectorised version by Will , it is not accepting the double input. Please help!

jassu kumar

plz give me code 4 feature extracion of glcm

Hi Stephanie,

The number of sets of outputs will depend on the number of GLCMs input into the function for both graycoprops() and GLCM_features().

In using GLCM_features() please note the function of the 'pairs' flag as explained in the intro. Also make sure how your version of graycomatrix() works with regards to the 'Symmetric' flag.

"Haralick uses 'Symmetric' = true in computing the glcm. There is no Symmetric flag in the Matlab version I use hence I add the diagonally opposite pairs to obtain the Haralick glcm. Here it is assumed that the diagonally opposite orientations are paired one after the other in the matrix. If the above assumption is true with respect to the input glcm then setting the flag 'pairs' to 1 will compute the final glcms that would result by setting 'Symmetric' to true. If your glcm is computed using the
Matlab version with 'Symmetric' flag you can set the flag 'pairs' to 0".

Please do get back if there is still an issue.

Thanks

Stephanie

Hi,

I'm a little confused as to why the output text has 2 numbers per function when applied to a single image. I read through the intro but missed it. When I do just graycoprops(), the outputs are single numbers. Could you explain why there are two number for each output and why they vary from each other? Thanks!

erma emira

hi,
i want to use glcm for crown segmentation but i got this error. n i'm very new to matlab and programmg.can anyone help?

??? Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
to change the limit.

need a lot of guidance.

Hi Ujwala,

"I am working on MRI of brain for my Ph.D. now I am using your GLCM_Features4 program for feature extraction, but I can not understant this GLCM_Features4 program calculate 22 feature or 44 feature."

The output is a structure called 'out' which has 22 features for each of the GLCMs that are input. The function takes multiple GLCMs as input. Please go through the description for the program and let me know if further explanation is needed.

"when I was passing MRI img to this it will give 2 values that belong to 22 feature or 44. like contrast = 22.22 33.33. tell me this is 2 diff feature or same only for contrast."

Please note that the function does NOT take images as input rather it takes GLCMS ( calculated using a function like graycomatrix() ) as input. And depending on the number of GLCMs there are so main sets of 22 features. So for n GLCMs you will have n sets of 22 features as output.

Hope that helps.

Hi Gomathi,

"to this GLCM program, I gave the tumor segmented image as input. Was I correct?"

Please make sure that you are giving the GLCM(s) as input to the GLCM_Features function. ( You can use help graycomatrix to know more on how to input your image into this matlab function ).

Please go through the initial description on this page and in the code and if there is still a problem please do get back.

Thanks!

Gomathi C

Hi Avinash
I'm doing a project in liver tumor classification. I used your program and it gave some output. I don't know whether I'm correct. Actually I initially used Region Growing method for liver segmentation and from that I segmented tumor using FCM. So, to this GLCM program, I gave the tumor segmented image as input. Was I correct? If so, I think, then, my output will also be correct. I gave the parameters exactly as in your example. Actually what do they mean? Do I need to change them for different images? If so, how to give the parameters? I'm completely new to this. So, kindly guide me.

I got this output. Am I correct?

stats =

autoc: [1.857855266614132e+000 1.857955341199538e+000]
contr: [5.103143332457753e-002 5.030548650257343e-002]
corrm: [9.512661919561399e-001 9.519459060378332e-001]
corrp: [9.512661919561385e-001 9.519459060378338e-001]
cprom: [7.885631654779597e+001 7.905268525471267e+001]
cshad: [1.219440700252286e+001 1.220659371449108e+001]
dissi: [2.037387269065756e-002 1.935418927908687e-002]
energ: [8.987753042491253e-001 8.988459843719526e-001]
entro: [2.759187341212805e-001 2.743152140681436e-001]
homom: [9.930016927881388e-001 9.935307908219834e-001]
homop: [9.925660617240367e-001 9.930960070222014e-001]
maxpr: [9.474275457490587e-001 9.474466930429607e-001]
sosvh: [1.847174384255155e+000 1.846913030238459e+000]
savgh: [2.332207337361002e+000 2.332108469591401e+000]
svarh: [6.311174784234007e+000 6.314794324825067e+000]
senth: [2.663144677055123e-001 2.653725436772341e-001]
dvarh: [5.103143332457753e-002 5.030548650257344e-002]
denth: [7.573115918713391e-002 7.073380266499811e-002]
inf1h: [-8.199645492654247e-001 -8.265514568489666e-001]
inf2h: [5.643539051044213e-001 5.661543271625117e-001]
indnc: [9.980238521073823e-001 9.981394883569174e-001]
idmnc: [9.993275086521848e-001 9.993404634013308e-001]

Awaiting your reply.

thanks....

giet

giet (view profile)

ram m

ram m (view profile)

Hi all

Can you explain the physical interpretation of the Inverse difference moment , Information measures of correlation , cluster prominence and shade in a image.
I was trying to get the physical meaning of them , but could not find properly.

Thanks

Will, Thanks for the update.

Will

Will (view profile)

function [out] = cad_glcm_features(glcm)

% VECTORIZED CODE: FASTER

size_glcm_1 = size(glcm,1);
size_glcm_2 = size(glcm,2);
size_glcm_3 = size(glcm,3);

% checked
out.autoc = zeros(1,size_glcm_3); % Autocorrelation: [2]
out.contr = zeros(1,size_glcm_3); % Contrast: matlab/[1,2]
out.corrm = zeros(1,size_glcm_3); % Correlation: matlab
out.corrp = zeros(1,size_glcm_3); % Correlation: [1,2]
out.cprom = zeros(1,size_glcm_3); % Cluster Prominence: [2]
out.cshad = zeros(1,size_glcm_3); % Cluster Shade: [2]
out.dissi = zeros(1,size_glcm_3); % Dissimilarity: [2]
out.energ = zeros(1,size_glcm_3); % Energy: matlab / [1,2]
out.entro = zeros(1,size_glcm_3); % Entropy: [2]
out.homom = zeros(1,size_glcm_3); % Homogeneity: matlab
out.homop = zeros(1,size_glcm_3); % Homogeneity: [2]
out.maxpr = zeros(1,size_glcm_3); % Maximum probability: [2]
out.sosvh = zeros(1,size_glcm_3); % Sum of sqaures: Variance [1]
out.savgh = zeros(1,size_glcm_3); % Sum average [1]
out.svarh = zeros(1,size_glcm_3); % Sum variance [1]
out.senth = zeros(1,size_glcm_3); % Sum entropy [1]
out.dvarh = zeros(1,size_glcm_3); % Difference variance [4]
out.denth = zeros(1,size_glcm_3); % Difference entropy [1]
out.inf1h = zeros(1,size_glcm_3); % Information measure of correlation1 [1]
out.inf2h = zeros(1,size_glcm_3); % Informaiton measure of correlation2 [1]
out.indnc = zeros(1,size_glcm_3); % Inverse difference normalized (INN) [3]
out.idmnc = zeros(1,size_glcm_3); % Inverse difference moment normalized [3]

% Indices
[i,j] = meshgrid(1:size_glcm_1,1:size_glcm_2);
idx1 = (i+j)-1;
idx2 = abs(i-j)+1;
ii = (1:(2*size_glcm_1-1))';
jj = (0:size_glcm_1-1)';

for k = 1:size_glcm_3 % number glcms
% Normalize GLCM
glcm_sum = sum(sum(glcm(:,:,k)));
Pij = glcm(:,:,k)./glcm_sum; % Normalize each glcm
glcm_mean = mean(Pij(:)); % compute mean after norm
%
p_x = squeeze(sum(Pij,2));
p_y = squeeze(sum(Pij,1))';
%
u_x = sum(sum(i.*Pij));
u_y = sum(sum(j.*Pij));
%
p_xplusy = zeros((2*size_glcm_1 - 1),1); %[1]
p_xminusy = zeros((size_glcm_1),1); %[1]
for aux = 1:max(idx1(:))
p_xplusy(aux) = sum(Pij(idx1==aux));
end
for aux = 1:max(idx2(:))
p_xminusy(aux) = sum(Pij(idx2==aux));
end

% Contrast
out.contr(k) = sum(sum((abs(i-j).^2).*Pij));
% Dissimilarity
out.dissi(k) = sum(sum(abs(i-j).*Pij));
% Energy
out.energ(k) = sum(sum(Pij.^2));
% Entropy
out.entro(k) = -sum(sum(Pij.*log(Pij+eps)));
% Homogeneity Matlab
out.homom(k) = sum(sum(Pij./(1+abs(i-j))));
% Homogeneity Paper
out.homop(k) = sum(sum(Pij./(1+abs(i-j).^2)));
% Sum of squares: Variance
out.sosvh(k) = sum(sum(Pij.*((j-glcm_mean).^2)));
% Inverse difference normalized
out.indnc(k) = sum(sum(Pij./(1+(abs(i-j)./size_glcm_1))));
% Inverse difference moment normalized
out.idmnc(k) = sum(sum(Pij./(1+((i-j)./size_glcm_1).^2)));
% Maximum probability
out.maxpr(k) = max(Pij(:));
% Sum average
out.savgh(k) = sum((ii+1).*p_xplusy);
% Sum entropy
out.senth(k) = -sum(p_xplusy.*log(p_xplusy+eps));
% Sum variance
out.svarh(k) = sum((((ii+1) - out.senth(k)).^2).*p_xplusy);
% Difference entropy
out.denth(k) = -sum(p_xminusy.*log(p_xminusy+eps));
% Difference variance
out.dvarh(k) = sum((jj.^2).*p_xminusy);
% Computes correlation
hxy1 = -sum(sum(Pij.*log(p_x*p_y' + eps)));
hxy2 = -sum(sum((p_x*p_y').*log(p_x*p_y' + eps)));
hx = -sum(p_x.*log(p_x+eps));
hy = -sum(p_y.*log(p_y+eps));
hxy = out.entro(k);
% Information measure of correlation 1
out.inf1h(k) = (hxy-hxy1)/(max([hx,hy]));
% Information measure of correlation 2
out.inf2h(k) = (1-exp(-2*(hxy2-hxy)))^0.5;
% Cluster Prominence
out.cprom(k) = sum(sum(Pij.*((i+j-u_x-u_y).^4)));
% Cluster Shade
out.cshad(k) = sum(sum(Pij.*((i+j-u_x-u_y).^3)));
%
s_x = sum(sum(Pij.*((i-u_x).^2)))^0.5;
s_y = sum(sum(Pij.*((j-u_y).^2)))^0.5;
corp = sum(sum(Pij.*(i.*j)));
corm = sum(sum(Pij.*(i-u_x).*(j-u_y)));
% Autocorrelation
out.autoc(k) = corp;
% Correlation paper
out.corrp(k) = (corp-u_x*u_y)/(s_x*s_y);
% Correlation Matlab
out.corrm(k) = corm/(s_x*s_y);
end

leila

leila (view profile)

Thank you. I have not checked if the output values are correct, but I'm just going to go and plug it in my classifier.

I will have more comments for you when i'm done with my project.

Thanks again

adzlan

adzlan (view profile)

hi Avinash

im new in matlab. can you tell me how can i call only this 13 features from your code
• Angular Second Moment
• Contrast
• Correlation
• Variance
• Inverse Second Differential Moment
• Sum Average
• Sum Variance
• Sum Entropy
• Entropy
• Difference Variance
• Difference Entropy
• Measure of Correlation 1
• Measure of Correlation 2

thanks,
adzlan

Hi bala,

Please try to explain further. From what I understand it looks like you want to know how to generate the E I S H for each image in your database and use the same parameters of the input image to find the closest ( euclidean ) image to it in the database.

You can generate the GLCM for each image using the in built matlab function graycomatrix() and then pass the generated GLCM to the function you downloaded here GLCM_featuresX()

Hope that helps,
Avinash

Rym MDAINI

Hi Avinash
Good job ;)
Can you please help me, I'm trying to move a window, say 9X9 on a matrix, and create for every region (9X9) the glcm, and then move this 9X9 window until I reach the end of the matrix. How can I do that?

Rym MDAINI

bala k

bala k (view profile)

avinash uppuluri,

i'm doing image processing using GLCM function energy, contrast, entropy, inverse matrix, can you give how i generate for these function code.
my process is
query_image = imread('145.jpg');
grayimage = rgb2gray(query_image);
i need to calculate gray level co-occurrence matrix,
energy E,
entropy I,
contrast S,
inverse difference H,
F_query = [E I S H];

image database also used above process.

F_data = [E1 I1 S1 H1];

euclidean distance

d = norm(F_query - F_data);

i will get the best match images.

thanks,
bala

Kapil,

I would appreciate if you can leave a short comment on how you think this work can be improved so that I can make it more useful for yourself and others.

Thanks,
Avinash

Hi Kavitha,

Can you please provide more information on how you generate your GLCM matrix (if possible also provide the image used) so that I can reproduce the error on my end.

Thanks,
Avinash

Hi
I tried the above code and got an error stating "Function undefined for input of type double".
What type should i convert my GLCM matrix for this function to work ?
Thanks for the help.

Kavitha

Kavitha Ravi

Hi
I tried the above code and got an error stating "Function undefined for input of type double".
What type should i convert my GLCM matrix for this function to work ?
Thanks for the help.

Kavitha

kapil veera

There have been a few questions on how to compute features for each pixel in a image. The link below provides further explanation into such details. See "Creating a texture image"

http://www.fp.ucalgary.ca/mhallbey/texture_calculations.htm

Main points being:
+ Texture for a pixel needs the definition of a "window" around the pixel
+ Once such a window is defined; you can calculate the GLCM for each pixel (taking the respective window into consideration);
+ These GLCMs for each pixel should later be fed into the GLCM_features function to extract the feature vector for each pixel (and related window)
+ If needed, the values can later be put together to form a texture feature image

Hope this helps.

http://www.mathworks.com/matlabcentral/fileexchange/22354-glcmfeatures4-m-vectorized-version-of-glcmfeatures1-m-with-code-changes

The above link has a faster version of this code (named GLCM_features4.m). They should give the same outputs. Do let me know if you find any difference in the outputs.

Thanks,
Avinash

gasmi karim

I work on the MRI image but I do not know how I can use to calculate your classification is for the I told you that the feature is calculated for each pixel I await your response

gasmi karim

Please I want known is that in calculating the Haralick feature of such energy to the entire image or for each pixel because in your code I think you calculate for the whole image a single value for each feature so how it can be used for classification is for this I see the need to calculate for each pixel the feature

Preeti

Preeti (view profile)

Thanks for reply. Actually i am not able to load the data from mat file. can you please help me in using the data in .mat file? what is the code to import data from .mat file one by one , then only i can form GLCM for every dicom image. Please also tell that how to save these features in a database

Looking forward to your reply.

Hi Preeti,

Try something like this:
% Form GLCMs for each of the 354 images using the required offsets (and other parameters as required) using the MATLAB function graycomatrix()

e.g., GLCM2 = graycomatrix(Dicom_images(:,:,1),'Offset',[0 2]);

% Then compute the features for each GLCM/image. You can also have multiple GLCMs per image depending on the parameters you input to graycomatrix().

stats = GLCM_features1(GLCM2,0)

Hope this helps,
Avinash

Hi
I have read your code GLCM texture features. I have a mat file of size 512*512*354. in which 354 DICOM images are saved.
I want to use your code to extract texture features of all images in .mat file. please help.
Preeti

Jonathan,
You are right! Haralick coefficients can be computed on GLCMs calculated in different directions. The matlab function graycomatrix() gives option to change this direction as required. http://www.mathworks.com/access/helpdesk/help/toolbox/images/graycomatrix.html

A good read for this topic: Image Processing: Dealing with texture by Maria Petrou and Pedro Garcia Sevilla. Let me know if you need any specifics about changing the orientation. Thanks.

Good job ;)
It works perfectly well.
I am not an expert on Haralick coefficient but it can be done in different direction, am I right?
If it is right would be interesting to be able to set this parameter...

It looks like the version of Image Processing Toolbox of matlab that you are working with does not have graycomatrix().

You can write a function to compute the GLCM for a image using the details provided in http://www.mathworks.com/access/helpdesk/help/toolbox/images/graycomatrix.html and the references listed in the description.

matlab res

>> help graycomatrix()

graycomatrix().m not found.

I get this error . What should i do?

>I = imread('circuit.tif');
>GLCM2 = graycomatrix(I,'Offset',[2 0;0 2]);
>stats = GLCM_features1(GLCM2,0)

The above code should work fine if you have Matlab Image Processing Toolbox with the function graycomatrix() to compute the Gray Level Cooccurrence Matrix (GLCM). [ Try > help graycomatrix and see what if the function is present in your version]

If you are using any other method to compute the GLCM (e.g., a self written function) you can use GLCM_Features1() with the first input as the GLCM (i x j x n matrix) and a parameter pairs which I use to indicate if a symmetric GLCM needs to be computed from opposite direction pairs. Go through the comments in the code to understand better. Please let me know if you still have a problem.

For the error

"??? Error using ==> GLCM_Features1
Too many or too few input arguments. Enter GLCM and pairs."

Let me know what kind of input parameters you gave the function and I will try to help.

Thanks

matlab res

I get this error . What should be done ?
GLCM2 = graycomatrix(I,'Offset',[2 0;0 2]);
??? Undefined command/function 'graycomatrix'.

matlab res

I am new to this environment.I dont know what parameters should be given & how to give.
I get the following error.Give me the step wise details of how to arrive at the output.

??? Error using ==> GLCM_Features1
Too many or too few input arguments. Enter GLCM and pairs.

Updates

1.2

Change of formula for s_x and s_y to obtain correct value of 'Correlation'

1.1

Code change

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video