f

#### Matlab's 'graycomatrix' function

```I have one question: Is Matlab's 'graycomatrix' function actually in
accordance with original Haralick's 1973 paper?
I mean, are they supposed to be the same algorithm? If yes, I don't
think Matlab did a good job on this.

For example, try it on this matrix (i.e., 'image'):
0 0 1 1
0 0 1 1
0 2 2 2
2 2 3 3

This matrix is in Haralick's original paper and the results can be
compared.

Can anybody ellaborate if you used it?

Thank you.
```
 0
bayrakta (3)
3/4/2005 5:40:01 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader.

5 Replies
1736 Views

Similar Articles

[PageSpeed] 12

```"Bulent Bayraktar" <bayrakta@purdue.edu> writes:

> I have one question: Is Matlab's 'graycomatrix' function actually in
> accordance with original Haralick's 1973 paper?
> I mean, are they supposed to be the same algorithm? If yes, I don't
> think Matlab did a good job on this.
>
> For example, try it on this matrix (i.e., 'image'):
> 0 0 1 1
> 0 0 1 1
> 0 2 2 2
> 2 2 3 3
>
> This matrix is in Haralick's original paper and the results can be
> compared.
>
> Can anybody ellaborate if you used it?

You do need to understand a bit about the conventions used in the software you
are using.  For example, the Image Processing Toolbox's default black-to-white
range for double-precision inputs is [0, 1].  The reference page for
graycomatrix describes in detail what it does.  By default, for example, it
quantizes the range [0, 1] into 8 levels, resulting in an 8-by-8 co-occurrence
matrix.  But for your matrix, it is seeing 5 "black," or zero-valued pixels, and
11 "white" pixels (greater than or equal to 1).

http://www.mathworks.com/access/helpdesk/help/toolbox/images/graycomatrix.html

--
Steve Eddins

Development Manager, Image Processing Group
The MathWorks, Inc.
```
 0
steve.eddins (785)
3/4/2005 6:23:41 PM
```Thanks Steve but my question is still unanswered. I already found out
(before I posted the first message) that the usage was different. I
actually used (for the matrix specified below)

[glcm,si] = graycomatrix(xx,'NumLevels',4,'GrayLimits',[]);

Sounds reasonable? Correct use or not?

If correct, I think Matlab's implementation is not the same as

"Because the processing required to calculate a GLCM for the full
dynamic range of an image is prohibitive, graycomatrix scales the
values in I". I don't understand why since even a 256 by 256 GLCM
shouldn't be hard to handle as far as the speed goes. I actually
wrote a code of my own (before I knew there was 'graycomatrix') and
even for 256-size image, my inefficient code doesn't take long at all
to calculate GLCM.

Thanks a bunch again.

Steve Eddins wrote:
>
>
> "Bulent Bayraktar" <bayrakta@purdue.edu> writes:
>
>> I have one question: Is Matlab's 'graycomatrix' function
actually
> in
>> accordance with original Haralick's 1973 paper?
>> I mean, are they supposed to be the same algorithm? If yes, I
> don't
>> think Matlab did a good job on this.
>>
>> For example, try it on this matrix (i.e., 'image'):
>> 0 0 1 1
>> 0 0 1 1
>> 0 2 2 2
>> 2 2 3 3
>>
>> This matrix is in Haralick's original paper and the results can
> be
>> compared.
>>
>> Can anybody ellaborate if you used it?
>
> You do need to understand a bit about the conventions used in the
> software you
> are using. For example, the Image Processing Toolbox's default
> black-to-white
> range for double-precision inputs is [0, 1]. The reference page
> for
> graycomatrix describes in detail what it does. By default, for
> example, it
> quantizes the range [0, 1] into 8 levels, resulting in an 8-by-8
> co-occurrence
> matrix. But for your matrix, it is seeing 5 "black," or
> zero-valued pixels, and
> 11 "white" pixels (greater than or equal to 1).
>
> <http://www.mathworks.com/access/helpdesk/help/toolbox/images/graycomatrix.html>
>
> --
> Steve Eddins
>
> Development Manager, Image Processing Group
> The MathWorks, Inc.
>
```
 0
bayrakta (3)
3/4/2005 6:54:35 PM
```"Bulent Bayraktar" <bayrakta@purdue.edu> writes:

> Thanks Steve but my question is still unanswered. I already found out
> (before I posted the first message) that the usage was different. I
> actually used (for the matrix specified below)
>
> [glcm,si] = graycomatrix(xx,'NumLevels',4,'GrayLimits',[]);
>
> Sounds reasonable? Correct use or not?
>
> If correct, I think Matlab's implementation is not the same as

>> I = [0 0 1 1; 0 0 1 1; 0 2 2 2; 2 2 3 3]

I =

0     0     1     1
0     0     1     1
0     2     2     2
2     2     3     3

>> graycomatrix(I,'NumLevels',4,'Gray',[])

ans =

2     2     1     0
0     2     0     0
0     0     3     1
0     0     0     1

What's wrong with this?  Take the first row: there are 2 instances of a 0-valued
pixel to the right of a 0-valued pixel; 2 instances 1-valued pixel to the right
of a 0-valued pixel; 1 instance of a 2-valued pixel to the right of a 0-value;
and no instances of a 3-valued pixel to the right of a 0-valued pixel.

Perhaps you are comparing with results computing using a different offset?

> "Because the processing required to calculate a GLCM for the full
> dynamic range of an image is prohibitive, graycomatrix scales the
> values in I". I don't understand why since even a 256 by 256 GLCM
> shouldn't be hard to handle as far as the speed goes. I actually
> wrote a code of my own (before I knew there was 'graycomatrix') and
> even for 256-size image, my inefficient code doesn't take long at all
> to calculate GLCM.

You may be corrent, here.  I'll pass along a suggestion to consider revising the
doc.

--
Steve Eddins

Development Manager, Image Processing Group
The MathWorks, Inc.
```
 0
steve.eddins (785)
3/4/2005 7:26:54 PM
```>>> I = [0 0 1 1; 0 0 1 1; 0 2 2 2; 2 2 3 3]
>
> I =
>
> 0 0 1 1
> 0 0 1 1
> 0 2 2 2
> 2 2 3 3
>
>>> graycomatrix(I,'NumLevels',4,'Gray',[])
>
> ans =
>
> 2 2 1 0
> 0 2 0 0
> 0 0 3 1
> 0 0 0 1
>
> What's wrong with this? Take the first row: there are 2 >
instances of a 0-valued pixel to the right of a 0-valued > pixel;
2 instances 1-valued pixel to the right of a 0- > valued pixel;
1 instance of a 2-valued pixel to the > right of a 0-value;
and no instances of a 3-valued pixel > to the right of a 0-valued
pixel.

Well, there may not be anything wrong... the same matrix produces the
following GLCM (with [0 1] - horizontal - offset and for 0 degree)in
Haralick's original paper:

4 2 1 0
2 4 0 0
1 0 6 1
0 0 1 2

The difference is that the 180 degree (complement of 0) elements are
also included in Haralick's GLCM. I would have said the the
approaches are the same since the diagonal elements are different
with a factor of 2, but the off-diagonal elements would be totally
different (which will eventually change the texture feature values
for sure).

Any compromises here?

Thank you.

> Perhaps you are comparing with results computing using a different
offset?
```
 0
bayrakta (3)
3/4/2005 8:20:25 PM
```"Bulent Bayraktar" <bayrakta@purdue.edu> writes:

>>>> I = [0 0 1 1; 0 0 1 1; 0 2 2 2; 2 2 3 3]
>>
>> I =
>>
>> 0 0 1 1
>> 0 0 1 1
>> 0 2 2 2
>> 2 2 3 3
>>
>>>> graycomatrix(I,'NumLevels',4,'Gray',[])
>>
>> ans =
>>
>> 2 2 1 0
>> 0 2 0 0
>> 0 0 3 1
>> 0 0 0 1
>>
>> What's wrong with this? Take the first row: there are 2 >
> instances of a 0-valued pixel to the right of a 0-valued > pixel;
> 2 instances 1-valued pixel to the right of a 0- > valued pixel;
> 1 instance of a 2-valued pixel to the > right of a 0-value;
> and no instances of a 3-valued pixel > to the right of a 0-valued
> pixel.
>
> Well, there may not be anything wrong... the same matrix produces the
> following GLCM (with [0 1] - horizontal - offset and for 0 degree)in
> Haralick's original paper:
>
> 4 2 1 0
> 2 4 0 0
> 1 0 6 1
> 0 0 1 2
>
> The difference is that the 180 degree (complement of 0) elements are
> also included in Haralick's GLCM. I would have said the the
> approaches are the same since the diagonal elements are different
> with a factor of 2, but the off-diagonal elements would be totally
> different (which will eventually change the texture feature values
> for sure).
>
> Any compromises here?

Possibly. We'll consider it.

--
Steve Eddins

Development Manager, Image Processing Group
The MathWorks, Inc.
```
 0
steve.eddins (785)
3/4/2005 9:11:55 PM

Similar Artilces:

Error while obtaining sizes from MEX S-function 'forward' in block 'dummy/Dynamic_Model/S-Function'. MATLAB error message:.
Hi to everybody, I created the file forward.dll using the command: mex -DWIN32 -output forward model_d.c model_s.c sdlib.c assigns.c contact.c derivs.c gmc.c impact.c inits.c invert.c lcp_solver.c lmdif_c.c mathtools.c object.c output.c pipetools.c readmuscles.c readtools.c sdfor.c spring_based.c wrapping.c gcvspl.c user_def.lib forward.lib acpp.lib qhull.lib solid.lib wrap.lib I need to run the command: set_param([subsystemname,'/','S-Function'],'function name','forward','parameters','[0],[0],[0],[0],[0],[0],[1 0 0 0 20],[0]'); ...

MatLab's 'movie' function
Hi! Using MatLab's 'movie' function you can play a movie recorded by the 'getframe' command. It is possible to specify the number of times the movie is played and the frames per second. Unfortunately, I've not found a way to stop the playback of a movie. Is it possible to, let's say I've specified the movie should be played 20 times, to disrupt the playback after an user interrupt?! Thanks a lot, Chris On Sat, 12 Feb 2005 10:40:06 +0100, Christoph ROLZ wrote: >Hi! > >Using MatLab's 'movie' function you can play a movie recorded by...

'Matlab Code' to 'Embedded Matlab fun code'
Dear friends, I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simulink and I want to use it in 'Embedded Matlab fun block' so i need to transform 'Matlab code' to 'Embedded Matlab fun code' to perform the task. The Matlab code is as follows: %%%%%%%%%%%%%%%%%%%%% u_abs = abs(u); major_th = 1.5e-1; minor_th = 1.8e-2; major_peak_value = []; minor_peak_value = []; pos = 1; pos_max = 1; while ~isempty(pos) [m pos_max(end+1)] = max( u_abs( pos : pos + 10) ); pos...

Performance of Matlab 'zip' and 'unzip' functions
I'm using matlab 6.5 and I just realized that it comes with zip and unzip functions. On the first try it seems that the matlab zip functions are slower than other commonly available programs e.g. winzip, winrar. Anyone has any reliable data about the performance of Matlab zip and unzip functions? Failing that, personal experience is good too. Thanks! Terence Leong wrote: > > > I'm using matlab 6.5 and I just realized that it comes with zip and > unzip functions. On the first try it seems that the matlab zip > functions are slower than other commonly available programs ...

Matlab 'mfilt.cicdecim' and 'filter' functions
I am trying to see the response of a CIC filter for a set of input data. I created the filter using the function Hd = mfilt.cicdecim(100, 1, 3) set(Hd, ... 'InputWordLength', 3, ... 'InputFracLength', 0, ... 'FilterInternals', 'FullPrecision'); I have some signed data in decimal in an input array 'x'. If I do, y = filter(Hd, x) 1. I am getting all zeros in y 2. y is not the form of a vector, but has other data in it. I am puzzled on why y has all zeros? Can somebody help? ...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

It's on-it's off-it's on, it's off -WHY?
IS THIS THE CORRECT FORUM? Hope so. We have three computer networked at home...all with Windows XP. one of those is a laptop. Some mornings all 3 can see each other and transfer files...then mysteriously one or more will disappear. No contact....then later it's back. The laptop is the worst. Most often it won't let us in...but sometimes it will. No obvious reason. The most INFURIATING part is the message "see your administrator". Dammit Bill Gates...don't you realize that most networks are small offices without a Majestic Royal Administrator sitting his i...

'is not' or '!='
A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y" tells you whether x and y actually refer to the same object. In the case of singletons like None (there's only one None object), it's better to use "is". "ElChino" <elchino@cnn.cn>: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: Do the following: take two \$10 bills. Hold one bill in the left hand, hold the other bill in the right hand. Now, the bill in the left hand "is not" the bill in the right hand. However, the bill in the left hand "==" the bill in the right hand. > Without any context, which one should be preferred? > IMHO, the latter is more readable. In almost all cases, both tests would result in the same behavior. However, the "is not" test is conceptually the correct one since you want...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

calling '!' or 'system' in matlab different than same functions from shell
Hi everyone, When I am in the shell (tcsh) on my Mac (outside Matlab), I am able to use the command line utility ncdump to read netcdf format files (http://www.unidata.ucar.edu/software/netcdf/): ncdump -h testfile.nc However, in Matlab, the same command preceded by the '!' (or using 'system') generates an error: >> !ncdump -h test.nc dyld: Library not loaded: /opt/local/lib/libnetcdf.7.dylib Referenced from: /opt/local/bin/ncdump Reason: Incompatible library version: ncdump requires version 10.0.0 or later, but libnetcdf.7.dylib provides version ...

Preventing Matlab's history from data entered through 'Input' function
Whether Matlab's history can be adjusted to prevent recording the data entered from the keyboard through 'Input' function during execution of a script? Thanks you very much in advance. ...

Matlab's 'rmfield' in Scilab
Hello, Does anyone know how to perform the MAtlab's rmfield function in Scilab. There isnt an equivalent function in SCilab, and the field and arrays get me confused. Does anyone know of or can give some tips on an alternative routine? Thanks! ...

i wonder result's difference between 'solve function' and 'circcirc function'
i calculate intersection point between two circles. first way, i used solve function. second way, i used circcirc function. By the way two way result is similar. but, The result is the same five-digit decimal. i wonder result's difference between 'solve function' and 'circcirc function' five-digit decimal. >> five decimal places On 7/11/14 7:03 AM, 김영재 wrote: > i wonder result's difference between 'solve function' and 'circcirc function' solve is much more general. Try finding the intersections between y=x^3 and y=9*x us...

Error? s = assignin('base','s',tf('s'));
Hi, I need a little help here. Could anyone please tell me what is wrong with this command? s = assignin('base','s',tf('s')); The matlab syntax is -- assignin(ws, 'var', val) Basically I just want to add s=tf('s') into the base workspace. Jack "Jack" <Jack@Jill.com> wrote in message news:ef3e449.-1@webcrossing.raydaftYaTP... > Hi, > I need a little help here. Could anyone please tell me what is wrong > with this command? > > s = assignin('base','s',tf('s')); > > The matlab syntax is -- assignin(ws, 'var', val) > Basically I just want to add s=tf('s') into the base workspace. What does the error message say? Something about too many output arguments, right? How many output arguments does the documentation for ASSIGNIN show that it should return? How many are you asking it to return? http://www.mathworks.com/access/helpdesk/help/techdoc/ref/assignin.html -- Steve Lord slord@mathworks.com ...

How to turn off 'N', 'S', 'E', 'W'
in the map lat and lon labels? I'm doing a final figure and I really don't need an 'N' after every latitude label, jus the number would suffice. How do I turn of the letters followin the number? What function / toolbox are you refering to?!? Being a little more specific would sure help to get an answer ... Sebastian ...

A question about 'class' and 'set' at MATLAB
In my project,an error stop my step.Need help!......About class and set value. For example: %Create a class D: D.value = 1; D = class(D,'model'); %Create a class C: C.value = 2; C.submodel = D; C = class(C,'model'); %Create a class B: B.value = 3; B.submodel = C; B = class(B,'model'); %Create a class A: A.value = 4; A.submodel = B; A = class(A,'model'); Now I wanna set D.value = 0, what can I do for that ? A.B.C.D.value ? no,maybe MATLAB is not power enough for this ? t.Michael Chan wrote: &...

Matlab BUG??? what's wrong with Matlab's "fmincon"?
I've set the lower bound for my parameter x to be 1e-7, and the upper bound for my parameter x to be 3, that's to say, it everything is correct, x should be within the range of [1e-7, 3], but then in my optimization objective function, I have a "log" function, involving log(x), I've checked, it gave me a complexe number, that's because Matlab "fmincon" still put x= -1.2547e-008, despite the fact that negative x is not allowed... What's wrong with Matlab's "fmincon"? It is difficult to know the answer to your question without se...

Difference between Matlab's A*A' and Netlib's BLAS dsyrk routine
I noticed a difference in multiplying a matrix A with its tranposation: A* A', between Matlab R2014b and Netlib's BLAS which uses dsyrk routine. I really need to know what causes the difference here. For example, in a 6x6 matrix created by: (1) rng('default'); A = 1000 * (1 - rand(6,6)); X = A * A'; Then X has a floating-point difference to the same matrix, created by normal matrix matrix multiplication, or created by an implemention of BLAS's dsyrk/dgemm routine. (2) Normal matrix matrix multiplication B = A'; X = A*B; (3) BLAS's dsyrk implement...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal''''''''''''''
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria" FROM "criteria" WHERE "criteria" UPDATE/APPEND "field selections" RecordSource "qryExample" = above text strings" _______________________________________________________________________ When i am running a SELECT query in this manner it works fine with no problems, and accepts the values of specified linked for...

gmdistribution.fit ERROR: Method 'fit' is not defined for class 'gmdistribution' or is removed from MATLAB's search path
Hi, I have to use a specific program that contains those rows: >S = struct('mu',mu,'Sigma',sigma,'PComponents',p); >options = statset('Display','final','MaxIter', 9000); >object =gmdistribution.fit(X,NGauss,'Options', options,'Start',S); but when I launch the program it returns this error: >Error using gmdistribution.fit >Method 'fit' is not defined for class 'gmdistribution' or is removed from MATLAB's search path. >Error in val (line 149) >object =gmdistribution.fit(X,NG...

when im trying to load a .wav file as ascii, im getting following error , can anybody resolve it??????? s=load('C:\Users\Lubna\matlab\2_1.wav', '-ascii') ??? Error using ==> load Unknown text on line number 1 of ASCII file C:\Users\Lubna\matlab\2_1.wav "RIFFX". "ABC " <looma.amir.ali@gmail.com> wrote in message <jn3vqv\$edk\$1@newscl01ah.mathworks.com>... > when im trying to load a .wav file as ascii, im getting following error , can anybody resolve it??????? > s=load('C:\Users\Lubna\matlab\2_1.wav', '-ascii') &...

There's 'new' but no 'delete'
Hi, If I use: "myobject = new MyObject" do I just delete it with "myobject = nil"? There's no "delete", how do I free any memory used within myobject? Thanks, Paul On 15.04.2005 05:35 Mat, in 425e45ff\$0\$30370\$afc38c87@news.optusnet.com.au, �pf� <paulfredlein@NOSPAMoptusnet.com.au> wrote: > Hi, > > If I use: "myobject = new MyObject" do I just delete it with "myobject = > nil"? There's no "delete", how do I free any memory used within myobject? > > Thanks, > > Paul ...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

Web resources about - Matlab's 'graycomatrix' function - comp.soft-sys.matlab

Resources last updated: 3/2/2016 4:13:07 AM