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

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

Definition at line 322 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.

00324 {
00325     typedef typename DstArrayT::StorType DstStorT;
00326     typedef typename DstArrayT::ArithType DstArithT;
00327     typedef typename SrcArrayT::StorType SrcStorT;
00328     typedef typename SrcArrayT::ArithType SrcArithT;
00329 
00330     typedef typename FunctorT::PointValueT PointValueT;
00331     typedef typename FunctorT::QT QT; 
00332     typedef typename FunctorT::NeighborsT NeighborsT;
00333     typedef typename FunctorT::VecNeighborsT VecNeighborsT;
00334 
00335     typedef Pattern::FcvArray<Geometry::PointZ> VecPointT;
00336 
00337     QT theQueue;
00338     int imgsizex = ArrayCW(dst);
00339     int imgsizey = ArrayCH(dst);
00340 
00341     // GLOBAL INIT
00342     { // local scope
00343         for (int y=0 ; y<imgsizey ; y++)
00344         {
00345             DstStorT* dPtr = ArrayCPB(dst, 0, y);
00346             SrcStorT* sPtr = ArrayCPB(src, 0, y);
00347             for (int x=0 ; x<imgsizex ; x++)
00348             {
00349                 PointValueT vp;
00350                 Geometry::PointZ p(x, y);
00351                 vp.point=p;
00352                 DstArithT d = PtrRead(dPtr, DstArithT());
00353                 SrcArithT s = PtrRead(sPtr, SrcArithT());
00354                 bool q = functor.GlobalPixelInit(vp, d, s);
00355                 if (q)
00356                     theQueue.push(vp); // NOTE: bool ok=queue.insert(vp).second is NEVER false
00357                 PtrWrite(dPtr, d);
00358                 dPtr += DstArrayT::ElemSize();
00359                 sPtr += SrcArrayT::ElemSize();
00360             }
00361         }
00362     } // end local scope
00363 
00364     // NEW: array of points to simplify loop 4/8/... connectivity, now skip (0,0,0)
00365     VecPointT neighborCoordinates;
00366     FuncQueueBased_ComputeNeighbors(neighborCoordinates, connectivity, radiusSqr);
00367 
00368     // clear speedup startpoint for localPixelInit() in large do while loop
00369     //__asm int 3
00370     Geometry::PointZ startpoint(0,0);
00371     VecNeighborsT vecneighbors;
00372 
00373     // LOOP until done with INIT local + PROPAGATE
00374     do
00375     {
00376         // INIT: FILL QUEUE
00377         { // local scope
00378             bool freshstart = functor.WantFreshStartLocalPixelInit();
00379             if (freshstart)
00380             {
00381                 startpoint.mX=0;
00382                 startpoint.mY=0;
00383             }
00384             bool continueloop=true;
00385             int x=startpoint.mX;
00386             int y=startpoint.mY;
00387             bool wenttonewpoint=false;
00388             if (wenttonewpoint)
00389                 y=0;
00390             for (; y<imgsizey; y++)
00391             {
00392                 if (wenttonewpoint)
00393                     x=0;
00394                 DstStorT* dPtr = ArrayCPB(dst, x, y);
00395                 SrcStorT* sPtr = ArrayCPB(src, x, y);
00396                 for (; x<imgsizex; x++)
00397                 {
00398                     if (!wenttonewpoint)
00399                     {
00400                         wenttonewpoint=true;
00401                     }
00402                     PointValueT vp;
00403                     vp.point.mX=x;
00404                     vp.point.mY=y;
00405                     DstArithT d = PtrRead(dPtr, DstArithT());
00406                     SrcArithT s = PtrRead(sPtr, SrcArithT());
00407                     bool q = functor.LocalPixelInit(vp, d, s, continueloop);
00408                     if (q)
00409                         theQueue.push(vp); // NOTE: bool ok=queue.insert(vp).second is NEVER false
00410                     PtrWrite(dPtr, d);
00411                     if (!continueloop)
00412                         break;
00413                     dPtr += DstArrayT::ElemSize();
00414                     sPtr += SrcArrayT::ElemSize();
00415                 }
00416                 if (!continueloop)
00417                     break;
00418             }
00419             // remember startpoint for next time
00420             startpoint.mX=x;
00421             startpoint.mY=y;
00422 
00423         } // end local scope
00424 
00425         // PROPAGATION
00426         { // local scope
00427             while (!theQueue.empty())
00428             { // line 4
00429                 PointValueT vp(theQueue.top());
00430                 theQueue.pop(); // line 5
00431 
00432                 // give functor first=this=center data
00433                 { // local scope
00434                     int tempx=vp.point.mX, tempy=vp.point.mY;
00435                     DstStorT* dPtr = ArrayCPB(dst, tempx, tempy);
00436                     SrcStorT* sPtr = ArrayCPB(src, tempx, tempy);
00437                     functor.First(vp, PtrRead(dPtr, DstArithT()),
00438                                   PtrRead(sPtr, SrcArithT()));
00439                 } // local scope
00440 
00441                 // give functor the neighbour pixels
00442                 // NOT yet optimized for iterator++ or LUT for coords
00443                 // NEW: use vector to pass neighbors, here be compatible with sequential code
00444                 { //local scope
00445                     FuncQueueBased_FillNeighborValues(dst, src, vp.point,
00446                                                       neighborCoordinates,
00447                                                       vecneighbors,
00448                                                       NeighborsT());
00449                     // CALCULATE put functor to work, might be removed by first call to getdata()
00450                     functor.Calculate(vecneighbors);
00451                 } //local scope
00452 
00453 
00454 
00455                 // read out phase, might have many values of different types
00456                 { // local scope
00457                     QAction action;
00458                     while ((action=functor.Result())!=STOP)
00459                     { 
00460                         switch (action)
00461                         {
00462                         case QUEUE:
00463                             { // local scope
00464                                 PointValueT vp;
00465                                 functor.GetItemToQueue(vp);
00466                                 theQueue.push(vp); 
00467                             } // local scope
00468                             break;
00469                         case REMOVE:
00470                             { // local scope
00471                                 PointValueT low, high;
00472                                 functor.GetItemToRemove(low, high);
00473                                 typename QT::iterator lowiter=theQueue.lower_bound(low);
00474                                 typename QT::iterator highiter=theQueue.after_upper_bound(high);
00475                                 for (typename QT::iterator iter=lowiter; iter!=highiter; iter++)
00476                                 {
00477                                     bool k=functor.KillThisOne(*iter);
00478                                     if (k)
00479                                     {
00480                                         theQueue.erase(iter);
00481                                         break;
00482                                     } 
00483                                 }
00484                             } // local scope
00485                             break;
00486                         case WRITE:
00487                             { // local scope
00488                                 Geometry::PointZ point; 
00489                                 DstArithT arith;
00490                                 functor.GetItemToWrite(point, arith);
00491                                 DstStorT* dPtr = ArrayCPB(dst, point.mX, point.mY);
00492                                 PtrWrite(dPtr, arith);
00493                             } // local scope
00494                             break;
00495                         default:
00496                             std::cerr << "ERROR switch (action) default:" << std::endl;
00497                         }; // switch (action)
00498                     } // while ((action=functor.Result())!=STOP) 
00499                 } // local scope
00500             } // while (!theQueue.empty()) 
00501         } // end local scope PROPAGATION
00502     }
00503     while (functor.WantAnotherLoop());
00504 }

Here is the call graph for this function:


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