KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
edge.h
Go to the documentation of this file.
1 /* $Id: edge.h 17393 2014-08-23 20:19:14Z predoehl $ */
2 /* =========================================================================== *
3  |
4  | Copyright (c) 1994-2010 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== */
19 
20 #ifndef KJB_CPP_EDGE_BASE_H
21 #define KJB_CPP_EDGE_BASE_H
22 
23 #include <string>
24 
25 #include <l/l_incl.h>
26 #include <edge/edge_base.h>
27 #include <i_cpp/i_image.h>
28 
29 #ifdef KJB_HAVE_BST_SERIAL
30 #include <boost/serialization/list.hpp>
31 //#include <boost/archive/text_oarchive.hpp>
32 //#include <boost/archive/text_iarchive.hpp>
33 #endif
34 
35 #include <boost/shared_ptr.hpp>
36 #include <string>
37 
38 namespace kjb
39 {
40 
41 class Edge;
42 class Edge_set;
43 
49 {
50 public:
51  Edge_point(kjb_c::Edge_point * pt)
52  {
53  _c_edge_pt = pt;
54  }
55 
57 
58  Edge_point(const Edge_point & pt)
59  {
60  (*this) = pt;
61  }
62 
64  {
65  _c_edge_pt = pt._c_edge_pt;
66  return (*this);
67  }
68 
70  inline unsigned int get_col() const { return _c_edge_pt->col;}
71 
73  inline unsigned int get_row() const { return _c_edge_pt->row;}
74 
76  inline double get_dcol() const {return _c_edge_pt->dcol;}
77 
79  inline double get_drow() const {return _c_edge_pt->drow;}
80 
82  inline double get_gradient_magnitude() const {return _c_edge_pt->mag;}
87  inline bool get_silhouette() const {return (bool)(_c_edge_pt->silhouette); }
88 
90  inline void set_col(unsigned int icol) { _c_edge_pt->col = icol;}
91 
93  inline void set_row(unsigned int irow) { _c_edge_pt->row = irow;}
94 
96  inline void set_dcol(double idcol) { _c_edge_pt->dcol = idcol;}
97 
99  inline void set_drow(double idrow) { _c_edge_pt->drow = idrow;}
100 
102  inline void set_gradient_magnitude(double imag) { _c_edge_pt->mag = imag;}
103 
105  inline void set_silhouette(bool isilhouette) { _c_edge_pt->silhouette = (unsigned int)isilhouette; }
106 
110  const kjb_c::Edge_point * _c_ptr()
111  {
112  return _c_edge_pt;
113  }
114 
116  void draw(Image & img, float r, float g, float b) const
117  {
118  kjb_c::Pixel pixel;
119  pixel.r = r;
120  pixel.g = g;
121  pixel.b = b;
122  kjb_c::KJB_image * out = img.non_const_c_ptr();
123  ETX(kjb_c::color_edge_point(&out, out, _c_edge_pt, &pixel) );
124  }
125 
126 
127 private:
128 
133  void set_edge_pt(kjb_c::Edge_point * i_edge_pt)
134  {
135  _c_edge_pt = i_edge_pt;
136  }
137 
138  // Pointer to the c Edge_point structure
139  kjb_c::Edge_point * _c_edge_pt;
140 
141  friend class kjb::Edge;
142  friend class kjb::Edge_set;
143 
144 };
145 
150 class Edge
151 {
152 public:
153  Edge(kjb_c::Edge *edge)
154  {
155  if(edge == NULL)
156  {
157  throw kjb::Illegal_argument(
158  "Null edge pointer passed to Edge class constructor");
159  }
160  _c_edge = edge;
161 
162  }
163 
164  ~Edge() {}
165 
166  Edge(const Edge & edge)
167  {
168  (*this) = edge;
169  }
170 
171  Edge & operator=(const Edge & edge)
172  {
173  _c_edge = edge._c_edge;
174  return (*this);
175  }
176 
178  inline unsigned int get_num_points() const
179  {
180  return _c_edge->num_points;
181  }
182 
184  Edge_point get_edge_point(unsigned int i) const
185  {
186  if(i >= get_num_points())
187  {
188  throw kjb::Illegal_argument("Edge point index out of bounds");
189  }
190  return Edge_point(&_c_edge->points[i]);
191  }
192 
194  const kjb_c::Edge * _c_ptr() const
195  {
196  return _c_edge;
197  }
198 
203  void draw(Image& img, float r, float g, float b) const
204  {
205  kjb_c::Pixel pixel;
206  pixel.r = r;
207  pixel.g = g;
208  pixel.b = b;
209  kjb_c::KJB_image * out = img.non_const_c_ptr();
210  ETX(kjb_c::color_edge_points(&out, out, _c_edge->points, _c_edge->num_points, &pixel) );
211  }
212 
216  void randomly_color(Image& img) const
217  {
218  kjb_c::KJB_image * out = img.non_const_c_ptr();
219  ETX(kjb_c::randomly_color_edge_points(&out, out, _c_edge->points, _c_edge->num_points) );
220  }
221 
222 
223 private:
224 
225  // Pointer to the c Edge structure
226  kjb_c::Edge * _c_edge;
227 };
228 
233 class Edge_set
234 {
235 public:
237  m_edge_set(0)
238  {}
239 
241  Edge_set(kjb_c::Edge_set* in) :
242  m_edge_set(in)
243  {
244 
245  }
246 
248  Edge_set(const char* fname) :
249  m_edge_set(0)
250  {
251  load(fname);
252  }
253 
255  Edge_set(const std::string& fname) :
256  m_edge_set(0)
257  {
258  load(fname.c_str());
259  }
260 
261  Edge_set(const Edge_set& edge_in) :
262  m_edge_set(0)
263  {
264  kjb_c::copy_edge_set(&m_edge_set, edge_in.m_edge_set);
265  }
266 
273  const std::vector<kjb_c::Edge_point>& edge_pts,
274  int num_rows_in,
275  int num_cols_in
276  )
277  : m_edge_set(0)
278  {
279  using kjb_c::Malloc_size;
280  // This ifdef makes it work in production mode =)
281 #ifdef TRACK_MEMORY_ALLOCATION
282  using kjb_c::debug_kjb_malloc;
283 #else
284  using kjb_c::kjb_malloc;
285 #endif
286  kjb_c::Edge_set* edge_set = static_cast<kjb_c::Edge_set*>(kjb_malloc(sizeof(kjb_c::Edge_set)));
287  edge_set->num_edges = 1;
288  edge_set->total_num_pts = edge_pts.size();
289  edge_set->edges = static_cast<kjb_c::Edge*>(kjb_malloc(sizeof(kjb_c::Edge)));
290  edge_set->edges[0].num_points = edge_pts.size();
291  edge_set->edges[0].points = static_cast<kjb_c::Edge_point*>(kjb_malloc(sizeof(kjb_c::Edge_point) * edge_pts.size()));
292  edge_set->num_rows = num_rows_in;
293  edge_set->num_cols = num_cols_in;
294 
295  for(size_t i = 0; i < edge_pts.size(); i++)
296  {
297  edge_set->edges[0].points[i] = edge_pts[i];
298  }
299 
300  m_edge_set = edge_set;
301  }
302 
303 
305  {
306  kjb_c::free_edge_set(m_edge_set);
307  }
308 
309  Edge_set& operator=(const Edge_set& other)
310  {
311  Edge_set tmp(other);
312  swap(tmp);
313  return *this;
314  }
315 
317  kjb_c::Edge_point& operator()(size_t edge_num, size_t point_num)
318  {
319  assert(m_edge_set);
320  assert(edge_num < m_edge_set->num_edges);
321  assert(point_num < m_edge_set->edges[edge_num].num_points);
322  return m_edge_set->edges[edge_num].points[point_num];
323  }
324 
326  const kjb_c::Edge_point& operator()(size_t edge_num, size_t point_num) const
327  {
328  assert(m_edge_set);
329  assert(edge_num < m_edge_set->num_edges);
330  assert(point_num < m_edge_set->edges[edge_num].num_points);
331  return m_edge_set->edges[edge_num].points[point_num];
332  }
333 
336  void swap(Edge_set& other)
337  {
338  using std::swap;
339  swap(m_edge_set, other.m_edge_set);
340  }
341 
343  kjb_c::Edge_point& operator[](size_t i)
344  {
345  assert(m_edge_set);
346  assert(i < m_edge_set->total_num_pts);
347  return m_edge_set->edges[0].points[i];
348  }
349 
351  const kjb_c::Edge_point& operator[](size_t i) const
352  {
353  assert(m_edge_set);
354  assert(i < m_edge_set->total_num_pts);
355  return m_edge_set->edges[0].points[i];
356  }
357 
359  size_t num_edges() const
360  {
361  if(!m_edge_set)
362  return 0;
363 
364  return m_edge_set->num_edges;
365  }
366 
368  size_t size() const
369  {
370  return get_total_edge_points();
371  }
372 
374  Edge get_edge(unsigned int i) const
375  {
376  return Edge(&m_edge_set->edges[i]);
377  }
378 
380  void set_edge_set(kjb_c::Edge_set* iedge_set)
381  {
382  kjb_c::free_edge_set(m_edge_set);
383  m_edge_set = iedge_set;
384  }
385 
387  size_t num_rows() const { return m_edge_set->num_rows; }
388 
390  inline size_t get_num_rows() const { return num_rows(); }
391 
393  size_t num_cols() const { return m_edge_set->num_cols; }
394 
396  inline size_t get_num_cols() const { return num_cols(); }
397 
399  size_t edge_length(size_t i_edge) const
400  {
401  assert(m_edge_set);
402  return m_edge_set->edges[i_edge].num_points;
403  }
404 
406  size_t get_total_edge_points() const
407  {
408  if(!m_edge_set)
409  return 0;
410 
411  return m_edge_set->total_num_pts;
412  }
413 
415  void remove_short_edges(uint32_t min_length)
416  {
417  kjb_c::remove_short_edges(m_edge_set, min_length);
418  }
419 
426  unsigned int find_index(const kjb::Edge & iedge) const
427  {
428  unsigned index;
429  int rc = kjb_c::find_edge_index(m_edge_set, iedge._c_ptr(), &index);
430  if (rc != kjb_c::NO_ERROR)
431  {
432  KJB_THROW_2(Illegal_argument, "Bad edge index");
433  }
434  return index;
435  }
436 
441  void remove_edge(unsigned int iindex)
442  {
443  if( kjb_c::remove_edge(m_edge_set, iindex) != kjb_c::NO_ERROR)
444  {
445  KJB_THROW_2(Illegal_argument, "Bad edge index");
446  }
447  }
448 
460  void break_edges_at_corners(float thresh, uint32_t num_avg)
461  {
462  kjb_c::break_edges_at_corners(m_edge_set, thresh, num_avg);
463  }
464 
465 
467  void sample_edge_set(float p)
468  {
469  using std::swap;
470 
471  kjb_c::Edge_set* c_result = NULL;
472  kjb_c::sample_edge_set(&c_result, m_edge_set, p);
473  swap(c_result, m_edge_set);
474  kjb_c::free_edge_set(c_result);
475  }
476 
481  void draw_edge(Image & img, float r, float g, float b, unsigned int edge_index) const
482  {
483  if(edge_index >= num_edges())
484  {
485  throw kjb::Illegal_argument("Edge set, color edge, edge index out of bounds");
486  }
487  Edge(&m_edge_set->edges[edge_index]).draw(img, r, g, b);
488  }
489 
492  void randomly_color_edge(Image & img, unsigned int edge_index) const
493  {
494  if(edge_index >= num_edges())
495  {
496  throw kjb::Illegal_argument("Edge set, randomly color edge, edge index out of bounds");
497  }
498  Edge(&m_edge_set->edges[edge_index]).randomly_color(img);
499  }
500 
505  void draw(Image& img, float r, float g, float b) const
506  {
507  // since we can't get a non-const pointer to the underlying KJB_image, we have to store the result in a new KJB_image, and swap it into the input image.
508 
509  kjb_c::Pixel pixel;
510  pixel.r = r;
511  pixel.g = g;
512  pixel.b = b;
513  kjb_c::KJB_image * out = img.non_const_c_ptr();
514  ETX(kjb_c::color_edge_set(&out, out, m_edge_set, & pixel));
515 
516  }
517 
523  {
524  kjb_c::KJB_image* out = NULL;
525 
526  ETX(kjb_c::randomly_color_edge_set(&out, img.c_ptr(), m_edge_set));
527  Image tmp(out); // this will handle freeing the c-style image
528  img.swap(tmp);
529  }
530 
532  void save(const char* fname) const
533  {
534  assert(m_edge_set);
535  ETX(kjb_c::write_edge_set(m_edge_set, fname));
536  }
537 
539  void load(const char* fname)
540  {
541  ETX(kjb_c::read_edge_set(&m_edge_set, fname));
542  }
543 
544 
546  void write(const char* fname) const
547  {
548  save(fname);
549  }
550 
551 
553  void read(const char* fname)
554  {
555  load(fname);
556  }
557 
562 
563 
565  const kjb_c::Edge_set* c_ptr() const { return m_edge_set; }
566 
567 private:
568  //C++ Wrappers for the underlying c edge_set structure
569  kjb_c::Edge_set* m_edge_set;
570 
571 private:
572 #ifdef KJB_HAVE_BST_SERIAL
573  friend class boost::serialization::access;
574 
575 
577  template <class Archive>
578  void save(Archive& ar, const unsigned int /* version */) const
579  {
580  char* buffer = 0;
581  size_t length;
582 
583  kjb_c::serialize_edge_set(m_edge_set, &buffer, &length);
584  std::string str_tmp(buffer);
585  ar & str_tmp;
586 
587  kjb_c::kjb_free(buffer);
588  }
589 
591  template <class Archive>
592  void load(Archive& ar, const unsigned int /* version */)
593  {
594  std::string buffer;
595  ar & buffer;
596  kjb_c::unserialize_edge_set(&m_edge_set, buffer.c_str());
597  }
598  BOOST_SERIALIZATION_SPLIT_MEMBER()
599 #endif /* KJB_HAVE_BST_SERIAL */
600 
601 };
602 
603 inline void load(Edge_set& edges, const std::string& fname)
604 {
605  edges.load(fname.c_str());
606 }
607 
608 inline void save(const Edge_set& edges, const std::string& fname)
609 {
610  edges.save(fname.c_str());
611 }
612 
613 typedef boost::shared_ptr<Edge_set> Edge_set_ptr;
614 
629 {
630 public:
631 
656  float sigma = 1,
657  float begin_thresh = 0,
658  float end_thresh = 0,
659  size_t padding = 0,
660  bool use_fourier = true) :
661  m_sigma(sigma),
662  m_begin_thresh(begin_thresh),
663  m_end_thresh(end_thresh),
664  m_padding(padding),
665  m_fourier(use_fourier)
666  {}
667 
669  {
670  Canny_edge_detector tmp(other);
671  swap(tmp);
672  return *this;
673  }
674 
678  {
679  using std::swap;
680  swap(m_sigma, other.m_sigma);
681  swap(m_begin_thresh, other.m_begin_thresh);
682  swap(m_end_thresh, other.m_end_thresh);
683  swap(m_padding, other.m_padding);
684  swap(m_fourier, other.m_fourier);
685  }
686 
687 
700  const Image& img,
701  bool noiseless_data = false
702  ) const
703  {
704  kjb_c::Edge_set* edge_set = NULL;
705  ETX(kjb_c::detect_image_edge_set(
706  &edge_set,
707  img.c_ptr(),
708  m_sigma,
709  m_begin_thresh,
710  m_end_thresh,
711  m_padding,
712  m_fourier,
713  noiseless_data));
714 
715  // wrap c struct in c++ object
716  return Edge_set_ptr(new Edge_set(edge_set));
717  }
718 
730  kjb::Edge_set* detect_edges(const Image& img, bool noiseless_data = false)
731  {
732 
733  kjb_c::Edge_set* edge_set = NULL;
734  ETX(kjb_c::detect_image_edge_set(
735  &edge_set,
736  img.c_ptr(),
737  m_sigma,
738  m_begin_thresh,
739  m_end_thresh,
740  m_padding,
741  m_fourier,
742  noiseless_data));
743 
744  // wrap c struct in c++ object
745  return new Edge_set(edge_set);
746  }
747 
748 private:
749 
751  float m_sigma;
752 
754  float m_begin_thresh;
755 
757  float m_end_thresh;
758 
760  size_t m_padding;
761 
763  bool m_fourier;
764 };
765 
766 
767 
768 // ///////////////////
769 // Global Functions //
770 // ///////////////////
771 
772 
782 Image edges_to_image(
783  const Edge_set& edges,
784  bool invert = false,
785  size_t remove_borders = 0
786 );
787 
809 Edge_set_ptr edge_image_to_edge_points(const Image& i, bool oriented = false);
810 
811 
812 } // namespace kjb
813 #endif
bool get_silhouette() const
Rate of change in brightness along the columns at the point.
Definition: edge.h:87
~Edge_set()
Definition: edge.h:304
void draw_edge(Image &img, float r, float g, float b, unsigned int edge_index) const
draws the edge with index edge_index onto the input image, using color (r,g,b). This function expects...
Definition: edge.h:481
const kjb_c::Edge * _c_ptr() const
returns a const pointer to the c Edge structure
Definition: edge.h:194
#define ETX(a)
Definition: l_exception.h:67
Edge_set_ptr edge_image_to_edge_points(const Image &i, bool oriented)
Definition: edge.cpp:107
void set_drow(double idrow)
returns the rate of change in brightness along the rows at the point.
Definition: edge.h:99
Edge & operator=(const Edge &edge)
Definition: edge.h:171
unsigned int get_num_points() const
returns the number of edge points in this edge
Definition: edge.h:178
void randomly_color_edge(Image &img, unsigned int edge_index) const
draws the edge with index edge_index onto the input image, using a random color
Definition: edge.h:492
const kjb_c::Edge_point & operator[](size_t i) const
Definition: edge.h:351
size_t num_cols() const
returns the number of columns in the image the edges were detected from
Definition: edge.h:393
void draw(Image &img, float r, float g, float b) const
draws all the edges onto the input image, using color (r,g,b). This function expects color values bet...
Definition: edge.h:505
Edge_set(const std::string &fname)
Constructs an Edge_set by reading it from an input file.
Definition: edge.h:255
size_t get_num_rows() const
alias of num_rows() to comply with other KJB dimensioned objects.
Definition: edge.h:390
size_t size() const
Definition: edge.h:368
Canny_edge_detector(float sigma=1, float begin_thresh=0, float end_thresh=0, size_t padding=0, bool use_fourier=true)
Definition: edge.h:655
void swap(Canny_edge_detector &other)
Definition: edge.h:677
kjb_c::Edge_point & operator()(size_t edge_num, size_t point_num)
Definition: edge.h:317
Edge_set()
Definition: edge.h:236
r
Definition: APPgetLargeConnectedEdges.m:127
Canny_edge_detector & operator=(const Canny_edge_detector &other)
Definition: edge.h:668
const kjb_c::Edge_set * c_ptr() const
Returns a const pointer to the underlying c structure.
Definition: edge.h:565
void save(const char *fname) const
saves this edge set on a file
Definition: edge.h:532
size_t edge_length(size_t i_edge) const
Definition: edge.h:399
kjb_c::Edge_point & operator[](size_t i)
Definition: edge.h:343
size_t length(const C &cner)
Counts the total number of elements in a 2D STL-style container.
Definition: l_util.h:17
~Edge_point()
Definition: edge.h:56
const kjb_c::Edge_point * _c_ptr()
Rate of change in brightness along the columns at the point.
Definition: edge.h:110
const Impl_type * c_ptr() const
Access a pointer to the underlying implementation.
Definition: i_image.cpp:419
void set_row(unsigned int irow)
returns the row the point lies in
Definition: edge.h:93
Image edges_to_image(const Edge_set &edges, bool invert, size_t remove_borders)
Definition: edge.cpp:72
Edge_set(kjb_c::Edge_set *in)
Constructs an Edge_set by reading it from an input stream.
Definition: edge.h:241
Definition: edge.h:150
void remove_short_edges(uint32_t min_length)
Removes from the edge set all the edges whose length is shorter than min_length.
Definition: edge.h:415
void set_dcol(double idcol)
returns the rate of change in brightness along the columns at the point.
Definition: edge.h:96
void draw(Image &img, float r, float g, float b) const
draws the edge onto the input image, using color (r,g,b). This funcstion expects color values between...
Definition: edge.h:203
unsigned int get_col() const
returns the column the point lies in
Definition: edge.h:70
Edge_set_ptr operator()(const Image &img, bool noiseless_data=false) const
Definition: edge.h:699
void read(const char *fname)
reads this edge set from a file
Definition: edge.h:553
void set_edge_set(kjb_c::Edge_set *iedge_set)
clear the previous edge set and makes this class point to the input c edge set
Definition: edge.h:380
size_t get_total_edge_points() const
Definition: edge.h:406
Impl_type * non_const_c_ptr() const
Access a pointer to the underlying implementation, use with care.
Definition: i_image.h:452
double get_drow() const
returns the rate of change in brightness along the rows at the point.
Definition: edge.h:79
Edge_point & operator=(const Edge_point &pt)
Definition: edge.h:63
Implements the Canny edge detection algorithm.
Definition: edge.h:628
double get_dcol() const
returns the rate of change in brightness along the columns at the point.
Definition: edge.h:76
kjb::Edge_set * detect_edges(const Image &img, bool noiseless_data=false)
Detect edges in img.
Definition: edge.h:730
void break_edges_at_corners(float thresh, uint32_t num_avg)
For each edge, it finds the edge point with the largest gradient difference on either side...
Definition: edge.h:460
~Edge()
Definition: edge.h:164
boost::shared_ptr< Edge_set > Edge_set_ptr
Definition: edge.h:613
Edge_set(const char *fname)
Constructs an Edge_set by reading it from an input file.
Definition: edge.h:248
void set_gradient_magnitude(double imag)
returns the magnitude of the gradient
Definition: edge.h:102
void load(Edge_set &edges, const std::string &fname)
Definition: edge.h:603
Edge(const Edge &edge)
Definition: edge.h:166
void load(const char *fname)
loads this edge set from a file
Definition: edge.h:539
Edge(kjb_c::Edge *edge)
Definition: edge.h:153
size_t get_num_cols() const
alias of num_cols() to comply with other KJB dimensioned objects.
Definition: edge.h:396
Edge_set(const std::vector< kjb_c::Edge_point > &edge_pts, int num_rows_in, int num_cols_in)
Definition: edge.h:272
Edge get_edge(unsigned int i) const
returns the ith edge
Definition: edge.h:374
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
size_t num_edges() const
Definition: edge.h:359
Edge_point(const Edge_point &pt)
Definition: edge.h:58
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
Edge_set & operator=(const Edge_set &other)
Definition: edge.h:309
const kjb_c::Edge_point & operator()(size_t edge_num, size_t point_num) const
Definition: edge.h:326
Edge_point get_edge_point(unsigned int i) const
returns the ith edge point of this edge
Definition: edge.h:184
void save(const Edge_set &edges, const std::string &fname)
Definition: edge.h:608
Definition: edge.h:48
double get_gradient_magnitude() const
returns the magnitude of the gradient
Definition: edge.h:82
void swap(Edge_set &other)
Swaps the content of this edgeset with the edgeset provided in input.
Definition: edge.h:336
void write(const char *fname) const
writes this edge set to a file
Definition: edge.h:546
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
Definition: edge.h:233
void set_silhouette(bool isilhouette)
sets the silhouette field of this edge point
Definition: edge.h:105
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
unsigned int find_index(const kjb::Edge &iedge) const
Finds the index where the Edge pointed by iedge is stored in the edge_set. Notice that this is based ...
Definition: edge.h:426
void swap(Image &other)
Swap the implementation of two images.
Definition: i_image.h:220
Edge_point(kjb_c::Edge_point *pt)
Definition: edge.h:51
edges
Definition: APPgetLargeConnectedEdges.m:85
void randomly_color(Image &img) const
draws the edge onto the input image, using a random color
Definition: edge.h:216
Code for a wrapper class around the C struct KJB_Image.
void randomly_color(Image &img)
draws all the edges onto the input image, using color (r,g,b). Each edge is drawn using a different r...
Definition: edge.h:522
void sample_edge_set(float p)
Randomly samples a subset of edge points from this set.
Definition: edge.h:467
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
bool is_edge_set_consistenct()
For debug purposes, checks that all the c++ wrappers are consistent with the underlying c structures...
Definition: edge.cpp:28
void draw(Image &img, float r, float g, float b) const
draws this edge point onto an image
Definition: edge.h:116
size_t num_rows() const
returns the number of rows in the image the edges were detected from
Definition: edge.h:387
Edge_set(const Edge_set &edge_in)
Definition: edge.h:261
void remove_edge(unsigned int iindex)
Removes the edge at index edge_id.
Definition: edge.h:441
unsigned int get_row() const
returns the row the point lies in
Definition: edge.h:73
void set_col(unsigned int icol)
sets the column the point lies in
Definition: edge.h:90