contrib/brl/bseg/sdet/sdet_third_order_edge_det_params.cxx
Go to the documentation of this file.
00001 // This is brl/bseg/sdet/sdet_third_order_edge_det_params.cxx
00002 #include "sdet_third_order_edge_det_params.h"
00003 //:
00004 // \file
00005 // See sdet_third_order_edge_det_params.h
00006 //
00007 //-----------------------------------------------------------------------------
00008 #include <vcl_sstream.h>
00009 #include <vcl_iostream.h>
00010 
00011 //------------------------------------------------------------------------
00012 // Constructors
00013 //
00014 
00015 sdet_third_order_edge_det_params::
00016 sdet_third_order_edge_det_params(const sdet_third_order_edge_det_params& dp)
00017   : gevd_param_mixin()
00018 {
00019   InitParams(dp.sigma_, dp.thresh_, dp.interp_factor_, dp.pfit_type_,
00020              dp.grad_op_, dp.conv_algo_,dp.adapt_thresh_);
00021 }
00022 
00023 sdet_third_order_edge_det_params::
00024 sdet_third_order_edge_det_params(const double sigma, const double thresh,
00025                                  const unsigned interp_factor, 
00026                                  const unsigned pfit_type, 
00027                                  const unsigned grad_op,
00028                                  const unsigned conv_algo,
00029                                  const bool adapt_thresh)
00030 {
00031   InitParams(sigma, thresh, interp_factor, pfit_type, grad_op, conv_algo, adapt_thresh);
00032 }
00033 
00034 void sdet_third_order_edge_det_params::InitParams(double sigma, double thresh,
00035                                                   unsigned interp_factor,
00036                                                   unsigned pfit_type,
00037                                                   unsigned grad_op,
00038                                                   unsigned conv_algo,
00039                                                   bool adapt_thresh)
00040 {
00041   sigma_ = sigma,
00042   thresh_ = thresh;
00043   interp_factor_ = interp_factor;
00044   pfit_type_ = pfit_type;
00045   grad_op_ = grad_op;
00046   conv_algo_ = conv_algo;
00047   adapt_thresh_ = adapt_thresh;
00048 }
00049 
00050 //-----------------------------------------------------------------------------
00051 //
00052 //:   Checks that parameters are within acceptable bounds
00053 //    Note that msg << ends seems to restart the string and erase the
00054 //    previous string. We should only use it as the last call, use
00055 //    vcl_endl otherwise.
00056 bool sdet_third_order_edge_det_params::SanityCheck()
00057 {
00058   vcl_stringstream msg;
00059   bool valid = true;
00060 
00061   if (thresh_<0 || thresh_>10)
00062   {
00063     msg << "ERROR: percentage threshold should be between 0 and 10";
00064     valid = false;
00065   }
00066   msg << vcl_ends;
00067 
00068   SetErrorMsg(msg.str().c_str());
00069   return valid;
00070 }
00071 
00072 vcl_ostream& operator<< (vcl_ostream& os, const sdet_third_order_edge_det_params& dp)
00073 {
00074   return
00075   os << "sdet_third_order_edge_det_params:\n[---\n"
00076      << "Smooth sigma " << dp.sigma_ << vcl_endl
00077      << "Gradient threshold in percentage " << dp.thresh_ << vcl_endl
00078      << "---]" << vcl_endl;
00079 }