contrib/brl/bseg/brip/brip_watershed_params.cxx
Go to the documentation of this file.
00001 #include "brip_watershed_params.h"
00002 //:
00003 // \file
00004 #include <vcl_sstream.h>
00005 #include <vcl_iostream.h>
00006 
00007 //------------------------------------------------------------------------
00008 // Constructors
00009 //
00010 
00011 brip_watershed_params::brip_watershed_params(const brip_watershed_params& wp)
00012 {
00013   InitParams(wp.sigma_, wp.thresh_,
00014              wp.eight_connected_, wp.verbose_);
00015 }
00016 
00017 brip_watershed_params::brip_watershed_params(float sigma, float thresh,
00018                                              bool eight_connected,
00019                                              bool verbose)
00020 {
00021   InitParams(sigma, thresh, eight_connected, verbose);
00022 }
00023 
00024 void brip_watershed_params::InitParams(float sigma, float thresh,
00025                                        bool eight_connected, bool verbose)
00026 {
00027   sigma_ = sigma;
00028   thresh_ = thresh;
00029   eight_connected_ = eight_connected;
00030   verbose_ = verbose;
00031 }
00032 
00033 //-----------------------------------------------------------------------------
00034 //
00035 //: Checks that parameters are within acceptable bounds
00036 //
00037 bool brip_watershed_params::SanityCheck()
00038 {
00039   vcl_stringstream msg;
00040   bool valid = true;
00041 
00042   if (sigma_ <= 0)  // Standard deviation of the smoothing kernel
00043   {
00044     msg << "ERROR: Value of gaussian smoothing sigma is too low <=0" << vcl_ends;
00045     valid = false;
00046   }
00047 
00048   if (thresh_ < 0)  // Noise weighting factor
00049   {
00050     msg << "ERROR: Value of noise weight must be >=0" << vcl_ends;
00051     valid = false;
00052   }
00053 
00054   msg << vcl_ends;
00055   SetErrorMsg(msg.str().c_str());
00056   return valid;
00057 }
00058 
00059 vcl_ostream& operator<<(vcl_ostream& os, const brip_watershed_params& wp)
00060 {
00061   return
00062   os << "brip_watershed_params:\n[---\n"
00063      << "sigma " << wp.sigma_ << vcl_endl
00064      << "thresh " << wp.thresh_ << vcl_endl
00065      << "eight connected? " << wp.eight_connected_ << vcl_endl
00066      << "verbose " << wp.verbose_ << vcl_endl
00067      << "---]" << vcl_endl;
00068 }