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

Linux Cross Reference
Tina6/tina-libs/tina/vision/visMatch_cstereo.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_cstereo.c,v $
 27  * Date    :  $Date: 2005/02/07 23:27:41 $
 28  * Version :  $Revision: 1.4 $
 29  * CVS Id  :  $Id: visMatch_cstereo.c,v 1.4 2005/02/07 23:27:41 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "visMatch_cstereo.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 disp, lowd, upd, width, correlate, uniqueness;
 53 static double asymetry = 0.85, range = 3.0;
 54 static Imrect *im_left, *im_right;      /* Defined in
 55                                          * corner/t_mat_cnr.c */
 56 
 57 void    stereo_corner_match(Imrect *im_left_new, Imrect *im_right_new,
 58        Imrect *left_er,Imrect *right_er,
 59        double new_disp, double new_lowd, double new_upd,
 60        double new_width, double new_corr, double new_unique, double new_asym)
 61 {
 62     Rindex *fxl;
 63     Rindex *fxr;
 64     Imregion left_search_func(Edgel * edgel);
 65     Imregion right_search_func(Edgel * edgel);
 66     Rindex *er_set_findex();
 67     int     type = MLIST;
 68     Vec2   *rectpos(Edgel * edgel);
 69 
 70     if (left_er == NULL || right_er == NULL)
 71     {
 72         error("no edge structure", non_fatal);
 73         return;
 74     }
 75     im_left = im_left_new;
 76     im_right = im_right_new;
 77 
 78     if (im_left == NULL || im_right == NULL)
 79     {
 80         error("no images", non_fatal);
 81         return;
 82     }
 83     if ((fxl = prop_get(left_er->props, ER_FINDEX)) == NULL)
 84         if ((fxl = er_set_findex(left_er, ER_FINDEX, rectpos)) == NULL)
 85             return;
 86     if ((fxr = prop_get(right_er->props, ER_FINDEX)) == NULL)
 87         if ((fxr = er_set_findex(right_er, ER_FINDEX, rectpos)) == NULL)
 88             return;
 89 
 90     disp = new_disp;
 91     lowd = new_lowd * left_er->width;
 92     upd = new_upd * left_er->width;
 93     width = new_width;
 94     correlate = new_corr;
 95     uniqueness = new_unique;
 96     asymetry = new_asym;
 97 
 98     rm_corner_matches(fxl, &type);
 99     get_corner_matches(fxl, fxr, RECTPOS, left_search_func, stereo_left_match);
100     rm_corner_matches(fxr, &type);
101     get_corner_matches(fxr, fxl, RECTPOS, right_search_func, stereo_right_match);
102     set_stereo_corner_matches(fxl);
103 }
104 
105 Vec2   *rectpos(Edgel * edgel)
106 {
107     return ((Vec2 *) prop_get(edgel->props, RECTPOS));
108 }
109 
110 void   *stereo_left_match(Edgel * edgell, Edgel * edgelr)
111 {
112     float   corr;
113 
114     corr = good_corner(edgell, edgelr, (float) range, (float) asymetry, im_left, im_right);
115 
116     if (corr > correlate - uniqueness)
117     {
118         Match  *match;
119         Match  *match_alloc();
120 
121         match = match_alloc(CORNER);
122         match->weight = corr;
123         match->to1 = (void *) edgell;
124         match->to2 = (void *) edgelr;
125         add_match_to_props(edgell, (void *) match, MLIST);
126     }
127     /* Return may be used in future */
128     return NULL;
129 }
130 
131 void   *stereo_right_match(Edgel * edgelr, Edgel * edgell)
132 {
133     float   corr;
134 
135     corr = good_corner(edgelr, edgell, (float) range, (float) asymetry, im_right, im_left);
136 
137     if (corr > correlate - uniqueness)
138     {
139         Match  *match;
140         Match  *match_alloc();
141 
142         match = match_alloc(CORNER);
143         match->weight = corr;
144         match->to1 = (void *) edgell;
145         match->to2 = (void *) edgelr;
146         add_match_to_props(edgelr, (void *) match, MLIST);
147     }
148     /* Return may be used in future */
149     return NULL;
150 }
151 
152 Imregion left_search_func(Edgel * edgel)
153 {
154     Imregion stereor = {Imregion_id};
155     Vec2   *rect;
156 
157     rect = (Vec2 *) prop_get(edgel->props, RECTPOS);
158     if (rect == NULL)
159         rect = &edgel->pos;
160 
161     stereor.lx = (int)floor(rect->el[0] + lowd + disp);
162     stereor.ux = (int)floor(rect->el[0] + upd + disp);
163     stereor.ly = (int)floor(rect->el[1] - width);
164     stereor.uy = (int)floor(rect->el[1] + width);
165     return (stereor);
166 }
167 
168 Imregion right_search_func(Edgel * edgel)
169 {
170     Imregion stereor = {Imregion_id};
171     Vec2   *rect;
172 
173     rect = (Vec2 *) prop_get(edgel->props, RECTPOS);
174     if (rect == NULL)
175         rect = &edgel->pos;
176 
177     stereor.lx = (int)floor(rect->el[0] - upd - disp);
178     stereor.ux = (int)floor(rect->el[0] - lowd - disp);
179     stereor.ly = (int)floor(rect->el[1] - width);
180     stereor.uy = (int)floor(rect->el[1] + width);
181     return (stereor);
182 }
183 
184 void    set_stereo_corner_matches(Rindex * fxl)
185 {
186     void   *data = NULL;
187 
188     apply_func_to_windex(fxl, (void *(*) ()) set_stereo_corner_match, data);
189 }
190 
191 void    rm_stereo_corner_matches(Rindex * fx)
192 {
193     apply_func_to_windex(fx, (void *(*) ()) rm_match_from_props, (void *) MLIST);
194 }
195 
196 /* ARGSUSED quieten lint */
197 /* BUGFIX: JB 22/11/93 was void   *set_stereo_corner_match(Edgel *
198  * ledge, void *data) */
199 void    set_stereo_corner_match(Edgel * ledge, void *data /* unused */ )
200 {
201     Edgel  *redge;
202     List   *left_matches;
203     List   *right_matches;
204     Match  *best_left_match;
205     Match  *next_best_left;
206     Match  *best_right_match;
207     Match  *next_best_right;
208 
209     if ((left_matches = (List *) prop_get(ledge->props, MLIST)) == NULL)
210         return;
211     if ((best_left_match = (Match *) left_matches->to) == NULL)
212         return;
213 
214     if ((redge = (Edgel *) best_left_match->to2) == NULL)
215         return;
216 
217     if ((right_matches = (List *) prop_get(redge->props, MLIST)) == NULL)
218         return;
219     if ((best_right_match = (Match *) right_matches->to) == NULL)
220         return;
221 
222     if (ledge == best_right_match->to1 && best_left_match->weight > correlate)
223     {
224         left_matches->type = FIXED_MATCH;
225         right_matches->type = FIXED_MATCH;
226         if (left_matches->next != NULL && (next_best_left = (Match *) left_matches->next->to) != NULL)
227         {
228             if ((best_left_match->weight - next_best_left->weight) < uniqueness)
229             {
230                 left_matches->type = GOOD_MATCH;
231                 right_matches->type = GOOD_MATCH;
232             }
233         }
234         if (right_matches->next != NULL && (next_best_right = (Match *) right_matches->next->to) != NULL)
235         {
236             if ((best_right_match->weight - next_best_right->weight) < uniqueness)
237             {
238                 left_matches->type = GOOD_MATCH;
239                 right_matches->type = GOOD_MATCH;
240             }
241         }
242     }
243 }
244 

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