Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

template<class DstArrayT, class SrcArrayT, class MaskArrayT, class FunctorT>
void Impala::Core::Array::Pattern::FuncQueueBasedDispatch ( DstArrayT *  dst,
SrcArrayT *  src,
MaskArrayT *  mask,
FunctorT &  functor,
int  connectivity,
int  radiusSqr 
)

Definition at line 124 of file FuncQueueBased.h.

References ArrayCH(), ArrayCPB(), ArrayCW(), FuncQueueBased_ComputeNeighbors(), FuncQueueBased_FillNeighborValues(), Impala::Core::Geometry::PointZ::mX, Impala::Core::Geometry::PointZ::mY, PtrRead(), PtrWrite(), QUEUE, REMOVE, STOP, and WRITE.

Referenced by PatQueueBased().

00126 {
00127     typedef typename DstArrayT::StorType DstStorT;
00128     typedef typename DstArrayT::ArithType DstArithT;
00129     typedef typename SrcArrayT::StorType SrcStorT;
00130     typedef typename SrcArrayT::ArithType SrcArithT;
00131     typedef typename MaskArrayT::StorType MaskStorT;
00132     typedef typename MaskArrayT::ArithType MaskArithT;
00133 
00134     typedef typename FunctorT::PointValueT PointValueT;
00135     typedef typename FunctorT::QT QT; 
00136     typedef typename FunctorT::NeighborsT NeighborsT;
00137     typedef typename FunctorT::VecNeighborsT VecNeighborsT;
00138 
00139     typedef Pattern::FcvArray<Geometry::PointZ> VecPointT;
00140 
00141     QT theQueue;
00142     int imgsizex = ArrayCW(dst);
00143     int imgsizey = ArrayCH(dst);
00144 
00145     // GLOBAL INIT
00146     { // local scope
00147         for (int y=0 ; y<imgsizey ; y++)
00148         {
00149             DstStorT* dPtr = ArrayCPB(dst, 0, y);
00150             SrcStorT* sPtr = ArrayCPB(src, 0, y);
00151             SrcStorT* mPtr = ArrayCPB(mask, 0, y);
00152             for (int x=0 ; x<imgsizex ; x++)
00153             {
00154                 PointValueT vp;
00155                 Geometry::PointZ p(x, y);
00156                 vp.point=p;
00157                 DstArithT d = PtrRead(dPtr, DstArithT());
00158                 SrcArithT s = PtrRead(sPtr, SrcArithT());
00159                 MaskArithT m = PtrRead(mPtr, MaskArithT());
00160                 bool q = functor.GlobalPixelInit(vp, d, s, m);
00161                 if (q)
00162                     theQueue.push(vp); // NOTE: bool ok=queue.insert(vp).second is NEVER false
00163                 PtrWrite(dPtr, d);
00164                 dPtr += DstArrayT::ElemSize();
00165                 sPtr += SrcArrayT::ElemSize();
00166                 mPtr += MaskArrayT::ElemSize();
00167             }
00168         }
00169     } // end local scope
00170 
00171     // NEW: array of points to simplify loop 4/8/... connectivity, now skip (0,0,0)
00172     VecPointT neighborCoordinates;
00173     FuncQueueBased_ComputeNeighbors(neighborCoordinates, connectivity, radiusSqr);
00174 
00175     // clear speedup startpoint for localPixelInit() in large do while loop
00176     //__asm int 3
00177     Geometry::PointZ startpoint(0,0);
00178     VecNeighborsT vecneighbors;
00179 
00180     // LOOP until done with INIT local + PROPAGATE
00181     do
00182     {
00183 
00184         // INIT: FILL QUEUE
00185         { // local scope
00186             bool freshstart = functor.WantFreshStartLocalPixelInit();
00187             if (freshstart)
00188             {
00189                 startpoint.mX=0;
00190                 startpoint.mY=0;
00191             }
00192             bool continueloop=true;
00193             int x=startpoint.mX;
00194             int y=startpoint.mY;
00195             bool wenttonewpoint=false;
00196             if (wenttonewpoint)
00197                 y=0;
00198             for (; y<imgsizey; y++)
00199             {
00200                 if (wenttonewpoint)
00201                     x=0;
00202                 DstStorT* dPtr = ArrayCPB(dst, x, y);
00203                 SrcStorT* sPtr = ArrayCPB(src, x, y);
00204                 SrcStorT* mPtr = ArrayCPB(mask, x, y);
00205                 for (; x<imgsizex; x++)
00206                 {
00207                     if (!wenttonewpoint)
00208                     {
00209                         wenttonewpoint=true;
00210                     }
00211                     PointValueT vp;
00212                     vp.point.mX = x;
00213                     vp.point.mY = y;
00214                     DstArithT d = PtrRead(dPtr, DstArithT());
00215                     SrcArithT s = PtrRead(sPtr, SrcArithT());
00216                     MaskArithT m = PtrRead(mPtr, MaskArithT());
00217                     bool q = functor.LocalPixelInit(vp, d, s, m, continueloop);
00218                     if (q)
00219                         theQueue.push(vp); // NOTE: bool ok=queue.insert(vp).second is NEVER false
00220                     PtrWrite(dPtr, d);
00221                     if (!continueloop)
00222                         break;
00223                     dPtr += DstArrayT::ElemSize();
00224                     sPtr += SrcArrayT::ElemSize();
00225                     mPtr += MaskArrayT::ElemSize();
00226                 }
00227                 if (!continueloop)
00228                     break;
00229             }
00230             // remember startpoint for next time
00231             startpoint.mX = x;
00232             startpoint.mY = y;
00233 
00234         } // end local scope
00235 
00236         // PROPAGATION
00237         { // local scope
00238             while (!theQueue.empty())
00239             { // line 4
00240                 PointValueT vp(theQueue.top());
00241                 theQueue.pop(); // line 5
00242 
00243                 // give functor first=this=center data
00244                 { // local scope
00245                     int tempx=vp.point.mX, tempy=vp.point.mY;
00246                     DstStorT* dPtr = ArrayCPB(dst, tempx, tempy);
00247                     SrcStorT* sPtr = ArrayCPB(src, tempx, tempy);
00248                     SrcStorT* mPtr = ArrayCPB(mask, tempx, tempy);
00249                     functor.First(vp, PtrRead(dPtr, DstArithT()),
00250                                   PtrRead(sPtr, SrcArithT()),
00251                                   PtrRead(mPtr, MaskArithT()));
00252                 } // local scope
00253 
00254                 // give functor the neighbour pixels
00255                 // NOT yet optimized for iterator++ or LUT for coords
00256                 // NEW: use vector to pass neighbors, here be compatible with sequential code
00257                 { //local scope
00258                     FuncQueueBased_FillNeighborValues(dst, src, mask, vp.point,
00259                                                       neighborCoordinates,
00260                                                       vecneighbors,
00261                                                       NeighborsT());
00262                     // CALCULATE put functor to work, might be removed by first call to getdata()
00263                     functor.Calculate(vecneighbors);
00264                 } //local scope
00265 
00266 
00267 
00268                 // read out phase, might have many values of different types
00269                 { // local scope
00270                     QAction action;
00271                     while ((action=functor.Result())!=STOP)
00272                     { 
00273                         switch (action)
00274                         {
00275                         case QUEUE:
00276                             { // local scope
00277                                 PointValueT vp;
00278                                 functor.GetItemToQueue(vp);
00279                                 theQueue.push(vp); 
00280                             } // local scope
00281                             break;
00282                         case REMOVE:
00283                             { // local scope
00284                                 PointValueT low, high;
00285                                 functor.GetItemToRemove(low, high);
00286                                 typename QT::iterator lowiter=theQueue.lower_bound(low);
00287                                 typename QT::iterator highiter=theQueue.after_upper_bound(high);
00288                                 for (typename QT::iterator iter=lowiter; iter!=highiter; iter++)
00289                                 {
00290                                     bool k=functor.KillThisOne(*iter);
00291                                     if (k)
00292                                     {
00293                                         theQueue.erase(iter);
00294                                         break;
00295                                     } 
00296                                 }
00297                             } // local scope
00298                             break;
00299                         case WRITE:
00300                             { // local scope
00301                                 Geometry::PointZ point; 
00302                                 DstArithT arith;
00303                                 functor.GetItemToWrite(point, arith);
00304                                 DstStorT* dPtr = ArrayCPB(dst, point.mX, point.mY);
00305                                 PtrWrite(dPtr, arith);
00306                             } // local scope
00307                             break;
00308                         default:
00309                             std::cerr << "ERROR switch (action) default:" << std::endl;
00310                         }; // switch (action)
00311                     } // while ((action=functor.Result())!=STOP) 
00312                 } // local scope
00313             } // while (!theQueue.empty()) 
00314         } // end local scope PROPAGATION
00315     }
00316     while (functor.WantAnotherLoop());
00317 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:01:40 2010 for ImpalaSrc by  doxygen 1.5.1