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

Similarity.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualisation_Plot_Similarity_h
00002 #define Impala_Visualisation_Plot_Similarity_h
00003 
00004 #include "Visualization/Plot/Plottable.h"
00005 #include "Data/Geometry/PointZ.h"
00006 #include "Ops/Element/ColConvert.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Visualization
00011 {
00012 namespace Plot
00013 {
00014 
00015 class Similarity : public Plottable
00016 {
00017 public:
00018 
00019     Similarity()
00020     {
00021         mImage1 = 0;
00022         mImage2 = 0;
00023     }
00024 
00025     virtual void
00026     Draw(Plot* plot)
00027     {
00028 
00029 //        glEnable(GL_BLEND);
00030 //        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00031         glColor3f(mRed, mGreen, mBlue);
00032 
00033         double front = 0.7;
00034         double back = -0.7;
00035 
00036         glBegin(GL_LINE_LOOP);
00037         glVertex3d(  0,  0, front);
00038         glVertex3d(  0,144, front);
00039         glVertex3d(192,144, front);
00040         glVertex3d(192,  0, front);
00041         glEnd();
00042 
00043         glBegin(GL_LINE_LOOP);
00044         glVertex3d(  0,  0,back);
00045         glVertex3d(  0,144,back);
00046         glVertex3d(192,144,back);
00047         glVertex3d(192,  0,back);
00048         glEnd();
00049 
00050         glBegin(GL_LINES);
00051         for(int i=0 ; i<mPoints1.size() ; i++)
00052         {
00053             SelectColor(mColorId[i]);
00054             glVertex3d(mPoints1[i].mX, mPoints1[i].mY, front);
00055             SelectColor(mColorId[i], 0.3);
00056             glVertex3d(mPoints2[i].mX, mPoints2[i].mY, back);
00057         }
00058         glEnd();
00059     }
00060 
00061     void
00062     SetData(Array2dVec3UInt8* im1, Array2dVec3UInt8* im2)
00063     {
00064         mImage1 = im1;
00065         mImage2 = im2;
00066     }
00067 
00068     void
00069     Val2Color(double v)
00070     {
00071         double r,g,b;
00072         r = (v+1.)/2.;
00073         g = (v-1.)/-2.;
00074         b = (1.-fabs(v))/2.;
00075         glColor3f(r, g, b);
00076     }
00077 
00078     void
00079     AddLine(double x1, double y1, double x2, double y2, int colorId)
00080     {
00081         mPoints1.push_back(PointZ(x1,y1));
00082         mPoints2.push_back(PointZ(x2,y2));
00083         mColorId.push_back(colorId);
00084     }
00085 
00086     void
00087     Clear()
00088     {
00089         mPoints1.clear();
00090         mPoints2.clear();
00091         mColorId.clear();
00092     }
00093 
00094 #define PI 3.1415926535897932384626433832795
00095 #define PHI 0.61803398874989484820458683436564
00096 
00097     void
00098     SelectColor(int colorId, double intensity = 1.)
00099     {
00100         double sat = sqrt((double)colorId/37.);
00101         double angle = (colorId*PHI*2.);
00102         while(angle>2.)
00103             angle -= 2.;
00104         Vec3Real64 color(angle*PI, intensity, sat);
00105         color = ColHSI2RGB(color);
00106         glColor3d(color.X(), color.Y(), color.Z());
00107     }
00108 
00109 #undef PI
00110 #undef PHI
00111 
00112 protected:
00113     Array2dVec3UInt8* mImage1;
00114     Array2dVec3UInt8* mImage2;
00115     std::vector<int>* mMatch;
00116     std::vector<double>* mScore;
00117     std::vector<PointZ> mPoints1;
00118     std::vector<PointZ> mPoints2;
00119     std::vector<int> mColorId;
00120 };
00121 
00122 }//namespace Impala
00123 }//namespace Visulization
00124 }//namespace Plot
00125 
00126 #endif Impala_Visualisation_Plot_Similarity_h

Generated on Fri Mar 19 09:31:28 2010 for ImpalaSrc by  doxygen 1.5.1