contrib/brl/bseg/sdet/sdet_img_edge.h
Go to the documentation of this file.
00001 // This is brl/bseg/sdet/sdet_img_edge.h
00002 #ifndef sdet_img_edge_h_
00003 #define sdet_img_edge_h_
00004 //:
00005 // \file
00006 // \brief Various utility methods and classes related to edge probability updates
00007 // \author Ibrahim Eden (ieden@lems.brown.edu)
00008 // \date Jul 14,  2009
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   December 15, 2009 - Ibrahim Eden - removed convert_image_types
00013 //   January 13, 2010 - Gamze Tunali - moved from bvxm/bvxm_edge_util.h to sdet_img_edge.h
00014 //   July 07, 2010 - Ozge C. Ozcanli - added detect_edge_tangent_interpolated method
00015 // \endverbatim
00016 
00017 #include <vil/vil_image_view.h>
00018 #include <vbl/vbl_array_2d.h>
00019 
00020 #include <vcl_string.h>
00021 #include <vcl_vector.h>
00022 #include <vcl_iostream.h>
00023 #include <vcl_cmath.h>
00024 
00025 class sdet_img_edge
00026 {
00027  public:
00028   //returns a binary map of edges with pixel resolution
00029   static vil_image_view<vxl_byte> detect_edges(vil_image_view<vxl_byte> img, double noise_multiplier, double smooth, bool automatic_threshold, bool junctionp, bool aggressive_junction_closure);
00030 
00031   // return image has three planes:
00032   // plane 0 - sub-pixel column position of the edge.
00033   //           Negative value indicates no edge is present
00034   // plane 1 - sub-pixel row position of the edge.
00035   //           Negative value indicates no edge is present
00036   // plane 2 - Orientation of local edge tangent direction in radians
00037   // range is [0, 2pi).
00038   static vil_image_view<float> detect_edge_tangent(vil_image_view<vxl_byte> img,
00039                                                    double noise_multiplier,
00040                                                    double smooth,
00041                                                    bool automatic_threshold,
00042                                                    bool junctionp,
00043                                                    bool aggressive_junction_closure);
00044 
00045   // return image has three planes as in detect_edge_tangent
00046   // Canny edge detector returns edgel chains with a linear interpolator by default, replace this interpolator with a cubic one and read the edge tangents from this interpolator                                  
00047   static vil_image_view<float> detect_edge_tangent_interpolated(vil_image_view<vxl_byte> img,
00048                                                                 double noise_multiplier,
00049                                                                 double smooth,
00050                                                                 bool automatic_threshold,
00051                                                                 bool junctionp,
00052                                                                 bool aggressive_junction_closure);
00053   // return image has three planes as in detect_edge_tangent
00054   static vil_image_view<float> detect_edge_line_fitted(vil_image_view<vxl_byte> img,
00055                                                    double noise_multiplier,
00056                                                    double smooth,
00057                                                    bool automatic_threshold,
00058                                                    bool junctionp,
00059                                                    bool aggressive_junction_closure,
00060                                                    int min_fit_length, double rms_distance);
00061 
00062   // input is an edge image as the output of detect_edge_tangent(); output is line image: 
00063   // plane 0 - line coefficient a --
00064   //                                |-- components of line normal vector
00065   // plane 1 - line coefficient b --
00066   //
00067   // plane 2 - line coefficient c
00068   static void convert_edge_image_to_line_image(vil_image_view<float>& edge_img, vil_image_view<float>& output_line_img);
00069 
00070 
00071   static void edge_distance_transform(vil_image_view<vxl_byte>& inp_image, vil_image_view<float>& out_edt);
00072 
00073   static vil_image_view<float> multiply_image_with_gaussian_kernel(vil_image_view<float> img, double gaussian_sigma);
00074   static void estimate_edge_prob_image(const vil_image_view<vxl_byte>& img_edge, vil_image_view<float>& img_edgeness, const int mask_size, const float mask_sigma);
00075   static vbl_array_2d<float> get_spherical_gaussian_kernel(const int size, const float sigma);
00076 
00077   static float convert_edge_statistics_to_probability(float edge_statistic, float n_normal, int dof);
00078 
00079   static void convert_true_edge_prob_to_edge_statistics(const vil_image_view<float>& img_tep,vil_image_view<float>& img_es);
00080 };
00081 
00082 #endif // sdet_img_edge_h_