1 // This is gel/vifa/vifa_int_face_attr.h
2 #ifndef VIFA_INT_FACE_ATTR_H_
3 #define VIFA_INT_FACE_ATTR_H_
4 
5 //-----------------------------------------------------------------------------
6 //:
7 // \file
8 // \brief Collects attribute information about an individual intensity face.
9 //
10 // \author Roddy Collins, from DDB in TargetJr
11 //
12 // \verbatim
13 //  Modifications:
14 //   MPP May 2003, Ported to VXL
15 // \endverbatim
16 //-----------------------------------------------------------------------------
17 
18 #include <iostream>
19 #include <vector>
20 #ifdef _MSC_VER
21 #  include <vcl_msvc_warnings.h>
22 #endif
23 #include <vbl/vbl_smart_ptr.h>
24 #include <vdgl/vdgl_fit_lines_params.h>
25 #include <vtol/vtol_intensity_face.h>
26 #include <vifa/vifa_histogram.h>
27 #include <vifa/vifa_int_face_attr_common.h>
28 #include <vifa/vifa_parallel.h>
29 #include <vifa/vifa_typedefs.h>
30 
31 
32 class vifa_int_face_attr: public vifa_int_face_attr_common
33 {
34  protected:
35 
36   //: The face whose attributes we store
37   vtol_intensity_face_sptr  face_;
38 
39   float cached_min_{0.0f};
40   float cached_max_{0.0f};
41   float cached_mean_{0.0f};
42   float cached_var_{0.0f};
43   float            cached_2_parallel_;
44   float            cached_4_parallel_;
45   int              cached_80_parallel_;
46   vifa_parallel *npobj_{nullptr};
47 
48 public:
49 
50   vifa_int_face_attr(vdgl_fit_lines_params*    fitter_params = nullptr,
51                      vifa_group_pgram_params*  gpp = nullptr,
52                      vifa_group_pgram_params*  gpp_w = nullptr,
53                      vifa_norm_params*         np = nullptr
54                     );
55   vifa_int_face_attr(const vtol_intensity_face_sptr&  f,
56                      vdgl_fit_lines_params*    fitter_params = nullptr,
57                      vifa_group_pgram_params*  gpp = nullptr,
58                      vifa_group_pgram_params*  gpp_w = nullptr,
59                      vifa_norm_params*         np = nullptr
60                     );
61   ~vifa_int_face_attr() override;
62 
63   // ---
64   // Public functional methods
65   // ---
66 
67   bool         ComputeAttributes() override;
68   bool         GetAttributes(std::vector<float>&  attrs) override;
69   static void  GetAttributeNames(std::vector<std::string>&  names);
70   bool         GetNativeAttributes(std::vector<float>&  attrs) override;
71 
72   // Data access for non-attributes
GetFace()73   vtol_intensity_face_sptr  GetFace() const { return face_; }
74   void                      SetFace(const vtol_intensity_face_sptr&  f);
75   edge_2d_list&             GetEdges() override;
76 
77   //: Centroid X
Xo()78   float  Xo() override { return face_->Xo(); }
79 
80   //: Centroid Y
Yo()81   float  Yo() override { return face_->Yo(); }
82 
83   //: Centroid Z
Zo()84   virtual float  Zo() { return face_->Zo(); }
85 
86   // ---
87   // Intensity attribute computations
88   // ---
89 
90   //: Min intensity
IntMin()91   float  IntMin() { return cached_min_; }
92 
93   //: Max intensity
IntMax()94   float  IntMax() { return cached_max_; }
95 
96   //: Mean intensity
IntMean()97   float  IntMean() { return cached_mean_; }
98 
99   //: Intensity variance
IntVar()100   float  IntVar() { return cached_var_; }
101 
102   // ---
103   // Geometric attribute computations
104   // ---
105 
106   //: Area
Area()107   float  Area() override { return (float)(GetFace() ? face_->Npix() : -1); }
108 
109   //: Ratio of major moments
110   float  AspectRatio() override;
111 
112   //: Length of boundary, in pixels
113   float  PerimeterLength() override;
114 
115   float  WeightedPerimeterLength() override;
116   float  Complexity() override;
117 
118   //: Edge length^2 / detection area
119   float  WeightedComplexity() override;
120 
121   float  TwoPeakParallel() override;
122   float  FourPeakParallel() override;
123   float  EightyPercentParallel() override;
124 
125  protected:
126 
127   void  ComputeCacheValues();
128   void  SetNP();
129 };
130 
131 typedef vbl_smart_ptr<vifa_int_face_attr>  vifa_int_face_attr_sptr;
132 
133 typedef std::vector<vifa_int_face_attr_sptr>            attr_list;
134 typedef std::vector<vifa_int_face_attr_sptr>::iterator  attr_iterator;
135 
136 
137 #endif  // VIFA_INT_FACE_ATTR_H_
138