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

Linux Cross Reference
Tina6/tina-libs/tina/vision/visMatch_ctemp.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/vision/visMatch_ctemp.c,v $
 27  * Date    :  $Date: 2008/12/09 00:15:22 $
 28  * Version :  $Revision: 1.4 $
 29  * CVS Id  :  $Id: visMatch_ctemp.c,v 1.4 2008/12/09 00:15:22 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "visMatch_ctemp.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/geometry/geomDef.h>
 49 #include <tina/geometry/geomPro.h>
 50 #include <tina/vision/vis_MatchPro.h>
 51 
 52 static double xdisp, ydisp, height, width, correlate, uniqueness;
 53 static double asymetry = 0.85, range = 3.0;
 54 static Imrect *old_er_left = NULL;
 55 static Imrect *old_er_right = NULL;
 56 static Imrect *old_er_mono = NULL;
 57 
 58 void    mono_corners_store(Imrect * er)
 59 {
 60     old_er_mono = er;
 61 }
 62 
 63 void    left_corners_store(Imrect * er)
 64 {
 65     old_er_left = er;
 66 }
 67 
 68 void    right_corners_store(Imrect * er)
 69 {
 70     old_er_right = er;
 71 }
 72 
 73 Imrect *stored_mono_corners(void)
 74 {
 75     return (old_er_mono);
 76 }
 77 
 78 Imrect *stored_left_corners(void)
 79 {
 80     return (old_er_left);
 81 }
 82 
 83 Imrect *stored_right_corners(void)
 84 {
 85     return (old_er_right);
 86 }
 87 
 88 void    temporal_corner_match(Imrect * er, Imrect * old_er, double new_xdisp, double new_ydisp, double new_height, double new_width, double
 89 new_corr, double new_unique, double new_asym)
 90 {
 91     Rindex *fx;
 92     Rindex *old_fx;
 93     Rindex *er_set_findex();
 94     Imregion backward_search_func(Edgel * edgel);
 95     Imregion forward_search_func(Edgel * edgel);
 96     int     type = BACKTEMP;
 97 
 98     if (er == NULL || old_er == NULL)
 99     {
100         error("missing edge structure", non_fatal);
101         return;
102     }
103     if ((fx = prop_get(er->props, ER_TINDEX)) == NULL)
104         if ((fx = er_set_findex(er, ER_TINDEX, (Vec2 * (*) ()) NULL)) == NULL)
105             return;
106     if ((old_fx = prop_get(old_er->props, ER_TINDEX)) == NULL)
107         if ((old_fx = er_set_findex(old_er, ER_TINDEX, (Vec2 * (*) ()) NULL)) == NULL)
108             return;
109 
110     xdisp = new_xdisp;
111     ydisp = new_ydisp;
112     height = new_height;
113     width = new_width;
114     correlate = new_corr;
115     uniqueness = new_unique;
116     asymetry = new_asym;
117 
118     rm_corner_matches(fx, &type);
119     get_corner_matches(fx, old_fx, 0, backward_search_func, (void*(*) ())temp_backward_match);
120     type = FORTEMP;
121     rm_corner_matches(old_fx, &type);
122     get_corner_matches(old_fx, fx, 0, forward_search_func, (void*(*) ())temp_forward_match);
123     set_temporal_corner_matches(fx);
124 }
125 
126 /* BUGFIX JB 22/11/93 was: void   *temp_backward_match(Edgel * edge1,
127  * Edgel * edge2) */
128 void    temp_backward_match(Edgel * edge1, Edgel * edge2)
129 {
130     float   corr;
131 
132     corr = good_corner(edge1, edge2, (float) range, (float) asymetry,
133                        (Imrect *) NULL, (Imrect *) NULL);
134 
135     if (corr > correlate - uniqueness)
136     {
137         Match  *match;
138         Match  *match_alloc();
139 
140         match = match_alloc(CORNER);
141         match->weight = corr;
142         match->to1 = (void *) edge1;
143         match->to2 = (void *) edge2;
144         add_match_to_props(edge1, (void *) match, BACKTEMP);
145     }
146 }
147 
148 
149 void    temp_forward_match(Edgel * edge2, Edgel * edge1)
150 {
151     float   corr;
152 
153     corr = good_corner(edge1, edge2, (float) range, (float) asymetry,
154                        (Imrect *) NULL, (Imrect *) NULL);
155 
156     if (corr > correlate - uniqueness)
157     {
158         Match  *match;
159         Match  *match_alloc();
160 
161         match = match_alloc(CORNER);
162         match->weight = corr;
163         match->to1 = (void *) edge1;
164         match->to2 = (void *) edge2;
165         add_match_to_props(edge2, (void *) match, FORTEMP);
166     }
167 }
168 
169 Imregion forward_search_func(Edgel * edgel)
170 {
171     Imregion tempr = {Imregion_id};
172     Vec2   *rect;
173 
174     rect = &edgel->pos;
175 
176     tempr.lx = (int)floor(rect->el[0] - width + xdisp);
177     tempr.ux = (int)floor(rect->el[0] + width + xdisp);
178     tempr.ly = (int)floor(rect->el[1] - height + ydisp);
179     tempr.uy = (int)floor(rect->el[1] + height + ydisp);
180     return (tempr);
181 }
182 
183 Imregion backward_search_func(Edgel * edgel)
184 {
185     Imregion tempr = {Imregion_id};
186     Vec2   *rect;
187 
188     rect = &edgel->pos;
189 
190     tempr.lx = (int)floor(rect->el[0] - width - xdisp);
191     tempr.ux = (int)floor(rect->el[0] + width - xdisp);
192     tempr.ly = (int)floor(rect->el[1] - height - ydisp);
193     tempr.uy = (int)floor(rect->el[1] + height - ydisp);
194     return (tempr);
195 }
196 
197 void    set_temporal_corner_matches(Rindex * fx)
198 {
199     void   *data = NULL;
200     apply_func_to_windex(fx, (void*(*)())set_temporal_corner_match, data);
201 }
202 
203 
204 void    set_temporal_corner_match(Edgel * edge1, void *data)
205 {
206         List    *matches1, *matches2;
207         Match   *best_match1,*best_match2;
208         Edgel   *edge2;
209 
210 
211     if ((matches1 = (List *) prop_get(edge1->props, BACKTEMP)) == NULL)
212         return;
213     if ((best_match1 = (Match *) matches1->to) == NULL)
214         return;
215 
216     if ((edge2 = (Edgel *) best_match1->to2) == NULL)
217         return;
218 
219     if ((matches2 = (List *) prop_get(edge2->props, FORTEMP)) == NULL)
220         return;
221     if ((best_match2 = (Match *) matches2->to) == NULL)
222         return;
223 
224     if (edge1 == best_match2->to1 && best_match1->weight > correlate)
225     {
226                 matches1->type = GOOD_MATCH;
227                 matches2->type = GOOD_MATCH;
228     }
229 
230 }/* end proc */
231         
232 

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