diff options
author | shamikam | 2017-01-16 02:56:17 +0530 |
---|---|---|
committer | shamikam | 2017-01-16 02:56:17 +0530 |
commit | a6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch) | |
tree | e806e966b06a53388fb300d89534354b222c2cad /macros/autoCorrelator.sci | |
download | FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.gz FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.bz2 FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.zip |
Diffstat (limited to 'macros/autoCorrelator.sci')
-rw-r--r-- | macros/autoCorrelator.sci | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/macros/autoCorrelator.sci b/macros/autoCorrelator.sci new file mode 100644 index 0000000..991b903 --- /dev/null +++ b/macros/autoCorrelator.sci @@ -0,0 +1,46 @@ +function relation = autoCorrelator(inputMatrix) +//Calculate 2-D auto correlation of input matrix +// +//Calling Sequence +// relation=autoCorrelator(inputMatrix) +// +//Parameters +// inputMatrix: input matrix to calculate auto correlation +// +//Description +//This function computes 2-D auto correlation of input matrix +// +// Examples +// rel = autoCorrelator([3 1;2 4]) // examples of use + + [lhs rhs]=argn(0); + if rhs<1 then + error(msprintf("Wrong arguments: Need atleast one argument")) + end + [r,c,channels] = size(inputMatrix); + if channels<> 1 then + error(msprintf("Auto correlator function do not support more than two dimensions")) + elseif type(inputMatrix)<> 1 + error(msprintf("Auto correlator function do not support input type %s",typeof(inputMatrix))) + end + Rep = zeros(r + r*2-2, c + c*2-2); + for x = r : r+r-1 + for y = c : c+c-1 + Rep(x,y) = inputMatrix(x-r+1, y-c+1); + end + end + conjMatrix=conj(inputMatrix); + //(mROw,mCols)- It indicates middle value of the output matrix + relation = zeros(r+r-1,c+c-1); //output matrix + //calculating only half of the output matrix + for x = 1 : r+r-1 + for y = 1 : c+c-1 + for i = 1 : r + for j = 1 : c + relation(x, y) = relation(x, y) + (Rep(x+i-1, y+j-1) * conjMatrix(i, j)); + end + end + end + end + //Copying remainig values +endfunction |