degate  0.1.2
Public Member Functions | Private Member Functions | Private Attributes
degate::LineSegmentExtraction< ImageType > Class Template Reference

#include <LineSegmentExtraction.h>

List of all members.

Public Member Functions

 LineSegmentExtraction (std::shared_ptr< ImageType > _img, unsigned int _search_radius_along, unsigned int _search_radius_across, unsigned int _border)
LineSegmentMap_shptr run ()

Private Member Functions

void extract_primitives ()
LinearPrimitive_shptr trace_line_primitive (std::shared_ptr< ImageType > img, unsigned int x, unsigned int y)

Private Attributes

unsigned int width
unsigned int height
std::shared_ptr< ImageType > img
std::shared_ptr< ImageType > processed
LineSegmentMap_shptr line_segments
unsigned int search_radius_along
unsigned int search_radius_across
unsigned int border

Detailed Description

template<typename ImageType>
class degate::LineSegmentExtraction< ImageType >

Definition at line 270 of file LineSegmentExtraction.h.


Constructor & Destructor Documentation

template<typename ImageType>
degate::LineSegmentExtraction< ImageType >::LineSegmentExtraction ( std::shared_ptr< ImageType >  _img,
unsigned int  _search_radius_along,
unsigned int  _search_radius_across,
unsigned int  _border 
) [inline]

Definition at line 283 of file LineSegmentExtraction.h.

References degate::LineSegmentExtraction< ImageType >::img, and degate::LineSegmentExtraction< ImageType >::processed.

                                              :
      width(_img->get_width()),
      height(_img->get_height()),
      img(_img),
      processed(new ImageType(width, height)),
      line_segments(new LineSegmentMap()),
      search_radius_along(_search_radius_along),
      search_radius_across(_search_radius_across),
      border(_border) {

      copy_image<ImageType, ImageType>(processed, img);
    }

Member Function Documentation

template<typename ImageType>
void degate::LineSegmentExtraction< ImageType >::extract_primitives ( ) [inline, private]

Definition at line 307 of file LineSegmentExtraction.h.

References degate::LineSegmentExtraction< ImageType >::border, degate::LineSegmentExtraction< ImageType >::height, degate::LineSegmentExtraction< ImageType >::line_segments, degate::LineSegmentExtraction< ImageType >::processed, degate::LineSegmentExtraction< ImageType >::trace_line_primitive(), and degate::LineSegmentExtraction< ImageType >::width.

Referenced by degate::LineSegmentExtraction< ImageType >::run().

                              {
      for(unsigned int y = border; y < height - border; y++)
        for(unsigned int x = border; x < width - border; x++) {

          if(processed->get_pixel(x, y) > 0) {
            LinearPrimitive_shptr lp = trace_line_primitive(processed, x, y);
            if(lp != NULL) {
              LineSegment_shptr segment(new LineSegment(lp));
              //segment->print();
              line_segments->add(segment);
            }
          }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename ImageType>
LineSegmentMap_shptr degate::LineSegmentExtraction< ImageType >::run ( ) [inline]
template<typename ImageType>
LinearPrimitive_shptr degate::LineSegmentExtraction< ImageType >::trace_line_primitive ( std::shared_ptr< ImageType >  img,
unsigned int  x,
unsigned int  y 
) [inline, private]

Definition at line 322 of file LineSegmentExtraction.h.

Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives().

                                                                               {

      LinearPrimitive_shptr segment;

      unsigned int _x = x;
      while(_x < width && img->get_pixel(_x, y) > 0) _x++;

      if(_x - x > 1) {
        segment = LinearPrimitive_shptr(new LinearPrimitive(x, y, _x, y));
        _x = x;
        while(_x < width && img->get_pixel(_x, y) > 0) {
          img->set_pixel(_x, y, 0);
          _x++;
        }
        return segment;
      }

      unsigned int _y = y;
      while(_y < height && img->get_pixel(x, _y) > 0) _y++;

      if(_y - y > 1) {
        segment = LinearPrimitive_shptr(new LinearPrimitive(x, y, x, _y));
        _y = y;
        while(_y < height && img->get_pixel(x, _y) > 0) {
            img->set_pixel(x, _y, 0);
            _y++;
          }
          return segment;
      }

      return segment;
    }

Here is the caller graph for this function:


Member Data Documentation

template<typename ImageType>
unsigned int degate::LineSegmentExtraction< ImageType >::border [private]
template<typename ImageType>
unsigned int degate::LineSegmentExtraction< ImageType >::height [private]
template<typename ImageType>
std::shared_ptr<ImageType> degate::LineSegmentExtraction< ImageType >::img [private]
template<typename ImageType>
LineSegmentMap_shptr degate::LineSegmentExtraction< ImageType >::line_segments [private]
template<typename ImageType>
std::shared_ptr<ImageType> degate::LineSegmentExtraction< ImageType >::processed [private]
template<typename ImageType>
unsigned int degate::LineSegmentExtraction< ImageType >::search_radius_across [private]
template<typename ImageType>
unsigned int degate::LineSegmentExtraction< ImageType >::search_radius_along [private]
template<typename ImageType>
unsigned int degate::LineSegmentExtraction< ImageType >::width [private]

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