|
degate 0.1.1
|
#include <LineSegmentExtraction.h>
Public Member Functions | |
| LineSegmentExtraction (std::tr1::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::tr1::shared_ptr< ImageType > img, unsigned int x, unsigned int y) |
Private Attributes | |
| unsigned int | width |
| unsigned int | height |
| std::tr1::shared_ptr< ImageType > | img |
| std::tr1::shared_ptr< ImageType > | processed |
| LineSegmentMap_shptr | line_segments |
| unsigned int | search_radius_along |
| unsigned int | search_radius_across |
| unsigned int | border |
Definition at line 270 of file LineSegmentExtraction.h.
| degate::LineSegmentExtraction< ImageType >::LineSegmentExtraction | ( | std::tr1::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);
}
| 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);
}
}
}
}


| LineSegmentMap_shptr degate::LineSegmentExtraction< ImageType >::run | ( | ) | [inline] |
Definition at line 299 of file LineSegmentExtraction.h.
References degate::LineSegmentExtraction< ImageType >::extract_primitives(), degate::LineSegmentExtraction< ImageType >::line_segments, degate::LineSegmentExtraction< ImageType >::search_radius_across, and degate::LineSegmentExtraction< ImageType >::search_radius_along.
Referenced by degate::WireMatching::run().
{
extract_primitives();
line_segments->merge(search_radius_along, search_radius_across);
line_segments->write();
return line_segments;
}


| LinearPrimitive_shptr degate::LineSegmentExtraction< ImageType >::trace_line_primitive | ( | std::tr1::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;
}

unsigned int degate::LineSegmentExtraction< ImageType >::border [private] |
Definition at line 280 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives().
unsigned int degate::LineSegmentExtraction< ImageType >::height [private] |
Definition at line 274 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives().
std::tr1::shared_ptr<ImageType> degate::LineSegmentExtraction< ImageType >::img [private] |
Definition at line 275 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::LineSegmentExtraction().
LineSegmentMap_shptr degate::LineSegmentExtraction< ImageType >::line_segments [private] |
Definition at line 277 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives(), and degate::LineSegmentExtraction< ImageType >::run().
std::tr1::shared_ptr<ImageType> degate::LineSegmentExtraction< ImageType >::processed [private] |
Definition at line 276 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives(), and degate::LineSegmentExtraction< ImageType >::LineSegmentExtraction().
unsigned int degate::LineSegmentExtraction< ImageType >::search_radius_across [private] |
Definition at line 279 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::run().
unsigned int degate::LineSegmentExtraction< ImageType >::search_radius_along [private] |
Definition at line 278 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::run().
unsigned int degate::LineSegmentExtraction< ImageType >::width [private] |
Definition at line 274 of file LineSegmentExtraction.h.
Referenced by degate::LineSegmentExtraction< ImageType >::extract_primitives().
1.7.4