contrib/oxl/mvl/HomgInterestPoint.cxx
Go to the documentation of this file.
00001 // This is oxl/mvl/HomgInterestPoint.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 //  \file
00007 
00008 #include "HomgInterestPoint.h"
00009 
00010 #include <vcl_iostream.h>
00011 #include <vnl/vnl_math.h>
00012 #include <mvl/HomgMetric.h>
00013 
00014 HomgInterestPoint::HomgInterestPoint()
00015 {
00016 }
00017 
00018 //: Create from vgl_homg_point_2d<double> in conditioned coordinates.
00019 // Using the given metric to convert back to image coordinates.
00020 HomgInterestPoint::HomgInterestPoint(const vgl_homg_point_2d<double>& h, const HomgMetric& metric, float mean_intensity):
00021   homg_(h.x(),h.y(),h.w()),
00022   double2_(0, 0),
00023   int2_(0, 0), // will be set below
00024   mean_intensity_(mean_intensity)
00025 {
00026   double x, y;
00027   metric.homg_to_image(homg_, &x, &y);
00028   double2_[0] = x;
00029   double2_[1] = y;
00030   int2_[0]= vnl_math_rnd(x);
00031   int2_[1]= vnl_math_rnd(y);
00032 }
00033 
00034 //: Create from HomgPoint2D in conditioned coordinates.
00035 // Using the given metric to convert back to image coordinates.
00036 HomgInterestPoint::HomgInterestPoint(const HomgPoint2D& h, const HomgMetric& metric, float mean_intensity):
00037   homg_(h),
00038   double2_(0, 0),
00039   int2_(0, 0), // will be set below
00040   mean_intensity_(mean_intensity)
00041 {
00042   double x, y;
00043   metric.homg_to_image(h, &x, &y);
00044   double2_[0] = x;
00045   double2_[1] = y;
00046   int2_[0]= vnl_math_rnd(x);
00047   int2_[1]= vnl_math_rnd(y);
00048 }
00049 
00050 HomgInterestPoint::HomgInterestPoint(double x, double y, float mean_intensity):
00051   homg_(x, y, 1.0),
00052   double2_(x, y),
00053   int2_(vnl_math_rnd(x), vnl_math_rnd(y)),
00054   mean_intensity_(mean_intensity)
00055 {
00056 }
00057 
00058 HomgInterestPoint::HomgInterestPoint(double x, double y, const HomgMetric& c, float mean_intensity):
00059   homg_(c.image_to_homg(x, y)),
00060   double2_(x, y),
00061   int2_(vnl_math_rnd(x), vnl_math_rnd(y)),
00062   mean_intensity_(mean_intensity)
00063 {
00064 }
00065 
00066 HomgInterestPoint::HomgInterestPoint(const HomgInterestPoint& that):
00067   homg_(that.homg_),
00068   double2_(that.double2_),
00069   int2_(that.int2_),
00070   mean_intensity_(that.mean_intensity_)
00071 {
00072 }
00073 
00074 HomgInterestPoint& HomgInterestPoint::operator=(const HomgInterestPoint& that)
00075 {
00076   homg_ = that.homg_;
00077   double2_ = that.double2_;
00078   int2_ = that.int2_;
00079   mean_intensity_ = that.mean_intensity_;
00080   return *this;
00081 }
00082 
00083 HomgInterestPoint::~HomgInterestPoint()
00084 {
00085 }
00086 
00087 vcl_ostream& operator<<(vcl_ostream& s, const HomgInterestPoint&)
00088 {
00089   return s;
00090 }
00091 
00092 bool operator==(const HomgInterestPoint& a, const HomgInterestPoint& b)
00093 {
00094   return a.double2_ == b.double2_;
00095 }