Permalink
Browse files

documented the tangent function

  • Loading branch information...
1 parent 411f0a6 commit bda173cce5767c8a50765ee18cf0aa8526fbaa62 @rfabbri committed Mar 4, 2012
Showing with 154 additions and 13 deletions.
  1. +11 −5 ChangeLog.txt
  2. +1 −1 help/Makefile.am
  3. +1 −1 help/en_US/curvature.xml
  4. +131 −0 help/en_US/tangent.xml
  5. +1 −1 macros/Makefile.am
  6. +5 −2 macros/follow.sci
  7. +4 −3 macros/tangent.sci
View
@@ -2,14 +2,20 @@ SIP - Scilab Image Processing Toolbox
Copyright (C) 2002-2012 Ricardo Fabbri
__________________________________________________________________
+
+0.8.x
+ + new tangent function to compute the tangential direction at each point of a
+ sampled curve or binary contour
+
+
0.8.0 Major new features!
This list highlights the main changes from 0.5.0 to 0.7.1. Read the
previous changelogs for minor improvements and details.
+ opencv support - new canny edge detection function
+ edilate now very fast with cutting edge exact Euclidean propagation algorithm
+ bwdist now has max_dist option to compute the EDT up to a maximum distance
- using a specialized fast exact Euclidean propagation algorithm.
+ using a specialized fast exact Euclidean propagation algorithm
+ new imshow option to use external viewer
+ new sip_exec utility to exec script anywhere on PATH
+ updated help files to contain illustrating figures
@@ -24,7 +30,7 @@ __________________________________________________________________
+ new function color_classify for color recognition
+ new function KRC_from_P for decomposing a camera matrix P into intrinsic
parameters K, rotation R, and camera center C.
- + new function sip_rq for RQ decomposition (the reverse of qr).
+ + new function sip_rq for RQ decomposition (the reverse of qr)
+ new functions to convert between rotation matrices, quaternions, and
exponential representations: quaternion2rot_matrix, rot_matrix2quaternion,
exp2rot_matrix, quaternion_matrix, quaternion_multiply
@@ -36,8 +42,8 @@ __________________________________________________________________
+ new imshow option to use external viewer
+ edilate now very fast with cutting edge exact Euclidean propagation algorithm
+ bwdist now has max_dist option to compute the EDT up to a maximum distance
- using a specialized fast exact Euclidean propagation algorithm.
- + various updates to help pages.
+ using a specialized fast exact Euclidean propagation algorithm
+ + various updates to help pages
0.7.0
+ new extras/ directory with code for specific practical problems. the biospot
@@ -58,7 +64,7 @@ __________________________________________________________________
+ fixed help building for systems returning non-en_US in getlanguage(),
bug #3393248
- + fixed help links to scilab functions external to SIP.
+ + fixed help links to scilab functions external to SIP
0.5.4
+ works with Scilab Git master branch
View
@@ -19,7 +19,7 @@
## -------------------------------------------------------------------------
##
-helppages_xml = en_US/imshow.xml en_US/bwborder.xml en_US/curvature.xml en_US/edge.xml en_US/follow.xml en_US/getangle.xml en_US/gsm.xml en_US/hsv2rgb.xml en_US/im2bw.xml en_US/im2gray.xml en_US/imfinfo.xml en_US/imnoise.xml en_US/imread.xml en_US/imwrite.xml en_US/ind2rgb.xml en_US/mogrify.xml en_US/ntsc2rgb.xml en_US/rgb2hsv.xml en_US/rgb2ntsc.xml en_US/unfollow.xml en_US/xgetpixel.xml en_US/perim.xml en_US/bwdist.xml en_US/bwlabel.xml en_US/curvature2d.xml en_US/dilate.xml en_US/drawline.xml en_US/edilate.xml en_US/erode.xml en_US/fftderiv.xml en_US/fractal.xml en_US/gsm2d.xml en_US/hello_sip.xml en_US/hough.xml en_US/ihough.xml en_US/imconv.xml en_US/imcorrcoef.xml en_US/imphase.xml en_US/improfile.xml en_US/imroi.xml en_US/imvariance.xml en_US/imxprofile.xml en_US/interferometry_gui.xml en_US/iradon.xml en_US/minmax.xml en_US/mkfftfilter.xml en_US/mkfilter.xml en_US/normal.xml en_US/percol.xml en_US/pifilter.xml en_US/poledetection.xml en_US/radon.xml en_US/rgbplot.xml en_US/sip_colormap.xml en_US/sip_fftshift.xml en_US/sip_setenv.xml en_US/sip_set_verbose.xml en_US/skel.xml en_US/thin.xml en_US/unwrapl.xml en_US/unwrapp.xml en_US/watershed.xml en_US/xor.xml en_US/gray_imread.xml en_US/sip_rq.xml en_US/KRC_from_P.xml en_US/quaternion2rot_matrix.xml en_US/rot_matrix2quaternion.xml en_US/exp2rot_matrix.xml en_US/quaternion_matrix.xml en_US/quaternion_multiply.xml en_US/arclength.xml
+helppages_xml = en_US/imshow.xml en_US/bwborder.xml en_US/curvature.xml en_US/edge.xml en_US/follow.xml en_US/getangle.xml en_US/gsm.xml en_US/hsv2rgb.xml en_US/im2bw.xml en_US/im2gray.xml en_US/imfinfo.xml en_US/imnoise.xml en_US/imread.xml en_US/imwrite.xml en_US/ind2rgb.xml en_US/mogrify.xml en_US/ntsc2rgb.xml en_US/rgb2hsv.xml en_US/rgb2ntsc.xml en_US/unfollow.xml en_US/xgetpixel.xml en_US/perim.xml en_US/bwdist.xml en_US/bwlabel.xml en_US/curvature2d.xml en_US/dilate.xml en_US/drawline.xml en_US/edilate.xml en_US/erode.xml en_US/fftderiv.xml en_US/fractal.xml en_US/gsm2d.xml en_US/hello_sip.xml en_US/hough.xml en_US/ihough.xml en_US/imconv.xml en_US/imcorrcoef.xml en_US/imphase.xml en_US/improfile.xml en_US/imroi.xml en_US/imvariance.xml en_US/imxprofile.xml en_US/interferometry_gui.xml en_US/iradon.xml en_US/minmax.xml en_US/mkfftfilter.xml en_US/mkfilter.xml en_US/normal.xml en_US/percol.xml en_US/pifilter.xml en_US/poledetection.xml en_US/radon.xml en_US/rgbplot.xml en_US/sip_colormap.xml en_US/sip_fftshift.xml en_US/sip_setenv.xml en_US/sip_set_verbose.xml en_US/skel.xml en_US/thin.xml en_US/unwrapl.xml en_US/unwrapp.xml en_US/watershed.xml en_US/xor.xml en_US/gray_imread.xml en_US/sip_rq.xml en_US/KRC_from_P.xml en_US/quaternion2rot_matrix.xml en_US/rot_matrix2quaternion.xml en_US/exp2rot_matrix.xml en_US/quaternion_matrix.xml en_US/quaternion_multiply.xml en_US/arclength.xml en_US/tangent.xml
helpdir=@TOOLBOXDIR@/jar
View
@@ -59,7 +59,7 @@
<refsection>
<title>Description</title>
<para>
- Function curvature calculates the curvature at each point of a binary contour, using FFT and a formula from differential geometry. </para>
+ Function <literal>curvature</literal> calculates the curvature at each point of a binary contour, using FFT and a formula from differential geometry. </para>
</refsection>
<refsection>
View
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="curvature">
+<info>
+ <pubdate>March, 2012</pubdate>
+</info>
+<refnamediv>
+ <refname>tangent</refname>
+ <refpurpose>compute tangents of a sampled curve</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis> K = tangent(BW [,sigma, delta])</synopsis>
+ <synopsis> K = tangent(x,y [,sigma, delta])</synopsis>
+</refsynopsisdiv>
+
+<refsection>
+<title>Parameters</title>
+<variablelist>
+
+ <varlistentry>
+ <term>tgt</term>
+ <listitem>
+ nx2 vector whose i-th line is the unit tangent vector at the i-th sample
+ of the contour.
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>BW</term>
+ <listitem>
+ Binary image containing only one object (0 for background, 1 for object).
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>x</term>
+ <term>y</term>
+ <listitem>
+ vectors, storing the parametrized contour.
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>sigma</term>
+ <listitem>
+ standard deviation of the gaussian function used to smooth the contour before computing the curvature. Defaults to 5.
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>delta</term>
+ <listitem>
+ a double number, the time between samples (delta t), and defaults to 1.
+ </listitem>
+ </varlistentry>
+</variablelist>
+</refsection>
+
+<refsection>
+<title>Description</title>
+ <para>
+ Function <literal>tangent</literal> calculates the tangent direction as a
+ vector at each point of a binary or sampled contour, using FFT and a formula from
+ differential geometry. </para>
+
+</refsection>
+<refsection>
+<title>Examples</title>
+ <programlisting><![CDATA[
+ initial_dir = PWD;
+ chdir (SIPDIR + 'images');
+
+ a=gray_imread('r.gif');
+ a=im2bw(a, 0.5);
+ [x,y]=follow(a);
+
+ npts = size(x,'*');
+ tgt=tangent(x,y, 1);
+
+ // Show the results
+ fig;
+ clf;
+ plot(x,y);
+ set(gca(), "isoview","on");
+ set(gca(), "auto_clear","off");
+
+ // todo use buffering
+ for i=1:size(x,'*')
+ champ(x(i),y(i),tgt(i,1),tgt(i,2),0.5);
+ end
+
+ chdir(initial_dir);
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+<title>References</title>
+<para>
+"Shape Analysis and Classification", L. da
+F. Costa and R. M. Cesar Jr., CRC Press.
+</para>
+<para>
+"Differential Geometry of Curves and Surfaces", Manfredo
+P. do Carmo, Prentice Hall, 1976.
+</para>
+</refsection>
+
+<refsection><title>Authors</title><simplelist type="vert">
+ <member>Ricardo Fabbri &lt;ricardofabbri[at]users.sf.net&gt;</member>
+</simplelist></refsection>
+
+<refsection><title>Availability</title>
+The latest version of SIP can be found at
+<para>http://siptoolbox.sf.net </para>
+</refsection>
+
+<refsection><title>See Also</title><simplelist type="inline">
+ <member> <link linkend="follow">follow</link> </member>
+ <member> <link linkend="gsm">gsm</link> </member>
+ <member> <link linkend="fftderiv">fftderiv</link> </member>
+</simplelist>
+</refsection>
+
+</refentry>
+<!-- ===================================================
+ SIP - Scilab Image Processing toolbox
+ Copyright (C) 2002-2009 Ricardo Fabbri
+
+ See the file COPYING for license-related issues
+ =================================================== -->
View
@@ -19,7 +19,7 @@
# The following variables are generated by configure:
# TOOBOXDIR, SCIDIR
-macros_sci = bwborder.sci curvature2d.sci curvature.sci dilate.sci edge.sci erode.sci fftderiv.sci follow.sci fractal.sci getangle.sci gray_imread.sci gsm2d_old.sci gsm2d.sci gsm.sci hough.sci ihough.sci im2bw.sci im2gray.sci imconv.sci imcorrcoef.sci imnoise.sci imphase.sci improfile.sci imroi.sci imshow.sci imxprofile.sci ind2rgb.sci iradon.sci minmax.sci mkfftfilter.sci mkfilter.sci normal.sci ntsc2rgb.sci perim.sci pifilter.sci poledetection.sci radon.sci rgb2ntsc.sci rgbplot.sci sip_approx_true_cmap.sci sip_colormap.sci sipdemo.sci sip_fftshift.sci sip_index_true_cmap.sci sip_quiet.sci sip_wordy.sci unfollow.sci unwrapl.sci unwrapp.sci xgetpixel.sci xor.sci sip_rq.sci KRC_from_P.sci quaternion2rot_matrix.sci rot_matrix2quaternion.sci exp2rot_matrix.sci quaternion_matrix.sci quaternion_multiply.sci color_classify.sci color_classify_single.sci color_segmentation.sci imhist.sci arclength.sci sip_exec.sci
+macros_sci = bwborder.sci curvature2d.sci curvature.sci dilate.sci edge.sci erode.sci fftderiv.sci follow.sci fractal.sci getangle.sci gray_imread.sci gsm2d_old.sci gsm2d.sci gsm.sci hough.sci ihough.sci im2bw.sci im2gray.sci imconv.sci imcorrcoef.sci imnoise.sci imphase.sci improfile.sci imroi.sci imshow.sci imxprofile.sci ind2rgb.sci iradon.sci minmax.sci mkfftfilter.sci mkfilter.sci normal.sci ntsc2rgb.sci perim.sci pifilter.sci poledetection.sci radon.sci rgb2ntsc.sci rgbplot.sci sip_approx_true_cmap.sci sip_colormap.sci sipdemo.sci sip_fftshift.sci sip_index_true_cmap.sci sip_quiet.sci sip_wordy.sci unfollow.sci unwrapl.sci unwrapp.sci xgetpixel.sci xor.sci sip_rq.sci KRC_from_P.sci quaternion2rot_matrix.sci rot_matrix2quaternion.sci exp2rot_matrix.sci quaternion_matrix.sci quaternion_multiply.sci color_classify.sci color_classify_single.sci color_segmentation.sci imhist.sci arclength.sci sip_exec.sci tangent.sci
macros_bin = $(macros_sci:.sci=.bin)
View
@@ -51,9 +51,12 @@ aux(2:r+1,2:c+1)=Im;
Im = aux;
clear aux
i=1;
-while( Im(i)<>1)
+while Im(i)<>1
i=i+1;
- end;
+ if i > r*c
+ error('Image has no 1-pixels. Perhaps you need to round it or use im2bw.');
+ end
+end
prv=i-1;
[i,j]=index2(i,r+2);
View
@@ -57,13 +57,14 @@ end
X=fft(x,-1);
delta = 1/(delta*size(x,'*')) // delta_f = 1/(dt*N)
-dx = fftderiv(X,1,sigma,in='frequency', delta=delta)
+dx = fftderiv(X,1,sigma,in='frequency', delta=delta)';
Y=fft(y,-1);
-dy = fftderiv(Y,1,sigma,in='frequency', delta=delta)
+dy = fftderiv(Y,1,sigma,in='frequency', delta=delta)';
tgt = [dx dy];
-tgt = tgt/norm(tgt);
+len = sum(tgt.*tgt,2);
+tgt = tgt./[len len];
endfunction
//

0 comments on commit bda173c

Please sign in to comment.