~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomCam_dstrt.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  * 
 25  * Program :    TINA
 26  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomCam_dstrt.c,v $
 27  * Date    :  $Date: 2002/12/09 11:51:23 $
 28  * Version :  $Revision: 1.1.1.1 $
 29  * CVS Id  :  $Id: geomCam_dstrt.c,v 1.1.1.1 2002/12/09 11:51:23 cvstina Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "geomCam_dstrt.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <tina/sys/sysDef.h>
 46 #include <tina/sys/sysPro.h>
 47 #include <tina/math/mathDef.h>
 48 #include <tina/math/mathPro.h>
 49 #include <tina/image/imgDef.h>
 50 #include <tina/geometry/geomDef.h>
 51 #include <tina/geometry/geom_CamDef.h>
 52 #include <tina/geometry/geom_EdgeDef.h>
 53 #include <tina/geometry/geom_EdgePro.h>
 54 #include <tina/geometry/geomCam_rect.h>
 55 
 56 
 57 Vec2    radial_distort(Vec2 w, double *a)
 58 {
 59     Vec2    v = {Vec2_id};
 60     double  radsq;
 61 
 62     radsq = w.el[0] * w.el[0] + w.el[1] * w.el[1];
 63     v.el[0] = (float)((1.0 - a[1] * radsq) * w.el[0]);
 64     v.el[1] = (float)((1.0 - a[1] * radsq) * w.el[1]);
 65     return (v);
 66 }
 67 
 68 Vec2    radial_correct(Vec2 w, double *a)
 69 {
 70     Vec2    v = {Vec2_id};
 71     double  radsq;
 72 
 73     v.el[0] = w.el[0];
 74     v.el[1] = w.el[1];
 75 
 76     radsq = v.el[0] * v.el[0] + v.el[1] * v.el[1];
 77     v.el[0] = (float)((1.0 + a[1] * radsq) * w.el[0]);
 78     v.el[1] = (float)((1.0 + a[1] * radsq) * w.el[1]);
 79 
 80     radsq = v.el[0] * v.el[0] + v.el[1] * v.el[1];
 81     v.el[0] = (float)((1.0 + a[1] * radsq) * w.el[0]);
 82     v.el[1] = (float)((1.0 + a[1] * radsq) * w.el[1]);
 83     return (v);
 84 }
 85 
 86 Vec2    cam_correct(Vec2 u, Camera * cam)
 87 
 88 
 89 
 90 /* this routine cannot be called with a NULL cam pointer */
 91 {
 92     if ((cam->correct_func != NULL) && (cam->distort_params != NULL))
 93     {
 94         /* change from image to unit camera coordinates */
 95         u = rectify_pos(cam->im_to_cam, u);
 96         /** allow for optical distortion **/
 97         u = cam->correct_func(u, cam->distort_params);
 98         /** change back to image coordinates **/
 99         u = rectify_pos(cam->cam_to_im, u);
100     }
101     return (u);
102 }
103 
104 void   *cam_distort_copy(double *b)
105 {
106     int     i, n;
107     double *a;
108 
109     n = (int) (b[0] + 0.5);
110     a = (double *) ralloc((unsigned) (sizeof(double) * (n + 1)));
111     for (i = 0; i < n + 1; i++)
112         a[i] = b[i];
113     return(a);
114 }
115 
116 /* ARGSUSED quieten lint */
117 void    edge_apply_corr(Edgel * edge, int type, Camera * cam)
118 
119 /* unused */
120 
121 {
122     if (edge == NULL || cam == NULL || cam->correct_func == NULL || cam->distort_params == NULL)
123         return;
124     edge->type &= EDGE_SET_CORR_MASK;
125     edge->type |= EDGE_CORRECTED;
126     edge->pos = cam_correct(edge->pos, cam);
127 }
128 
129 /* ARGSUSED quieten lint */
130 void    edge_add_corr_prop(Edgel * edge, int type, Camera * cam)
131 {
132     Vec2   *r;
133 
134     if (edge == NULL || cam == NULL || cam->correct_func == NULL || cam->distort_params == NULL)
135         return;
136     r = vec2_alloc();
137 
138     *r = cam_correct(edge->pos, cam);
139     edge->props = proplist_addifnp(edge->props, (void *) r, CORRPOS, vec2_free, true);
140 }
141 
142 void    er_add_corrpos_prop(Imrect * er, Camera * cam)
143 {
144     er_apply_to_all_edges(er, edge_add_corr_prop, (void *) cam);
145 }
146 
147 void    er_correct(Imrect * er, Camera * cam)
148 {
149     er_apply_to_all_edges(er, edge_apply_corr, (void *) cam);
150 }
151 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.