File Exchange

## Gray Level Run Length Matrix Toolbox

version 1.0.0.0 (9.55 KB) by
The toolbox provide useful functions for extract high order run length features

Updated 18 Feb 2008

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.

Citation:
Xunkai Wei, Gray Level Run Length Matrix Toolbox v1.0,Software,Beijing Aeronautical Technology Research Center, 2007 http://www.mathworks.com/matlabcentral/fileexchange/download.do?objectId=17482&fn=RunLengthMatrixToolboxver1.0&fe=.zip&cid=1101680

### Cite As

Xunkai Wei (2021). Gray Level Run Length Matrix Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/17482-gray-level-run-length-matrix-toolbox), MATLAB Central File Exchange. Retrieved .

yogi

I am a novice to Matlab, a simple question: where do I put my images? Thanks!

bakht azam

sam manzoor

i want to know when we calculate GLRLM in literature we find its features as double summation of few terms. the limit of double summation use variables G,R and N. G is the number of grey levels , R is the number of run lengths in the matrix and
N is the number of points in the image. what values of these are taken to calculate features

Sergey Klimov

Seems like some of the run length function names are not correct.

For example:
the Long Run Low Gray-Level Emphasis (LRLGE) function is noted as:
tGLRLM.*(c_matrix.^2)./(r_matrix.^2);
But it should be the c_matrix on the denominator and the r_matrix on the numerator (http://shrike.depaul.edu/~dxu/Papers/final_submission_paper_452_131_last.pdf) . This actually gives the value for the Short Run High Gray-Level Emphasis. Same with some of the other names. You still get the full feature list, just in the wrong order it seems.

RangeRes

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.

Faranak

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?
Thanks

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);

razieh azizian

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:"http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.72.5153"

thomas

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

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

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

Narender

Nice

Subha

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

Subha

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

fazli

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

Subha

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

I=rgb2gray(RGB);
[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

Hi

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

Hope can help
Tq

Nicolas Cusseau

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

Good!

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.

##### MATLAB Release Compatibility
Created with R2007b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux