contrib/brl/bseg/segv/segv_vil_segmentation_manager.h
Go to the documentation of this file.
00001 #ifndef segv_vil_segmentation_manager_h_
00002 #define segv_vil_segmentation_manager_h_
00003 //--------------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \brief Manager for segmentation algorithm execution and display
00007 // \author
00008 //   J.L. Mundy
00009 //
00010 // \verbatim
00011 //  Modifications:
00012 //   J.L. Mundy November 18, 2002    Initial version.
00013 // \endverbatim
00014 //---------------------------------------------------------------------------
00015 
00016 #include <vcl_vector.h>
00017 #include <vil/vil_image_resource.h>
00018 #include <vsol/vsol_line_2d_sptr.h>
00019 #include <vsol/vsol_conic_2d_sptr.h>
00020 #include <vsol/vsol_polygon_2d_sptr.h>
00021 #include <vsol/vsol_polyline_2d_sptr.h>
00022 #include <vtol/vtol_edge_2d_sptr.h>
00023 #include <vsol/vsol_point_2d_sptr.h>
00024 #include <vtol/vtol_intensity_face_sptr.h>
00025 #include <vtol/vtol_face_2d_sptr.h>
00026 #include <vgui/vgui_wrapper_tableau.h>
00027 #include <vgui/vgui_grid_tableau_sptr.h>
00028 #include <vgui/vgui_range_map_params_sptr.h>
00029 #include <vgui/vgui_style_sptr.h>
00030 #include <bgui/bgui_picker_tableau_sptr.h>
00031 #include <bgui/bgui_vtol2D_tableau_sptr.h>
00032 #include <bgui/bgui_image_tableau_sptr.h>
00033 #include <bgui/bgui_bargraph_clipon_tableau_sptr.h>
00034 #include <bgui/bgui_graph_tableau_sptr.h>
00035 #include <bgui/bgui_graph_tableau.h>
00036 #include <brip/brip_roi_sptr.h>
00037 class vgui_window;
00038 
00039 class segv_vil_segmentation_manager : public vgui_wrapper_tableau
00040 {
00041  public:
00042   segv_vil_segmentation_manager();
00043   ~segv_vil_segmentation_manager();
00044   static segv_vil_segmentation_manager *instance();
00045   void quit();
00046   void load_image();
00047   void save_image();
00048   void save_nitf_camera();
00049   void save_mask();
00050 
00051   // -- visualization --
00052 
00053   void set_range_params();
00054   void inline_viewer();
00055   void intensity_profile();
00056   void intensity_histogram();
00057   void display_images_as_color();
00058   void image_as_vrml_points();
00059 
00060   // -- image transformation --
00061 
00062   void flip_image_lr();
00063   void rotate_image();
00064   void reduce_image();
00065   void reduce_image_bicubic();
00066   void expand_image();
00067   void expand_image_bicubic();
00068 
00069   // -- image arithmetic --
00070 
00071   void add_images();
00072   void subtract_images();
00073   void negate_image();
00074 
00075   // -- image processing --
00076 
00077   void entropy();
00078   void minfo();
00079   void max_trace_scale();
00080   void color_order();
00081   void extrema();
00082   void rot_extrema();
00083   void beaudet();
00084   void parallel_coverage();
00085   void gradient_mag_angle();
00086   void fft();
00087   void gaussian();
00088   void abs_value();
00089   // -- segmentation --
00090 
00091   void threshold_image();
00092   void harris_corners();
00093   void nonmaximal_suppression();
00094   void vd_edges();
00095   void third_order_edges();
00096   void fit_lines();
00097   void fit_conics();
00098   void fit_overlay_conics();
00099   void regions();
00100   void mser_conics();
00101   void draw_line_image();
00102   //: ############## New method to project 3D points ##################
00103   void project_points();
00104   // ##################################################################
00105 
00106   // -- utilities --
00107 
00108   void clear_display();
00109   void clear_all();
00110   void init();
00111   void remove_image();
00112   void convert_to_grey();
00113   void clear_mask();
00114   void add_poly_to_mask();
00115   void load_image_nomenu(vcl_string const& path);
00116   void crop_image();
00117   //: drawing
00118   void create_polygon();
00119   void create_roi();
00120   void display_roi();
00121   //: access to the window
00122   vgui_window* get_window(){return win_;}
00123   //: access to the window
00124   void set_window(vgui_window* win){win_=win;}
00125 
00126  protected:
00127   void draw_edges(vcl_vector<vtol_edge_2d_sptr>& edges, bool verts=false);
00128   void draw_lines(vcl_vector<vsol_line_2d_sptr> const & line_segs,
00129                   const vgui_style_sptr& style = NULL);
00130 
00131   void draw_conics(vcl_vector<vsol_conic_2d_sptr> const & conic_segs,
00132                    const vgui_style_sptr& style = NULL);
00133 
00134   void draw_polylines(vcl_vector<vsol_polyline_2d_sptr> const & polys);
00135   void draw_regions(vcl_vector<vtol_intensity_face_sptr>& regions,
00136                     bool verts=false);
00137   void draw_points(vcl_vector<vsol_point_2d_sptr> const & points,
00138                    const vgui_style_sptr& style);
00139 
00140   void set_selected_grid_image(vil_image_resource_sptr const& image,
00141                                vgui_range_map_params_sptr const& rmps =0);
00142 
00143   void add_image_at(vil_image_resource_sptr const& image,
00144                     const unsigned col, const unsigned row,
00145                     vgui_range_map_params_sptr const& rmps = 0);
00146 
00147   void add_image(vil_image_resource_sptr const& image,
00148                  vgui_range_map_params_sptr const& rmps =0);
00149 
00150   vil_image_resource_sptr selected_image();
00151   vil_image_resource_sptr image_at(const unsigned col, const unsigned row);
00152   bool
00153   set_image_at(const unsigned col, const unsigned row, vil_image_resource_sptr const& image);
00154   bgui_image_tableau_sptr selected_image_tab();
00155   bgui_vtol2D_tableau_sptr vtol2D_tab_at(const unsigned col,const unsigned row);
00156   bgui_vtol2D_tableau_sptr selected_vtol2D_tab();
00157   bgui_picker_tableau_sptr selected_picker_tab();
00158   vtol_face_2d_sptr face_at(const int col, const int row);
00159   vgui_range_map_params_sptr range_params(vil_image_resource_sptr const& image);
00160  private:
00161   // -- flags --
00162   bool first_; //: first image load
00163   vgui_window* win_;
00164   vgui_grid_tableau_sptr grid_;
00165   vtol_face_2d_sptr foreground_face_;
00166   vtol_face_2d_sptr background_face_;
00167   bgui_bargraph_clipon_tableau_sptr bargraph_;
00168   vcl_vector<vsol_polygon_2d_sptr> mask_;
00169   brip_roi_sptr roi_;
00170   static segv_vil_segmentation_manager *instance_;
00171 };
00172 
00173 #endif // segv_vil_segmentation_manager_h_