contrib/mul/mipa/mipa_ms_block_normaliser.h
Go to the documentation of this file.
00001 #ifndef mipa_ms_block_normaliser_h_
00002 #define mipa_ms_block_normaliser_h_
00003 
00004 //:
00005 // \file
00006 // \author Martin Roberts
00007 // \brief Class to independently normalise sub-blocks with a region
00008 
00009 #include <vcl_string.h>
00010 #include <vcl_iosfwd.h>
00011 #include <vnl/vnl_fwd.h>
00012 #include <mipa/mipa_block_normaliser.h>
00013 #include <mipa/mipa_identity_normaliser.h>
00014 
00015 //: Independently normalise (non-overlapping) blocks within a region
00016 //(e.g. as in simplified R-HOG without overlap)
00017 
00018 class mipa_ms_block_normaliser : public mipa_block_normaliser
00019 {
00020   //: Number of SIFT-like scales at which the histogram cells are combined
00021   unsigned nscales_;
00022 
00023   //: Is there an overall histogram (over all cells) included at the end
00024   bool include_overall_histogram_;
00025 
00026  public:
00027 
00028   mipa_ms_block_normaliser():
00029       mipa_block_normaliser(),
00030       nscales_(1), include_overall_histogram_(false) {}
00031 
00032   mipa_ms_block_normaliser(const mipa_block_normaliser& lbn,
00033                            unsigned nscales,bool include_overall_histogram):
00034       mipa_block_normaliser(lbn),
00035       nscales_(nscales), include_overall_histogram_(include_overall_histogram) {}
00036 
00037   //: Apply transform independently to each block (at multi-scales)
00038   virtual void normalise(vnl_vector<double>& v) const;
00039 
00040   //: Name of the class
00041   virtual vcl_string is_a() const;
00042 
00043   //: Create a copy on the heap and return base class pointer
00044   virtual mipa_vector_normaliser* clone() const;
00045 
00046   //: Print class to os
00047   virtual void print_summary(vcl_ostream& os) const;
00048 
00049   //: Save class to binary file stream
00050   virtual void b_write(vsl_b_ostream& bfs) const;
00051 
00052   //: Load class from binary file stream
00053   virtual void b_read(vsl_b_istream& bfs);
00054 
00055   //: Initialise from a text stream.
00056   // syntax
00057   // \verbatim
00058   // {
00059   //   normaliser: mipa_l2norm_vector_normaliser
00060   //   ni: 16
00061   //   nj: 16
00062   //   nA: 20;
00063   //   nc_per_block: 4
00064   //   include_overall_histogram: true
00065   //   nscales: 2
00066   // }
00067   // \endverbatim
00068   virtual void config_from_stream(
00069       vcl_istream &is, const mbl_read_props_type &extra_props);
00070 
00071   void set_nscales(unsigned n)
00072       {nscales_ = n;}
00073 
00074   void set_include_overall_histogram(bool bIn)
00075       {include_overall_histogram_ = bIn;}
00076 
00077   unsigned  nscales() const {return nscales_;}
00078 
00079   bool include_overall_histogram() const  {return include_overall_histogram_ ;}
00080 };
00081 
00082 #endif // mipa_ms_block_normaliser_h_