template<class DstArrayT, class Src1ArrayT, class Src2ArrayT>
Definition at line 219 of file QbWatershed.h. References Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::actionsout, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::arith, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::center, Impala::Core::Array::Trait::CONTOURVAL, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::cost, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::costImage, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::curdist, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::distImage, Impala::Core::Array::Pattern::FcvArray< T >::empty(), Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::globalOrderCounter, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::h, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::img, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::index, Impala::Core::Array::Trait::INITVAL, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::labelcode, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::lastDist, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::localOrderCounter, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::mask, Impala::Core::Array::Trait::MASKVAL, Impala::Core::Geometry::PointZ::mX, Impala::Core::Geometry::PointZ::mY, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::neighboursout, Impala::Core::Array::Trait::QbWatershed< DstArrayT, Src1ArrayT, Src2ArrayT >::structPointValue::point, Impala::Core::Array::Pattern::QUEUE, Impala::Core::Array::Pattern::FcvArray< T >::size(), Impala::Core::Array::Pattern::WRITE, and Impala::Core::Array::Trait::WSHEDVAL. 00220 { 00221 index=0; // for result() 00222 neighboursout.clear(); 00223 actionsout.clear(); 00224 00225 int i; 00226 bool step2=false; 00227 //here starts the propagation part (in algorithm point 2 to 4) 00228 if (!neighboursin.empty() && (center.arith == CONTOURVAL)) { 00229 // here we increment curDist, every time a new layer of pixels is 00230 // gonna be processed. 00231 if (center.lastDist > curdist) { 00232 curdist++; 00233 } 00234 00235 step2=true; 00236 for (i=0; i<neighboursin.size(); i++) { 00237 NeighborsT val=neighboursin[i]; 00238 PointValueT neighbor; 00239 neighbor.point=val.point; 00240 neighbor.arith=val.arith; 00241 neighbor.img=val.img; 00242 neighbor.mask=val.mask; 00243 neighbor.cost=costImage(neighbor.point.mX, neighbor.point.mY); 00244 int dn= distImage(neighbor.point.mX, neighbor.point.mY); 00245 if ((neighbor.arith > 0 || neighbor.arith == WSHEDVAL 00246 || neighbor.arith == CONTOURVAL)) { //not labeled yet 00247 if (neighbor.arith > 0) { 00248 if (center.arith == WSHEDVAL 00249 || center.arith == CONTOURVAL ) { 00250 center.arith = neighbor.arith; 00251 neighboursout.push_back(center); 00252 actionsout.push_back(Pattern::WRITE); 00253 } else if (center.arith != neighbor.arith) { 00254 center.arith = WSHEDVAL; 00255 neighboursout.push_back(center); 00256 actionsout.push_back(Pattern::WRITE); 00257 } 00258 } else if (center.arith < 0 && center.img == h) { 00259 center.arith = WSHEDVAL; 00260 neighboursout.push_back(center); 00261 actionsout.push_back(Pattern::WRITE); 00262 } 00263 } 00264 else if((neighbor.arith <0 && neighbor.img == h) 00265 && distImage(neighbor.point.mX, neighbor.point.mY) == 0) { 00266 // nu aici trebuie incrementat current distance, sau in orice 00267 // caz nu de fiecare data cumva trebuie sa semnalizez cind 00268 // iau de pe stiva, primul pixel pus aici 00269 // pot folosi de exemplu cimputl cost... 00270 distImage(neighbor.point.mX, neighbor.point.mY)=curdist+1; 00271 neighbor.lastDist=distImage(neighbor.point.mX, neighbor.point.mY); 00272 costImage(neighbor.point.mX, neighbor.point.mY) = -1;// curdist+2; 00273 neighbor.localOrderCounter=globalOrderCounter++; // for equal 00274 // values be a FIFO=QUEUE 00275 neighbor.cost=costImage(neighbor.point.mX, neighbor.point.mY); 00276 neighboursout.push_back(neighbor); 00277 actionsout.push_back(Pattern::QUEUE); 00278 00279 neighbor.arith = CONTOURVAL; 00280 neighboursout.push_back(neighbor); 00281 actionsout.push_back(Pattern::WRITE); 00282 00283 } 00284 //leon a adaugat asta, ca sa markez pixeli de contur 00285 //else 00286 if (neighbor.img!=center.img && center.img==h 00287 && neighbor.arith<0) { 00288 // we mark this pixel, to be treated later, but we do not put 00289 // it on Queue 00290 neighbor.arith=CONTOURVAL; // line 9 00291 distImage(neighbor.point.mX, neighbor.point.mY)= 1; 00292 costImage(neighbor.point.mX, neighbor.point.mY)= -2; 00293 neighbor.localOrderCounter=globalOrderCounter++; // for equal 00294 // values be a FIFO=QUEUE 00295 neighbor.cost=costImage(neighbor.point.mX, neighbor.point.mY); 00296 neighboursout.push_back(neighbor); 00297 actionsout.push_back(Pattern::WRITE); 00298 } 00299 00300 } 00301 } 00302 00303 00304 //the next LOOP(2) should start only AFTER ALL pixels from the queue were tried 00305 // to be processed with LOOP1 00306 //here starts the propagation part searching for local minima (in algorithm point 4) 00307 00308 if (!step2) { 00309 //if not labeled yet 00310 if(!neighboursin.empty() && center.arith == MASKVAL) { 00311 labelcode++; 00312 center.arith = labelcode; 00313 neighboursout.push_back(center); 00314 actionsout.push_back(Pattern::WRITE); 00315 } //end if(!neighboursin.empty() && center.arith == MASKVAL) 00316 00317 if(!neighboursin.empty() && center.arith > 0) { 00318 for (i=0; i<neighboursin.size(); i++) { 00319 NeighborsT val=neighboursin[i]; 00320 PointValueT neighbor; 00321 neighbor.point=val.point; 00322 neighbor.arith=val.arith; 00323 neighbor.img=val.img; 00324 neighbor.mask=val.mask; 00325 neighbor.cost=costImage(neighbor.point.mX, neighbor.point.mY); 00326 00327 if(neighbor.arith == MASKVAL 00328 || neighbor.arith == INITVAL ) 00329 //if we uncomment this, the watershed lines will be removed 00330 // || neighbor.arith == WSHEDVAL 00331 // || neighbor.arith == CONTOURVAL) //not labeled yet 00332 { 00333 if(neighbor.img==center.img && center.img==h ) { 00334 neighbor.arith=center.arith; // line 9 00335 costImage(neighbor.point.mX, neighbor.point.mY)= 0; 00336 neighbor.localOrderCounter=globalOrderCounter++; // for 00337 // equal values be a FIFO=QUEUE 00338 neighbor.cost=costImage(neighbor.point.mX, 00339 neighbor.point.mY); 00340 neighboursout.push_back(neighbor); 00341 actionsout.push_back(Pattern::WRITE); 00342 neighboursout.push_back(neighbor); 00343 actionsout.push_back(Pattern::QUEUE); 00344 } 00345 else if(neighbor.img!=center.img && neighbor.arith<0) { 00346 // this is contour pixel 00347 // we mark this pixel, to be treated by the other loop, 00348 // but we do not put it on Queue 00349 neighbor.arith=CONTOURVAL; // line 9 00350 distImage(neighbor.point.mX, neighbor.point.mY)= 1; 00351 costImage(neighbor.point.mX, neighbor.point.mY)= -2; 00352 neighbor.localOrderCounter=globalOrderCounter++; // for 00353 // equal values be a FIFO=QUEUE 00354 neighbor.cost=costImage(neighbor.point.mX, 00355 neighbor.point.mY); 00356 neighboursout.push_back(neighbor); 00357 actionsout.push_back(Pattern::WRITE); 00358 } 00359 } 00360 } 00361 } 00362 } 00363 //here ends the propagation part searching for local minima (in algorithm point 4) 00364 00365 } //end calculate
Here is the call graph for this function:
|