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

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

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

  1 /**@(#)
  2 **/
  3 /* disp_range.c
  4  * 
  5  * Module for managing current disparity range information.
  6  * 
  7  * Must be revised as appropriate before other stereo matching.
  8  * 
  9  * Can be used in conjuntion with disparity histogram to obtain spatial
 10  * map of disparity ranges directly from the edge data.
 11  * 
 12  * Subsequently provides an local index for disparity range estimates. */
 13 
 14 #include <math.h>
 15 #include <tina/sys.h>
 16 #include <tina/sysfuncs.h>
 17 #include <tina/math.h>
 18 #include <tina/mathfuncs.h>
 19 #include <tina/vision.h>
 20 #include <tina/visionfuncs.h>
 21 
 22 /* Static structure and functions to manage index of allowable
 23  * disparity its size should mirror dimensions of stereo index of the
 24  * left image. */
 25 static Windex *disp_range;
 26 
 27 void    disp_range_set(Windex * range)
 28 {
 29     wx_free(disp_range, rfree);
 30     disp_range = range;
 31 }
 32 
 33 Windex *disp_range_get(void)
 34 {
 35     return (disp_range);
 36 }
 37 
 38 /* Enquire about the disparity range corresponding to image location
 39  * (wrt stereo index image region). */
 40 Bool    disp_range_at_pos2(Vec2 v, double *low_d, double *up_d)
 41 {
 42     Ipos    p = {Ipos_id};
 43     Vec2   *vp;
 44 
 45     if (disp_range == NULL)
 46         return (false);
 47 
 48     p = wx_get_index(disp_range, v);
 49     vp = (Vec2 *) wx_get(disp_range, ipos_y(p), ipos_x(p));
 50 
 51     if (vp == NULL)
 52         return (false);
 53 
 54     *low_d = vec2_x(*vp);
 55     *up_d = vec2_y(*vp);
 56     return (true);
 57 }
 58 
 59 /* Fix the disparity range of the disparity range index. */
 60 void    disp_range_fix_disparity(Windex * w, double low_d, double up_d)
 61 {
 62     Vec2 ***index;
 63     int     i, j;
 64     int     n, m;
 65 
 66     if (w == NULL)
 67         return;
 68 
 69     m = w->m;
 70     n = w->n;
 71     index = (Vec2 ***) w->index;
 72 
 73     for (i = 0; i < m; ++i)
 74         for (j = 0; j < n; ++j)
 75             *index[i][j] = vec2(low_d, up_d);
 76 }
 77 
 78 /* Make a disparity range index corresponding to given region and
 79  * dimensions. */
 80 Windex *disp_range_build(Imregion * region, int m, int n)
 81 {
 82     Windex *w;
 83     Vec2 ***index;
 84     int     i, j;
 85 
 86     if (region == NULL)
 87         return (NULL);
 88 
 89     w = wx_alloc(region, m, n, DISPARITY);
 90     m = w->m;
 91     n = w->n;
 92     index = (Vec2 ***) w->index;
 93 
 94     for (i = 0; i < m; ++i)
 95         for (j = 0; j < n; ++j)
 96             index[i][j] = vec2_make(vec2_zero());
 97     return (w);
 98 }
 99 
100 /* Build a disparity range window for the edgerect uses the region of
101  * the associated stereo index. */
102 Windex *er_disp_range_build(Imrect * er, int m, int n)
103 {
104     Rindex *sx;
105 
106     if (er == NULL)
107         return (NULL);
108 
109     sx = (Rindex *) prop_get(er->props, SINDEX);
110     if (sx == NULL)
111         return (NULL);
112 
113     return (disp_range_build(sx->region, m, n));
114 }
115 

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