File Exchange

image thumbnail

Cooccurrence matrix

version 1.0 (1.7 KB) by

Calculates cooccurrence matrix for a given direction and distance

3.42857
7 Ratings

23 Downloads

Updated

View License

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

Comments and Ratings (14)

komal latif

in which language u run co-occurrence matrix code? @baran Ayodgan

komal latif

if anyone have co-occurrence matrix algorithm. plz email me i need

france k

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

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.

abs pir

Frb

Frb (view profile)

Thanks

hu defeng

John Bertrand

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

Kartik Gupta

engin tola

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

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

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;

anu gawade

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

MATLAB Release
MATLAB 7.1.0 (R14SP3)

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

» Watch video