LevelHelpers.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Copyright 2008 Isis Innovation Limited
00003 
00004 // LevelHelpers.h - a few handy tools to ease using levels.
00005 // The important thing is the XXXPos functions, which convert
00006 // image positions from one level to another. Use these whenever
00007 // transforming positions to ensure consistent operation!!
00008 
00009 #ifndef __LEVEL_HELPERS_H
00010 #define __LEVEL_HELPERS_H
00011 #include <TooN/TooN.h>
00012 using namespace TooN;
00013 #include <cvd/image_ref.h>
00014 
00015 // Set of global colours useful for drawing stuff:
00016 extern Vector<3> gavLevelColors[];
00017 // (These are filled in in KeyFrame.cc)
00018 
00019 // What is the scale of a level?
00020 inline int LevelScale(int nLevel)
00021 {
00022   return 1 << nLevel;
00023 }
00024 
00025 // 1-D transform to level zero:
00026 inline double LevelZeroPos(double dLevelPos, int nLevel)
00027 {
00028   return (dLevelPos + 0.5) * LevelScale(nLevel) - 0.5;
00029 }
00030 
00031 // 2-D transforms to level zero:
00032 inline Vector<2> LevelZeroPos(Vector<2> v2LevelPos, int nLevel)
00033     {
00034   Vector<2> v2Ans;
00035   v2Ans[0] = LevelZeroPos(v2LevelPos[0], nLevel);
00036   v2Ans[1] = LevelZeroPos(v2LevelPos[1], nLevel);
00037   return v2Ans;
00038     }
00039 inline Vector<2> LevelZeroPos(CVD::ImageRef irLevelPos, int nLevel) 
00040     {
00041   Vector<2> v2Ans;
00042   v2Ans[0] = LevelZeroPos(irLevelPos.x, nLevel);
00043   v2Ans[1] = LevelZeroPos(irLevelPos.y, nLevel);
00044   return v2Ans;
00045     }
00046 
00047 // 1-D transform from level zero to level N:
00048 inline double LevelNPos(double dRootPos, int nLevel)
00049 {
00050   return (dRootPos + 0.5) / LevelScale(nLevel) - 0.5;
00051 }
00052 
00053 // 2-D transform from level zero to level N:
00054 inline Vector<2> LevelNPos(Vector<2> v2RootPos, int nLevel)
00055     {
00056   Vector<2> v2Ans;
00057   v2Ans[0] = LevelNPos(v2RootPos[0], nLevel);
00058   v2Ans[1] = LevelNPos(v2RootPos[1], nLevel);
00059   return v2Ans;
00060     }
00061 
00062 #endif


ptam
Author(s): Markus Achtelik , Stephan Weiss , Simon Lynen
autogenerated on Sun Oct 5 2014 23:52:33