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

Linux Cross Reference
Tina4/src/vision/stereo/choose_wta.c

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

  1 /**@(#)
  2 **/
  3 /* choose_wta.c
  4  * 
  5  * Generic stereo functions for performing winner take all choices.
  6  * 
  7  * Includes WTA schemes for implementing either uniqueness or ordering. */
  8 
  9 #include <math.h>
 10 #include <tina/sys.h>
 11 #include <tina/sysfuncs.h>
 12 #include <tina/math.h>
 13 #include <tina/mathfuncs.h>
 14 #include <tina/vision.h>
 15 #include <tina/visionfuncs.h>
 16 
 17 /* Test if 2 matches are unique wrt uniquely labeled regular
 18  * sub-strings. */
 19 /* ARGSUSED quieten lint */
 20 Bool    matches_not_unique(Match * m1, int type, Match * m2)
 21 
 22 /* unused */
 23 
 24 {
 25     int     s1_id, s2_id;
 26 
 27     if (m1->to1 == m2->to1 || m1->to2 == m2->to2)
 28         return (true);
 29 
 30     s1_id = (int) prop_get(((Tstring *) m1->to1)->props, STRING);
 31     s2_id = (int) prop_get(((Tstring *) m2->to1)->props, STRING);
 32 
 33     if (s1_id == s2_id)
 34         return (true);
 35 
 36     s1_id = (int) prop_get(((Tstring *) m1->to2)->props, STRING);
 37     s2_id = (int) prop_get(((Tstring *) m2->to2)->props, STRING);
 38 
 39     if (s1_id == s2_id)
 40         return (true);
 41 
 42     return (false);
 43 }
 44 
 45 /* Test if 2 matches preserve order along the x direction. */
 46 /* ARGSUSED quieten lint */
 47 Bool    matches_not_ordered(Match * m1, int type, Match * m2)
 48 
 49 /* unused */
 50 
 51 {
 52     double  x11, x12, x21, x22;
 53     Vec2    v = {Vec2_id};
 54 
 55     v = str2_centroid((Tstring *) m1->to1);
 56     x11 = vec2_x(v);
 57     v = str2_centroid((Tstring *) m1->to2);
 58     x12 = vec2_x(v);
 59     v = str2_centroid((Tstring *) m2->to1);
 60     x21 = vec2_x(v);
 61     v = str2_centroid((Tstring *) m2->to2);
 62     x22 = vec2_x(v);
 63 
 64     if ((x11 < x12) != (x21 < x22))
 65         return (true);
 66 
 67     return (false);
 68 }
 69 
 70 /* Apply WTA scheme to matches associated with a single raster.
 71  * 
 72  * WTA allows strongest matches to be chosen and competitors to be
 73  * eliminated.
 74  * 
 75  * Scheme implemeted here does not properly allow for the fact that the
 76  * same sub-string can be indexed on different rows. */
 77 void    choose_wta(List * left, double (*cost_func) ( /* ??? */ ), Bool(*compat_func) ( /* ??? */ ))
 78 /* epipolar edge list */
 79 
 80 
 81 
 82 {
 83     List   *mlist = NULL;
 84     List   *ptr;
 85     List   *next;
 86     List   *choose = NULL;
 87 
 88     list_apply_func(left, es_add_to_mlist, (void *) &mlist);
 89     mlist = list_reverse(sort_list(mlist, cost_func, NULL));
 90     mlist_set_supp_type(mlist, BAD_MATCH);
 91 
 92     for (ptr = mlist; ptr != NULL; ptr = next)
 93     {
 94         Match  *m = (Match *) ptr->to;
 95 
 96         next = ptr->next;
 97         choose = link_addtostart((List *) choose, ptr);
 98         next = list_rm_links_on_func(next, compat_func, (void *) m);
 99     }
100     mlist_set_supp_type(choose, GOOD_MATCH);
101     list_rm_links(mlist);
102 }
103 
104 /* Apply wta scheme to all the rasters in the edgerect. */
105 void    choose_wta_matches(Imrect * er, double (*cost_func) ( /* ??? */ ), Bool(*compat_func) ( /* ??? */ ))
106 /* left edgerect */
107 
108 
109 
110 {
111     Rindex *sx;
112     int     ly, uy, i;
113 
114     if (er == NULL || (sx = (Rindex *) prop_get(er->props, SINDEX)) == NULL)
115         return;
116 
117     ly = sx->region->ly;
118     uy = sx->region->uy;
119 
120     for (i = ly; i < uy; ++i)
121         choose_wta((List *) sx->index[i], cost_func, compat_func);
122 }
123 

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