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

Linux Cross Reference
Tina5/tina-libs/tina/vision/visCorr_disp.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/visCorr_disp.c,v $
 23  * Date    :  $Date: 2004/08/04 15:07:47 $
 24  * Version :  $Revision: 1.1 $
 25  * CVS Id  :  $Id: visCorr_disp.c,v 1.1 2004/08/04 15:07:47 paul Exp $
 26  *
 27  * Author : Simon Crossley (see thesis Univ. Sheffield U.K.), NAT.
 28  */
 29 /**
 30  * @file stereo correlation algorithms
 31  * @brief Routines to enforce unique matching on disparity values at edges. 
 32  *
 33  *********
 34 */
 35 
 36 #include "visCorr_disp.h"
 37 
 38 #include <math.h>
 39 #include <tina/sys/sysDef.h>
 40 #include <tina/sys/sysPro.h>
 41 #include <tina/math/mathDef.h>
 42 #include <tina/math/mathPro.h>
 43 #include <tina/geometry/geomDef.h>
 44 #include <tina/geometry/geomPro.h>
 45 #include <tina/image/imgDef.h>
 46 #include <tina/image/imgPro.h>
 47 #include <tina/vision/visDef.h>
 48 #include <tina/vision/visPro.h>
 49 
 50 #include "vis_CorrDef.h"
 51 #include "vis_CorrPro.h"
 52 
 53 void cross_ref_check(Edgel *edgel1, int type, int prop_type)
 54 {
 55   Edgel *edgel2;
 56   Match *match1, *match2;
 57 
 58   if (type != EDGE || edgel1 == NULL)
 59     return;
 60 
 61   /* get the edgel that it matched to */
 62   match1 = (Match *)prop_get(edgel1->props, MATCH);
 63   if (match1 == NULL) return;
 64   
 65   edgel2 = (Edgel *)match1->to2;
 66   
 67   /* check in opposite direction for aggreement */
 68   match2 = (Match *)prop_get(edgel2->props, MATCH);
 69   if (match2 == NULL || edgel1 != (Edgel *)match2->to2)
 70     edgel1->props = proplist_rm(edgel1->props, MATCH);
 71 }
 72 
 73 /* edgel based uniqueness checking */
 74 
 75 Imrect *edge_im_disp_merge(Imrect *leftdisp_im, Imrect *leftedge_im,
 76                            Imrect *rightedge_im)
 77 {
 78   Imrect *outdisp;
 79   int x, y;
 80   Edgel *ledgel;
 81   Match *matchl;
 82 
 83   if (leftdisp_im == NULL || leftedge_im == NULL || rightedge_im == NULL)
 84     return(NULL);
 85     
 86   outdisp = im_alloc(leftdisp_im->height, leftdisp_im->width,
 87                      leftdisp_im->region, float_v);
 88 
 89   FOR_IM (outdisp->region, y, x)
 90     IM_FLOAT(outdisp, y, x) = NO_DISP;
 91 
 92   /* cross-reference the edge pointers for uniqueness */
 93 
 94   er_apply_to_all_edges(leftedge_im, cross_ref_check, (void *)MATCH);
 95   er_apply_to_all_edges(rightedge_im, cross_ref_check, (void *)MATCH);
 96 
 97   FOR_IM(leftdisp_im->region, y, x)
 98     {
 99       if (IM_FLOAT(leftdisp_im, y, x) == NO_DISP)
100         continue;
101 
102       /* get ledgel associated with left disparity */
103       ledgel = (Edgel *)IM_PTR(leftedge_im, y, x);
104       if (ledgel == NULL) continue;
105       
106       /* check for an edgel match */
107       matchl = (Match *)prop_get(ledgel->props, MATCH);
108       if (matchl == NULL) continue;
109       
110       IM_FLOAT(outdisp, y, x) = IM_FLOAT(leftdisp_im, y, x);
111     }
112   
113   return(outdisp);
114 }
115 
116 /* imf_disp_conv produces the corresponding right-handed
117    disparity image, from the given left-handed disparity
118    image, which exists over the given right_im roi */
119 
120 Imrect *imf_disp_conv(Imrect *leftdisp_im, Imrect *right_im)
121 {
122   Imrect *rightdisp_im;
123   int x, y, rx;
124   float disp;
125 
126   /* if there is no boot-strap disp image... */
127   if (leftdisp_im == NULL) return(NULL);
128 
129   rightdisp_im = im_alloc(right_im->height, right_im->width,
130                           right_im->region, float_v);
131   FOR_IM(rightdisp_im->region, y, x)
132     IM_FLOAT(rightdisp_im, y, x) = NO_DISP;
133 
134   FOR_IM(leftdisp_im->region, y, x)
135     {
136       disp = IM_FLOAT(leftdisp_im, y, x);
137       if (disp == NO_DISP)
138         continue;
139 
140       /* no need for sub-pix accuracy here */
141       rx = tina_int(disp) + x;
142       if (roi_inregion(rightdisp_im->region, rx, y))
143         IM_FLOAT(rightdisp_im, y, rx) = -disp;
144     }
145   
146   return(rightdisp_im);
147 }
148 

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