File Exchange

image thumbnail

Gray Level Run Length Matrix Toolbox

version 1.0 (9.55 KB) by

The toolbox provide useful functions for extract high order run length features



View License

This toolbox provides several state of the art high order run length matrix statistics for image analysis.

Currently supported features are:

1. 0,45,90,135 direction run-length matrix
2. Fully vectorized coding style
3. Inputs checking using MATLAB style
4. 11 various statistics include:Short Run Emphasis, Long Run Emphasis, Gray-Level Nonuniformity, Run Length Nonuniformity, Run Percentage, Low Gray-Level Run Emphasis, High Gray-Level Run Emphasis, Short Run Low Gray-Level Emphasis, Short Run High Gray-Level Emphasis,Long Run Low Gray-Level Emphasis ,Long Run High Gray-Level Emphasis.

Files include: grayrlmatrix, grayrlprops,and some utility functions

Importance Notice: You can freely use the source files for academic research purpose at your own risk.For commercial use, you should consult with the author for conditions.

If you use them for your academic research work,please kindly cite this toolbox as:
Xunkai Wei, Gray Level Run Length Matrix Toolbox v1.0,Software,Beijing Aeronautical Technology Research Center, 2007

Comments and Ratings (23)


Thanks for sharing your code.
I think you should modify line 72 in the function grayrlprops.m as follows in order to proceed the calculation for 1 GLRL matrix.
tGLRLM = cell2mat(GLRLM);
In addition, it would be much helpful to output the features' names with the values in a structure.
Thanks again!!

Neha Baraiya

This function generates 4 different cells, but it can not be understood how to use them for pattern classification.


Thanks for sharing your code. I want to use this code to add check texture result of dicom image but I don't know how to use it. Could you please help me?

Geng Wei Syu

Thanks for share,I run this code and the answer not meet the cited paper.

When I change the code where the grayrlprops.
m it will meet the paper.

%p_g = sum(tGLRLM);
->p_g = sum(tGLRLM,2)';

%p_r = sum(tGLRLM,2)';
->p_r = sum(tGLRLM);

Thank you for your helpful code. how can i generalize your code for compute RLM for 3D image in 13 direction base on papar in this link:""


thomas (view profile)

few changes todo in the inputparser, if you have only one parameter it should be included in a cell to success at the parser, but in the main function you treat a single parameter as a matrix ...


thomas (view profile)

Thank you for this usefull functions,
i have just 2 "objections" :
- be carefull of iptcheckinput, it will disapear (maybe replace it by validateattribute, and use inputparser matlab object)
- why dont use the standards or graycomatrix (only one direction as output, no cell array, struct for the stats, offset as a direction vector)


thomas (view profile)

Phu Pham Quoc

Dear Xunkai Wei
Thank you a lot for your useful source code. It helps me so much in my programs.
I am just confused that whether it has some mistakes in the calculation of SRE and LRE.
%1. Short Run Emphasis (SRE)
SRE = sum(p_r./(c_vector.^2))/N_runs;
% 2. Long Run Emphasis (LRE)
LRE = sum(p_r.*(c_vector.^2))/N_runs;
I think we should use p_g instead of p_r ?

sanu mn




Subha (view profile)

Can anyone say how to normalize this GLRL matrix....


Subha (view profile)

yeah we can take the average of features from 4 directions.. and atlast will have 11*1 matrix...


fazli (view profile)

Now I can run the code. Very simple. Thanks a lot

But I do not really understand, how can we combined all features from different direction. (After extracting the features, we will get 11 features from 4 direction. Is it possible to combine the features from each direction. This means the output will be 11x1 matrix only)


Subha (view profile)


Subha (view profile)

Nice toolbox.. works well.. thank you sir..

[GLRLM,SI]= grayrlmatrix(I,'OFFSET',[1;2;3;4],'NumLevels',8,'G',[]);
stats = grayrlprops(GLRLM,{'SRE','LRE','GLN','RLN','RP','LGRE','HGRE','SRLGE','SRHGE','LRLGE','LRHGE'})

i've used in this way is this correct????
1. hw to normalize the runlength matrix?? where and hw to add the command ?


fazli (view profile)


I am new in matlab and image processing
Where can I start using this code

Hope can help

Interesting code !
I was looking for statistics on run length and it's a good starting point.
But you don't mention Stefan Eireiner and use its code even if there are other ways to compute run length which are best for the memory than cell arrays.

Chen-Yi Lee


Daniel Jake

Thank you for sharing this excellent code:)

yue feng

Thx for this great toolbox!

Anas To'meh

I try to use the package, but it did not work.
matlab msg:
Corrupt P-file "D:\matlab\run-length matrix\Mymatlab\grayrlmatrix.p".

Error in ==> test at 6
GLRLMS = GRAYRLMATRIX(m,'Offset',1,'NumLevels',8,'G',[]);

Please update the package with running grayrlmatrix.p file

xunkai wei

Please mind problems of this version,I have fixed several key bugs. A new version will be issued soon.Please keep an eye on it.


Bug fixed version
It issued wrong outputs when handling nonsquare matrix. Now We output cell matrix instead of multi-dimensional matrix.

MATLAB Release
MATLAB 7.5 (R2007b)


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

» Watch video

Win prizes and improve your MATLAB skills

Play today