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

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

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