Code covered by the BSD License  

Highlights from
Cooccurrence matrix

3.33333

3.3 | 6 ratings Rate this file 39 Downloads (last 30 days) File Size: 1.7 KB File ID: #11727

Cooccurrence matrix

by

 

19 Jul 2006 (Updated )

Calculates cooccurrence matrix for a given direction and distance

| Watch this File

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)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
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.

12 Dec 2012 abs pir  
10 Apr 2012 Frb

Thanks

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.

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

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;

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

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

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

%####I adive codes####
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...

Contact us