contrib/gel/vtol/vtol_intensity_face.h
Go to the documentation of this file.
00001 // This is gel/vtol/vtol_intensity_face.h
00002 #ifndef vtol_intensity_face_h_
00003 #define vtol_intensity_face_h_
00004 //:
00005 // \file
00006 // \brief A face with intensity attributes
00007 //
00008 //  A sub-class of Face which contains intensity attributes that are the
00009 //  result of sampling the interior of the face in an image. The boundaries
00010 //  of the face are vtol_edge(s) with DigitalCurve geometry. The
00011 //  IntensityFace is nominally 2d and embedded in an image coordinate
00012 //  frame. The IntensityFace can be constructed from a 3-d linear
00013 //  Face (Face with ImplicitPlane and ImplicitLine geometry) under
00014 //  a WorldToImage camera projection, or directly from an image region
00015 //  analysis.  In the latter case the IntensityFace is constructed
00016 //  from a set of vtol_edge(s) and then the interior is derived from the
00017 //  associated image region.  If the IntensityFace is derived from
00018 //  a projected linear Face, the projected boundaries of a set of Faces
00019 //  are used to tessellate the image for region analysis.
00020 //
00021 // \author J.L. Mundy
00022 // \date   November 21, 1999
00023 //
00024 // \verbatim
00025 //  Modifications
00026 //   8-May-2002 - Peter Vanroose - no longer inherits from vdgl_digital_region:
00027 //                    dependency changed to "has_a", but with cast_to semantics
00028 //   8-Jan-2003 - Peter Vanroose - moved compute_bounding_box() to vtol_face
00029 //   5-Feb-2003 - Peter Vanroose - moved IsHoleP() to vtol_face_2d
00030 //   9-May-2003 - Mike Petersen - intensity face attributes support:
00031 //                    - added get_min() & get_max() pass-throughs
00032 //                    - restored perimeter() API
00033 //                    - added topology_type() override (INTENSITYFACE)
00034 //   14-Nov-2003 - Joe Mundy - removed leak since region_ was not being deleted
00035 //   22-Sep-2004 - Peter Vanroose - deprecated all 3D interface stuff
00036 //   22-Sep-2004 - Peter Vanroose - added cast_to_intensity_face()
00037 // \endverbatim
00038 //
00039 //-------------------------------------------------------------------------
00040 
00041 #include <vnl/vnl_matrix.h>
00042 #include <vdgl/vdgl_digital_region.h>
00043 #include <vtol/vtol_topology_object.h>
00044 #include <vtol/vtol_face_2d.h>
00045 #include <vtol/vtol_intensity_face_sptr.h>
00046 
00047 class vtol_intensity_face : public vtol_face_2d
00048 {
00049  protected:
00050   // Data Members--------------------------------------------------------------
00051   vdgl_digital_region* region_;
00052  public:
00053   //Constructors---------------------------------------------------------------
00054   //: A constructor from an existing face
00055   vtol_intensity_face(vtol_face_2d_sptr const& face);
00056 #if 0
00057   //: A constructor from a set of 2-d vtol_edge(s) with DigitalCurve geometry
00058   //  Here the vtol_edge(s) are constructed from edgel curves formed during
00059   //  region analysis.
00060   vtol_intensity_face(vcl_vector<vtol_edge_sptr>* edges) : Face(edges) {}
00061   //: Uses given 2-d vtol_edges (not deep copy) with intensity information from dr.
00062   vtol_intensity_face(vcl_vector<vtol_edge_sptr>* edges, vdgl_digital_region& dr)
00063   : vtol_face_2d(edges), vdgl_digital_region(dr.Npix(), dr.Xj(), dr.Yj(), dr.Ij()) {}
00064 #endif
00065   vtol_intensity_face(vcl_vector<vtol_edge_sptr>* edges);
00066   vtol_intensity_face(one_chain_list & one_chains);
00067   vtol_intensity_face(vcl_vector<vtol_one_chain_sptr>* chains, vdgl_digital_region const& dr);
00068   vtol_intensity_face(vtol_intensity_face_sptr const& iface);
00069   vtol_intensity_face(vtol_face_2d_sptr const& face, int npts, float const* xp, float const* yp,
00070                       unsigned short const* pix);
00071   ~vtol_intensity_face();
00072 
00073   //---------------------------------------------------------------------------
00074   //: Clone `this': creation of a new object and initialization
00075   //  See Prototype pattern
00076   //---------------------------------------------------------------------------
00077   virtual vsol_spatial_object_2d* clone() const;
00078 
00079   //: Return a platform independent string identifying the class
00080   virtual vcl_string is_a() const { return vcl_string("vtol_intensity_face"); }
00081 
00082   //: Return true if the argument matches the string identifying the class or any parent class
00083   virtual bool is_class(const vcl_string& cls) const
00084   { return cls==is_a() || vtol_face_2d::is_class(cls); }
00085 
00086  private:
00087   inline vtol_topology_object::vtol_topology_object_type
00088     GetTopologyType() const { return vtol_topology_object::INTENSITYFACE; }
00089 
00090   // MPP 5/9/2003
00091   // Added API consistent w/ overloaded vtol method
00092   virtual vtol_topology_object::vtol_topology_object_type
00093   topology_type() const { return GetTopologyType(); }
00094 
00095  public:
00096   //***************************************************************************
00097   // Replaces dynamic_cast<T>
00098   //***************************************************************************
00099 
00100   //---------------------------------------------------------------------------
00101   //: Return `this' if `this' is an intensity face, 0 otherwise
00102   //---------------------------------------------------------------------------
00103   virtual const vtol_intensity_face* cast_to_intensity_face() const { return this; }
00104 
00105   //---------------------------------------------------------------------------
00106   //: Return `this' if `this' is an intensity face, 0 otherwise
00107   //---------------------------------------------------------------------------
00108   virtual vtol_intensity_face* cast_to_intensity_face() { return this; }
00109 
00110   virtual vdgl_digital_region* cast_to_digital_region() const {return region_;}
00111   virtual vdgl_digital_region* cast_to_digital_region() {return region_;}
00112   double area() const { return region_->area(); }
00113   void ResetPixelData() { region_->ResetPixelData(); }
00114   void IncrementMeans(float x, float y, unsigned short pix){region_->IncrementMeans(x,y,pix);}
00115   void ComputeIntensityStdev(){region_->ComputeIntensityStdev();}
00116   void InitPixelArrays() { region_->InitPixelArrays(); }
00117   void InsertInPixelArrays(float x, float y, unsigned short pix){region_->InsertInPixelArrays(x,y,pix);}
00118 
00119   float const* Xj() const { return region_->Xj(); }
00120   float const* Yj() const { return region_->Yj(); }
00121   // \deprecated since intensity_face is strictly 2d in VXL
00122   float const* Zj() const { return 0; }
00123   unsigned short const* Ij() const { return region_->Ij(); }
00124 
00125   int Npix()const {return region_->Npix(); }
00126   float X() const { return region_->X(); }
00127   float Y() const { return region_->Y(); }
00128   // \deprecated since intensity_face is strictly 2d in VXL
00129   float Z() const { return 0.f; }
00130   unsigned short I() const {return region_->I();}
00131 
00132   void set_X(float x){region_->set_X(x); }
00133   void set_Y(float y){region_->set_Y(y); }
00134   void set_I(unsigned short I){region_->set_I(I);}
00135 
00136   void reset() const {region_->reset();}
00137   bool next() const {return region_->next();}
00138   float Xo()const { return region_->Xo(); }
00139   float Yo()const { return region_->Yo(); }
00140   // \deprecated since intensity_face is strictly 2d in VXL
00141   float Zo()const { return 0.f; }
00142   float Io()const { return region_->Io(); }
00143   float Io_sd()const { return region_->Io_sd(); }
00144   double X2()const { return region_->X2(); }
00145   double Y2()const { return region_->Y2(); }
00146   double XY()const { return region_->XY(); }
00147   double I2()const { return region_->I2(); }
00148   double XI()const { return region_->XI(); }
00149   double YI()const { return region_->YI(); }
00150   double Ix() const { return region_->Ix(); }
00151   double Iy() const { return region_->Iy(); }
00152   float Ir() const { return region_->Ir(); }
00153   float Diameter() const { return region_->Diameter(); }
00154   float AspectRatio() const { return region_->AspectRatio(); }
00155 #if 0
00156   void PrincipalOrientation(vcl_vector<float>& axis) { region_->PrincipalOrientation(axis); }
00157 #endif
00158   double Var() const { return region_->Var(); }
00159 
00160   // MPP 5/9/2003
00161   // Additional digital region pass-throughs
00162   float get_min() const { return region_->get_min(); }
00163   float get_max() const { return region_->get_max(); }
00164 
00165   //Accessors
00166   // The Face moment matrix
00167   virtual vnl_matrix<double> MomentMatrix();
00168 
00169   //Utility Methods
00170 
00171   // MPP 5/9/2003
00172   // Resurrected from #ifdef'd block below for intensity face attributes
00173   double perimeter();
00174 };
00175 
00176 #endif // vtol_intensity_face_h_