00001 /* 00002 * roUtil.H 00003 * 00004 * 00005 * Created by Randolph Voorhies on 11/13/07. 00006 * Copyright 2007 __MyCompanyName__. All rights reserved. 00007 * 00008 */ 00009 00010 #ifndef ROUTIL_H 00011 #define ROUTIL_H 00012 00013 #include <queue> 00014 00015 using namespace std; 00016 00017 00018 //This function constructs a priority queue of type pix out of an image 00019 template <class T> 00020 rutz::shared_ptr< priority_queue< pix<T> > > makePriQueue(rutz::shared_ptr< Image<T> > inputImage) { 00021 rutz::shared_ptr< priority_queue< pix<T> > > outputQueue(new priority_queue< pix<T> >); 00022 00023 for(int x=0; x<inputImage->getWidth(); x++) { 00024 for(int y=0; y<inputImage->getHeight(); y++) { 00025 outputQueue->push(pix<T>(x,y,inputImage->getVal(x,y))); 00026 } 00027 } 00028 00029 return outputQueue; 00030 } 00031 00032 template <class T> 00033 void makeHeatmap(rutz::shared_ptr<priority_queue < pix <T> > > rankOrderPixels, rutz::shared_ptr< Image< PixRGB <float> > > heatmap) { 00034 pix <float> currPix; 00035 float h=1; 00036 float i=255.0; 00037 float j=255.0; 00038 00039 heatmap->clear(); 00040 00041 while(!rankOrderPixels->empty() && rankOrderPixels->top().val > 10) { 00042 currPix = rankOrderPixels->top(); 00043 rankOrderPixels->pop(); 00044 heatmap->setVal(currPix.x, currPix.y, PixRGB<float>(i,j,0.0)); 00045 h-=.0001; 00046 i=255.0*h; 00047 j=255*(1-h); 00048 } 00049 } 00050 00051 #endif 00052