Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Get shortest paths from sourceSuperPixel to all others
- */
- vector<double> GeodesicSaliencyPropagation::shortestPaths(SuperPixel* sourceSuperPixel)
- {
- unsigned superPixelsCount = this->superPixels.size();
- vector<double> lengthOfPaths(superPixelsCount);
- //set to all superpixels "infinite" length and non processed flag
- for (unsigned i = 0; i < superPixelsCount; i++){
- this->superPixels[i]->setProcessedFlag(false);
- lengthOfPaths[i] = DBL_MAX;
- }
- //set length 0 to source superpixel
- lengthOfPaths[sourceSuperPixel->getGraphIndex()] = 0.0;
- for (unsigned i = 0; i < superPixelsCount - 1; i++){
- //select min length of path on non processed superpixels
- double minLength = DBL_MAX;
- int minIndex;
- for (unsigned m = 0; m < superPixelsCount; m++){
- if (this->superPixels[m]->isProcessed() == false && lengthOfPaths[m] < minLength){
- minLength = lengthOfPaths[m];
- minIndex = m;
- }
- }
- //Select closest superpixel, set as processed and select all paths to others superpixels
- SuperPixel *current = this->superPixels[minIndex];
- current->setProcessedFlag(true);
- vector<SPPath*> paths = current->getPaths();
- //Travel through all paths to non processed superpixels
- for (unsigned p = 0; p < paths.size(); p++){
- SuperPixel *dest = paths[p]->nextSuperPixel(current);
- if (dest->isProcessed() == false){
- int destIndex = dest->getGraphIndex();
- double deltaPk = paths[p]->getLength();
- double lengthToDest = lengthOfPaths[minIndex] + deltaPk;
- //save closest path
- if (lengthToDest < lengthOfPaths[destIndex]){
- lengthOfPaths[destIndex] = lengthToDest;
- }
- }
- }
- }
- return lengthOfPaths;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement