"Fossies" - the Fresh Open Source Software Archive

Member "sip-0.12.1/macros/tangent.sci" (4 Mar 2012, 2598 Bytes) of package /linux/privat/sip-0.12.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scilab source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 function  tgt = tangent(arg1, arg2, arg3, arg4)
    2 //
    3 // Tangent vectors of an object border represented by a
    4 // binary image or a parametric contour.
    5 // TODO
    6 //    - accept coordinates as unique complex vector
    7 //    - pad vector for FFT
    8 // 
    9 // AUTHOR
   10 //    Ricardo Fabbri  <rfabbri@(not this part) gmail d0t com>
   11 //    Cybernetic Vision Research Group
   12 //    Luciano da Fontoura Costa, supervisor.
   13 //    http://siptoolbox.sf.net
   14 //
   15 // REFERENCE    
   16 //    "Shape Analysis and Classification", L. da
   17 //    F. Costa and R. M Cesar Jr., CRC Press,
   18 //    pp. 335-347.
   19 //    "Differential Geometry of Curves and Surfaces", 
   20 //    Manfredo P. do Carmo, Prentice Hall, 1976.
   21 //
   22 
   23 rhs = argn(2)
   24 if rhs == 0 then
   25    error('Invalid number of arguments.')
   26 end
   27 [r,c]=size(arg1)
   28 if (r > 1) & (c > 1)    // input is a binary image
   29    [x,y] = follow(arg1)
   30    select rhs
   31       case 1 
   32          sigma = 5
   33          delta = 1
   34       case 2 
   35          sigma = arg2
   36          delta = 1
   37       case 3
   38          sigma = arg2
   39          delta = arg3
   40       else error('Invalid number of arguments.')
   41    end
   42 else      // input is a parametric contour
   43    select rhs
   44       case 2 
   45          sigma = 5
   46          delta = 1
   47       case 3 
   48          sigma = arg3
   49          delta = 1
   50       case 4
   51          sigma = arg3
   52          delta = arg4
   53       else error('Invalid number of arguments.')
   54    end
   55    x = arg1, y = arg2
   56 end
   57 
   58 X=fft(x,-1);
   59 delta = 1/(delta*size(x,'*'))  // delta_f = 1/(dt*N)
   60 dx = fftderiv(X,1,sigma,in='frequency', delta=delta)';
   61 
   62 Y=fft(y,-1);
   63 dy = fftderiv(Y,1,sigma,in='frequency', delta=delta)';
   64 
   65 tgt = [dx dy];
   66 len = sum(tgt.*tgt,2);
   67 tgt = tgt./[len len];
   68 endfunction
   69 
   70 //
   71 // -------------------------------------------------------------------------
   72 // SIP - Scilab Image Processing toolbox
   73 // Copyright (C) 2002-2009  Ricardo Fabbri
   74 //
   75 // This program is free software; you can redistribute it and/or modify
   76 // it under the terms of the GNU General Public License as published by
   77 // the Free Software Foundation; either version 2 of the License, or
   78 // (at your option) any later version.
   79 //
   80 // This program is distributed in the hope that it will be useful,
   81 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   82 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   83 // GNU General Public License for more details.
   84 //
   85 // You should have received a copy of the GNU General Public License
   86 // along with this program; if not, write to the Free Software
   87 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   88 // -------------------------------------------------------------------------
   89 //