View License

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

» Watch video

Highlights from
Cooccurrence matrix

3.4 | 7 ratings Rate this file 8 Downloads (last 30 days) File Size: 1.7 KB File ID: #11727 Version: 1.0

Cooccurrence matrix


Baran Aydogan (view profile)


19 Jul 2006 (Updated )

Calculates cooccurrence matrix for a given direction and distance

| Watch this File

File Information

Calculates cooccurrence matrix of gray scale images for a given direction (0, +45, +90, +135, +180, -135, -90, -45) and distance

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
31 Aug 2016 france k

Dear friend can any one explain the for loop (intensity1,intensity2) how it works.

23 Jun 2014 Abhishek Singh

I am using this code and it is very slow. Can anyone provide the vectorization version of this code or vectorization version of co-occurrence matrix.

Comment only
12 Dec 2012 abs pir

10 Apr 2012 Frb

Frb (view profile)


16 Sep 2011 hu defeng

14 Aug 2008 John Bertrand

This looks similar to c = n12/(n1 + n2 - n12)

04 Apr 2008 Kartik Gupta

20 Nov 2006 engin tola

to ludvik: thanks for the warning. I didn't know that.

Comment only
24 Oct 2006 Ludvik T

Comment to engin tola: no, you are wrong. It is evaluated only once before all iterations before the "for" cycle, so your proposal would make it slower. Try this:

a = zeros(5,1);
for f = 1:size(a,1);
a = zeros(10,1);

In fact the "for" cycle is equivalent to "cycle through vector" command. This slightly explains how the "for" cycle really works in Matlab:

for f = [2,1:3,700,ones(1,5),pi,7.564];

Comment only
18 Aug 2006 engin tola

instead of using i = 1:size(ind_x1,1) kind of indexing for "for loops" you should compute x1sz=size(ind_x1,1) once and use i = 1:x1sz so that code will not call "size" function for every iteration needlessly.

another point to speed-up the code is to break the inner for loop where the "count" variable is incremented since once the match of indexes is found, it is not necessary to continue searching for the match.

Comment only
16 Aug 2006 anu gawade

22 Jul 2006 Ali ÖZGÜL

Dear Baran Aydogan
I was perused your program code. Your program has some line`s block if-end codes. This region if this code application switch(parameter)-case{} codes than more small. For example your code;

if (dir == 0)
dir_x = 0;
dir_y = 1;

if (dir == 1)
dir_x = 1;
dir_y = 1;

if (dir == 2)
dir_x = 1;
dir_y = 0;

%####I adive codes####
% |
%_______for i=0 than
dir_x = 0;
dir_y = 1;
%_______for i=1 than
dir_x = 1;
dir_y = 1;
%_______for i=2 than
dir_x = 1;
dir_y = 0;


good lock...

Comment only

Contact us