ShiTomasi.cc
Go to the documentation of this file.
00001 // Copyright 2008 Isis Innovation Limited
00002 #include "ptam/ShiTomasi.h"
00003 #include <math.h>
00004 
00005 using namespace CVD;
00006 
00007 double FindShiTomasiScoreAtPoint(BasicImage<byte> &image,
00008                                  int nHalfBoxSize,
00009                                  ImageRef irCenter)
00010 {
00011   double dXX = 0;
00012   double dYY = 0;
00013   double dXY = 0;
00014 
00015   ImageRef irStart = irCenter - ImageRef(nHalfBoxSize, nHalfBoxSize);
00016   ImageRef irEnd = irCenter + ImageRef(nHalfBoxSize, nHalfBoxSize);
00017 
00018   ImageRef ir;
00019   for(ir.y = irStart.y; ir.y<=irEnd.y; ir.y++)
00020     for(ir.x = irStart.x; ir.x<=irEnd.x; ir.x++)
00021     {
00022       double dx = image[ir + ImageRef(1,0)] - image[ir - ImageRef(1,0)];
00023       double dy = image[ir + ImageRef(0,1)] - image[ir - ImageRef(0,1)];
00024       dXX += dx*dx;
00025       dYY += dy*dy;
00026       dXY += dx*dy;
00027     }
00028 
00029   int nPixels = (irEnd - irStart + ImageRef(1,1)).area();
00030   dXX = dXX / (2.0 * nPixels);
00031   dYY = dYY / (2.0 * nPixels);
00032   dXY = dXY / (2.0 * nPixels);
00033 
00034   // Find and return smaller eigenvalue:
00035   return 0.5 * (dXX + dYY - sqrt( (dXX + dYY) * (dXX + dYY) - 4 * (dXX * dYY - dXY * dXY) ));
00036 };
00037 


ptam
Author(s): Stephan Weiss, Markus Achtelik, Simon Lynen
autogenerated on Tue Jan 7 2014 11:12:22