degate  0.1.2
Public Member Functions | Private Attributes
degate::EdgeDetection Class Reference

#include <EdgeDetection.h>

Inheritance diagram for degate::EdgeDetection:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void setup_pipe ()
unsigned int get_width () const
unsigned int get_height () const
void set_directory (std::string const &path)
std::string get_directory () const
bool has_directory () const
void run_edge_detection (ImageBase_shptr in)
TileImage_GS_DOUBLE_shptr get_horizontal_edges ()
TileImage_GS_DOUBLE_shptr get_vertical_edges ()
TileImage_GS_DOUBLE_shptr get_edge_magnitude_image (TileImage_GS_DOUBLE_shptr probability_map)
TileImage_GS_DOUBLE_shptr get_edge_image (TileImage_GS_DOUBLE_shptr probability_map)
 EdgeDetection (unsigned int _min_x, unsigned int _max_x, unsigned int _min_y, unsigned int _max_y, unsigned int median_filter_width=3, unsigned int _blur_kernel_size=10, double _sigma=0.5)
virtual ~EdgeDetection ()
unsigned int get_border () const

Private Attributes

IPPipe pipe
unsigned int min_x
unsigned int max_x
unsigned int min_y
unsigned int max_y
unsigned int median_filter_width
unsigned int blur_kernel_size
unsigned int border
double sigma
TileImage_GS_DOUBLE_shptr i1
TileImage_GS_DOUBLE_shptr i2
std::string directory
bool has_path

Detailed Description

Definition at line 38 of file EdgeDetection.h.


Constructor & Destructor Documentation

EdgeDetection::EdgeDetection ( unsigned int  _min_x,
unsigned int  _max_x,
unsigned int  _min_y,
unsigned int  _max_y,
unsigned int  median_filter_width = 3,
unsigned int  _blur_kernel_size = 10,
double  _sigma = 0.5 
)

Definition at line 27 of file EdgeDetection.cc.

References setup_pipe().

                                            :
  min_x(_min_x),
  max_x(_max_x),
  min_y(_min_y),
  max_y(_max_y),
  median_filter_width(_median_filter_width),
  blur_kernel_size(_blur_kernel_size),
  border(_blur_kernel_size >> 1),
  sigma(_sigma),
  has_path(false) {

  setup_pipe();
}

Here is the call graph for this function:

Definition at line 46 of file EdgeDetection.cc.

                              {
}

Member Function Documentation

unsigned int EdgeDetection::get_border ( ) const
std::string EdgeDetection::get_directory ( ) const

Definition at line 102 of file EdgeDetection.cc.

References directory.

Referenced by degate::CannyEdgeDetection::non_maximum_supression().

                                             {
  return directory;
}

Here is the caller graph for this function:

Definition at line 168 of file EdgeDetection.cc.

References border, directory, get_height(), get_width(), has_path, i1, i2, and degate::join_pathes().

Referenced by degate::ZeroCrossingEdgeDetection::run(), and degate::CannyEdgeDetection::run().

                                                                                                 {

  if(i1 == NULL || i2 == NULL) return TileImage_GS_DOUBLE_shptr();

  TileImage_GS_DOUBLE_shptr edge_image(new TileImage_GS_DOUBLE(get_width(), get_height()));

  for(unsigned int y = border +2; y < get_height() - border -1; y++) {
    for(unsigned int x = border+2; x < get_width() - border -1; x++) {
      double gx = i1->get_pixel(x, y);
      double gy = i2->get_pixel(x, y);

      if(probability_map != NULL) {
        if(probability_map->get_pixel(x, y) > 0)
          edge_image->set_pixel(x, y, gx + gy);
      }
      else
        edge_image->set_pixel(x, y, gx + gy);
    }
  }
  if(has_path) save_normalized_image<TileImage_GS_DOUBLE>(join_pathes(directory,
                                                                      "03_edge_image.tif"),
                                                          edge_image);

  return edge_image;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file EdgeDetection.cc.

References border, directory, get_height(), get_width(), has_path, i1, i2, and degate::join_pathes().

Referenced by degate::CannyEdgeDetection::run().

                                                                                                           {

  if(i1 == NULL || i2 == NULL) return TileImage_GS_DOUBLE_shptr();

  TileImage_GS_DOUBLE_shptr edge_mag_image(new TileImage_GS_DOUBLE(get_width(), get_height()));

  for(unsigned int y = border +2; y < get_height() - border -1; y++) {
    for(unsigned int x = border+2; x < get_width() - border -1; x++) {
      double gx = i1->get_pixel(x, y);
      double gy = i2->get_pixel(x, y);
      double g = sqrt(pow(gx,2) + pow(gy, 2));
      if(probability_map != NULL) {
        if(probability_map->get_pixel(x, y) > 0)
          edge_mag_image->set_pixel(x, y, g);
      }
      else
        edge_mag_image->set_pixel(x, y, g);
    }
  }

  if(has_path) save_normalized_image<TileImage_GS_DOUBLE>(join_pathes(directory,
                                                                      "03_edge_mag_image.tif"),
                                                          edge_mag_image);
  return edge_mag_image;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int EdgeDetection::get_height ( ) const

Definition at line 131 of file EdgeDetection.cc.

References i1.

Referenced by degate::CannyEdgeDetection::run().

                                                              {
  return i1;
}

Here is the caller graph for this function:

Definition at line 135 of file EdgeDetection.cc.

References i2.

Referenced by degate::CannyEdgeDetection::run().

                                                            {
  return i2;
}

Here is the caller graph for this function:

unsigned int EdgeDetection::get_width ( ) const

Definition at line 106 of file EdgeDetection.cc.

References has_path.

Referenced by degate::CannyEdgeDetection::non_maximum_supression().

                                        {
  return has_path;
}

Here is the caller graph for this function:

Definition at line 110 of file EdgeDetection.cc.

References directory, has_path, i1, i2, degate::join_pathes(), pipe, and degate::IPPipe::run().

Referenced by degate::ZeroCrossingEdgeDetection::run(), and degate::CannyEdgeDetection::run().

                                                         {

  ImageBase_shptr out = pipe.run(in);
  assert(out != NULL);

  std::shared_ptr<SobelYOperator> SobelY(new SobelYOperator());
  std::shared_ptr<IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE> > edge_filter_x
    (new IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE>(SobelY) );

  std::shared_ptr<SobelXOperator> SobelX(new SobelXOperator());
  std::shared_ptr<IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE> > edge_filter_y
    (new IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE>(SobelX) );

  i1 = std::dynamic_pointer_cast<TileImage_GS_DOUBLE>(edge_filter_x->run(out));
  i2 = std::dynamic_pointer_cast<TileImage_GS_DOUBLE>(edge_filter_y->run(out));
  assert(i1 != NULL && i2 != NULL);

  if(has_path) save_normalized_image<TileImage_GS_DOUBLE>(join_pathes(directory, "01_sobelx.tif"), i1);
  if(has_path) save_normalized_image<TileImage_GS_DOUBLE>(join_pathes(directory, "02_sobely.tif"), i2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void EdgeDetection::set_directory ( std::string const &  path)

Definition at line 97 of file EdgeDetection.cc.

References directory, and has_path.

Referenced by degate::ZeroCrossingEdgeDetection::run(), and degate::CannyEdgeDetection::run().

                                                       {
  directory = path;
  has_path = true;
}

Here is the caller graph for this function:

Definition at line 54 of file EdgeDetection.cc.

References degate::IPPipe::add(), blur_kernel_size, debug(), max_x, max_y, degate::median_filter(), median_filter_width, min_x, min_y, pipe, sigma, and TM.

Referenced by EdgeDetection().

                               {

  debug(TM, "will extract background image (%d, %d) (%d, %d)", min_x, min_y, max_x, max_y);
  std::shared_ptr<IPCopy<TileImage_RGBA, TileImage_GS_DOUBLE> > copy_rgba_to_gs
    (new IPCopy<TileImage_RGBA, TileImage_GS_DOUBLE>(min_x, max_x, min_y, max_y) );

  pipe.add(copy_rgba_to_gs);

  if(median_filter_width > 0) {
    std::shared_ptr<IPMedianFilter<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE> > median_filter
      (new IPMedianFilter<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE>(median_filter_width));

    pipe.add(median_filter);
  }


  std::shared_ptr<IPNormalize<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE> > normalizer
    (new IPNormalize<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE>(0, 1) );
  pipe.add(normalizer);


  if(blur_kernel_size > 0) {
    std::shared_ptr<GaussianBlur>
      GaussianB(new GaussianBlur(blur_kernel_size, blur_kernel_size, sigma));

    GaussianB->print();
    std::shared_ptr<IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE> > gaussian_blur
      (new IPConvolve<TileImage_GS_DOUBLE, TileImage_GS_DOUBLE>(GaussianB) );

    pipe.add(gaussian_blur);
  }

}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 47 of file EdgeDetection.h.

Referenced by setup_pipe().

unsigned int degate::EdgeDetection::border [private]

Definition at line 47 of file EdgeDetection.h.

Referenced by get_border(), get_edge_image(), and get_edge_magnitude_image().

std::string degate::EdgeDetection::directory [private]
unsigned int degate::EdgeDetection::max_x [private]

Definition at line 44 of file EdgeDetection.h.

Referenced by get_width(), and setup_pipe().

unsigned int degate::EdgeDetection::max_y [private]

Definition at line 44 of file EdgeDetection.h.

Referenced by get_height(), and setup_pipe().

Definition at line 45 of file EdgeDetection.h.

Referenced by setup_pipe().

unsigned int degate::EdgeDetection::min_x [private]

Definition at line 44 of file EdgeDetection.h.

Referenced by get_width(), and setup_pipe().

unsigned int degate::EdgeDetection::min_y [private]

Definition at line 44 of file EdgeDetection.h.

Referenced by get_height(), and setup_pipe().

Definition at line 42 of file EdgeDetection.h.

Referenced by run_edge_detection(), and setup_pipe().

double degate::EdgeDetection::sigma [private]

Definition at line 48 of file EdgeDetection.h.

Referenced by setup_pipe().


The documentation for this class was generated from the following files: