1 // This is gel/vifa/vifa_parallel.h
2 #ifndef VIFA_PARALLEL_H
3 #define VIFA_PARALLEL_H
4 
5 //-----------------------------------------------------------------------------
6 //:
7 // \file
8 // \brief Class for parallel line calculations.
9 //
10 // \author Roddy Collins, from DDB in TargetJr
11 //
12 // \verbatim
13 //  Modifications:
14 //   MPP Mar 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 <vtol/vtol_intensity_face_sptr.h>
24 #include <vtol/vtol_edge_2d.h>
25 #include <vifa/vifa_histogram.h>
26 #include <vifa/vifa_parallel_params.h>
27 #include <vifa/vifa_typedefs.h>
28 
29 
30 //: Compute the parallel-ness of a set of line segments
31 // NOTE: All angles are in degrees.
32 class vifa_parallel: public vifa_parallel_params
33 {
34  private:
35   //: Raw histogram
36   vifa_histogram*  raw_h_;
37 
38   //: Normalized histogram
39   vifa_histogram*  norm_h_;
40 
41  public:
42   //: Face-based constructor
43   vifa_parallel(iface_list&      faces,
44                 bool             contrast_weighted,
45                 vifa_parallel_params*  params = nullptr
46                );
47 
48   //: Orientation-based constructor
49   vifa_parallel(std::vector<float>&  pixel_orientations,
50                 vifa_parallel_params*  params = nullptr
51                );
52 
53   //: Constructor based on line statistics
54   vifa_parallel(float  center_angle,
55                 float  std_dev
56                );
57 
58   //: Destructor
59   ~vifa_parallel() override;
60 
61   void reset();
62 
63   vifa_histogram *get_raw_hist();
64   vifa_histogram *get_norm_hist();
65 
66   void  map_gaussian(float&  max_angle,
67                      float&  std_dev,
68                      float&  scale
69                     );
70   void  remove_gaussian(float  max_angle,
71                         float  std_dev,
72                         float  scale
73                        );
74   void  snapshot(char* fname);
75   float area();
76   float bin_variance();
77 
78 private:
79   float           map_x(float  raw_x);
80   vifa_histogram* normalize_histogram(vifa_histogram*  h);
81   float           find_peak(float&  max_value);
82   vtol_intensity_face_sptr get_adjacent_iface(const vtol_intensity_face_sptr& known_face,
83                                               vtol_edge_2d*            e);
84 };
85 
86 
87 #endif  // VIFA_PARALLEL_H
88