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

Linux Cross Reference
Tina5/tina-libs/tina/vision/visMatch_ewta.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_ewta.c,v $
 23  * Date    :  $Date: 2003/10/06 12:29:48 $
 24  * Version :  $Revision: 1.3 $
 25  * CVS Id  :  $Id: visMatch_ewta.c,v 1.3 2003/10/06 12:29:48 neil Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes :
 30  * 
 31  * Generic stereo functions for performing winner take all choices.
 32  * 
 33  * Includes WTA schemes for implementing either uniqueness or ordering. 
 34  *
 35  *********
 36 */
 37 
 38 #include "visMatch_ewta.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/geometry/geomDef.h>
 50 #include <tina/geometry/geomPro.h>
 51 #include <tina/vision/vis_MatchDef.h>
 52 #include <tina/vision/vis_MatchPro.h>
 53 
 54 /* Test if 2 matches are unique wrt uniquely labeled regular
 55  * sub-strings. */
 56 /* ARGSUSED quieten lint */
 57 Bool    matches_not_unique(Match * m1, int type, Match * m2)
 58 
 59 /* unused */
 60 
 61 {
 62     int     s1_id, s2_id;
 63 
 64     if (m1->to1 == m2->to1 || m1->to2 == m2->to2)
 65         return (true);
 66 
 67     s1_id = (int) prop_get(((Tstring *) m1->to1)->props, STRING);
 68     s2_id = (int) prop_get(((Tstring *) m2->to1)->props, STRING);
 69 
 70     if (s1_id == s2_id)
 71         return (true);
 72 
 73     s1_id = (int) prop_get(((Tstring *) m1->to2)->props, STRING);
 74     s2_id = (int) prop_get(((Tstring *) m2->to2)->props, STRING);
 75 
 76     if (s1_id == s2_id)
 77         return (true);
 78 
 79     return (false);
 80 }
 81 
 82 /* Test if 2 matches preserve order along the x direction. */
 83 /* ARGSUSED quieten lint */
 84 Bool    matches_not_ordered(Match * m1, int type, Match * m2)
 85 
 86 /* unused */
 87 
 88 {
 89     double  x11, x12, x21, x22;
 90     Vec2    v = {Vec2_id};
 91 
 92     v = str2_centroid((Tstring *) m1->to1);
 93     x11 = vec2_x(v);
 94     v = str2_centroid((Tstring *) m1->to2);
 95     x12 = vec2_x(v);
 96     v = str2_centroid((Tstring *) m2->to1);
 97     x21 = vec2_x(v);
 98     v = str2_centroid((Tstring *) m2->to2);
 99     x22 = vec2_x(v);
100 
101     if ((x11 < x12) != (x21 < x22))
102         return (true);
103 
104     return (false);
105 }
106 
107 /* Apply WTA scheme to matches associated with a single raster.
108  * 
109  * WTA allows strongest matches to be chosen and competitors to be
110  * eliminated.
111  * 
112  * Scheme implemeted here does not properly allow for the fact that the
113  * same sub-string can be indexed on different rows. */
114 void    choose_wta(List * left, double (*cost_func) ( /* ??? */ ), Bool(*compat_func) ( /* ??? */ ))
115 /* epipolar edge list */
116 
117 
118 
119 {
120     List   *mlist = NULL;
121     List   *ptr;
122     List   *next;
123     List   *choose = NULL;
124 
125     list_apply_func(left, es_add_to_mlist, (void *) &mlist);
126     mlist = list_reverse(sort_list(mlist, cost_func, NULL));
127     mlist_set_supp_type(mlist, BAD_MATCH);
128 
129     for (ptr = mlist; ptr != NULL; ptr = next)
130     {
131         Match  *m = (Match *) ptr->to;
132 
133         next = ptr->next;
134         choose = link_addtostart((List *) choose, ptr);
135         next = list_rm_links_on_func(next, compat_func, (void *) m);
136     }
137     mlist_set_supp_type(choose, GOOD_MATCH);
138     list_rm_links(mlist);
139 }
140 
141 /* Apply wta scheme to all the rasters in the edgerect. */
142 void    choose_wta_matches(Imrect * er, double (*cost_func) ( /* ??? */ ), Bool(*compat_func) ( /* ??? */ ))
143 /* left edgerect */
144 
145 
146 
147 {
148     Rindex *sx;
149     int     ly, uy, i;
150 
151     if (er == NULL || (sx = (Rindex *) prop_get(er->props, SINDEX)) == NULL)
152         return;
153 
154     ly = sx->region->ly;
155     uy = sx->region->uy;
156 
157     for (i = ly; i < uy; ++i)
158         choose_wta((List *) sx->index[i], cost_func, compat_func);
159 }
160 

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