Code covered by the BSD License

### Highlights from Cooccurrence matrix

3.33333
3.3 | 6 ratings Rate this file 28 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

File Information
Description

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)
23 Jun 2014 Abhishek Singh

### Abhishek Singh (view profile)

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)

Thanks

16 Sep 2011 hu defeng

### hu defeng (view profile)

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

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];
f
end

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.
-cheers;

Comment only
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;
end

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

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

switch(dir)%______________
% |
%_______for i=0 than
case{0},
dir_x = 0;
dir_y = 1;
%_______for i=1 than
case{1},
dir_x = 1;
dir_y = 1;
%_______for i=2 than
case{2},
dir_x = 1;
dir_y = 0;

end%_________________|

good lock...

Comment only