10 #ifndef PIXPATH_H_UOFARIZONAVISION
11 #define PIXPATH_H_UOFARIZONAVISION 1
13 #include <l/l_error.h>
14 #include <l/l_global.h>
123 typedef std::vector< PixPoint > VecPP;
129 typedef std::map< PixPoint, unsigned > PPMap;
167 float hausdorff_dist_1side(
const PixPath& )
const;
191 int add_a_point_along_longest_segment();
193 int untangle_recursive(
int depth );
203 my_vpp.reserve( potential_size );
213 PixPath(
const std::string&,
int );
228 Some_error(
const std::string&
m,
const char* f,
int l )
246 return PixPath( potential_size );
279 return PixPath( pt_a, pt_b, sz );
303 my_vpp.at( index ) = newp;
312 if ( ppmap[ oldp ] <= 0 )
325 return my_vpp[ index ];
331 my_vpp.push_back( pp );
340 return my_vpp.size();
346 my_vpp.swap( vpp.my_vpp );
347 ppmap.swap( vpp.ppmap );
360 return my_vpp.begin();
372 return my_vpp.rbegin();
378 return my_vpp.rend();
458 return subrange( first, my_vpp.size() );
477 bool connected8(
bool emit_verbose_debug_output =
false )
const;
483 return my_vpp.front();
489 return my_vpp.back();
503 virtual int arclength( std::vector< float >* )
const;
518 std::string
str(
const std::string& separator =
"\n" )
const;
521 int save(
const std::string& filename )
const;
624 PPMap::const_iterator pn = ppmap.find( query_point );
625 return ( ppmap.end() == pn ) ? 0 : pn -> second;
666 int cubic_fit( std::vector<float>*
x, std::vector<float>* y,
682 return expel(
begin() + index_of_unwanted_point );
696 return std::max( hausdorff_dist_1side( that ),
697 that.hausdorff_dist_1side( *
this ) );
743 PixPoint bracket = my_vpp.at( index + 1 ) - my_vpp.at( index - 1 ),
744 here = my_vpp.at( index + 1 ) - my_vpp.at( index );
745 return bracket.
cross( here );
805 unsigned* endpoint_intersector_index = 00
980 int untangle_segments()
985 return untangle_recursive( 0 );
1009 template<
typename Ran >
1013 std::copy( begin, end, std::back_inserter( result ) );
Base class of all exceptions in the jwsc++ library.
Definition: l_exception.h:132
PixPath expel(const_iterator) const
Duplicate this path, except that we omit the indicated point.
Definition: pixpath.cpp:950
double angle_at(unsigned) const
Compute included angle at some interior point in a path.
Definition: pixpath.cpp:1098
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
PixPath merge_redundant_slopes() const
return a path with interior points removed but preserve all slopes.
Definition: pixpath.cpp:1450
VecPP::const_iterator const_iterator
constant iterator through PixPath points
Definition: pixpath.h:235
bool operator==(const PixPath &) const
Compare PixPaths; true iff the sequence of points is identical.
Definition: pixpath.cpp:750
PixPath(size_t potential_size)
ctor receives the size to reserve
Definition: pixpath.h:201
int save(const std::string &filename) const
Saves the path to an ASCII file, returns NO_ERROR or ERROR.
Definition: pixpath.cpp:407
PixPath cull_redundant_points() const
Remove "unnecessary" points (ones that can be bresenham interpolated)
Definition: pixpath.cpp:914
PixPoint front() const
Return (by value) the first point in the path.
Definition: pixpath.h:481
unsigned longest_segment(float *length=00) const
return index of first point of longest segment
Definition: pixpath.cpp:1298
theta
Definition: APPgetLargeConnectedEdges.m:108
const PixPoint & const_reference
Reference to an element – required to use std::back_inserter().
Definition: pixpath.h:219
virtual float hausdorff_distance(const PixPath &that) const
Compute the Hausdorff metric between two sets of points.
Definition: pixpath.h:694
virtual void pop_back()
Definition: pixpath.cpp:1668
virtual PixPath & append(const_iterator begin, const_iterator end)
Append a range from a given other path to the end of this path.
Definition: pixpath.cpp:152
virtual void push_back(const PixPoint &pp)
Vector-like appending a new PixPoint on the end of the object.
Definition: pixpath.h:329
bool operator!=(const PixPath &other) const
Compare PixPaths; true iff the sequence of points differs.
Definition: pixpath.h:527
static PixPath reserve(size_t potential_size=0)
named ctor creates an empty path but reserves some memory for it
Definition: pixpath.h:244
static PixPath fenceposts(const PixPoint &pt_a, const PixPoint &pt_b, size_t sz)
named ctor makes a path of evenly spaced points from a to b
Definition: pixpath.h:273
size_t length(const C &cner)
Counts the total number of elements in a 2D STL-style container.
Definition: l_util.h:17
Integer cross(const PixPoint &pp) const
return cross product of two PixPoints interpreted as 2-vectors.
Definition: pixpoint.h:327
unsigned member_near_centroid() const
return index of a member point nearest centroid() (qv)
Definition: pixpath.cpp:1382
virtual float arclength() const
compute and return polygonal path length of this path
Definition: pixpath.cpp:1637
static PixPath load(const std::string &filename)
named ctor loads path coordinates from an ASCII file
Definition: pixpath.h:250
const_reverse_iterator rend() const
return one-before-first iterator, in symmetry with end().
Definition: pixpath.h:376
Representation of a sequence of pixel coordinates.
Definition: pixpath.h:117
size_t size() const
Number of points in the path (not the same as its length).
Definition: pixpath.h:338
PixPath reverse() const
return a copy of this list after reversing the front-back order.
Definition: pixpath.h:651
const_iterator end() const
Rtn iterator pointing to just beyond the last point in the path.
Definition: pixpath.h:364
virtual int append_no_overlap(const PixPath &suffix)
Like append(), with extra avoid-the-duplicates fuss; overwrites.
Definition: pixpath.cpp:177
std::string str(const std::string &separator="\n") const
Return the path as an ASCII string.
Definition: pixpath.cpp:396
PixPath interpolate(bool forbid_self_intersection=false) const
This interpolates pixels between unconnected pixels.
Definition: pixpath.cpp:792
PixPoint::Integer bracket_cross_at(unsigned index) const
cross product of line segs (index-1,index+1) x (index,index+1)
Definition: pixpath.h:741
const_iterator begin() const
Return an iterator pointing to the first point in the path.
Definition: pixpath.h:358
PixPath append_trying_not_to_overlap(PixPath aaa, const PixPath &bbb)
apppend first to second, without duplicating aaa.back(), bbb.front()
Definition: pixpath.cpp:1661
int cubic_fit(std::vector< float > *x, std::vector< float > *y, int ref=0) const
Fit a cubic polynomial to the given list of x and y points.
Definition: pixpath.cpp:643
const_reverse_iterator rbegin() const
return a reverse-moving iterator to the last point in path
Definition: pixpath.h:370
x
Definition: APPgetLargeConnectedEdges.m:100
unsigned hits(const PixPoint &query_point) const
Return number of times (maybe 0) the path hits a query point.
Definition: pixpath.h:619
PixPath subrange(unsigned, unsigned) const
Returns a subrange of this PixPath object.
Definition: pixpath.cpp:223
Code for a wrapper class around the C struct Pixel.
float closest_adjacent_pair(const_iterator *pa=0) const
Find a pair of adjacent points at least as close as any other.
Definition: pixpath.cpp:1003
PixPath suffix(unsigned first) const
Variation on subrange: return a suffix of this path (by value)
Definition: pixpath.h:456
PixPath copy_pixpoint_array(Ran begin, Ran end)
build a PixPath from a range of PixPoints, using random iterators
Definition: pixpath.h:1010
bool has_subsequence(const PixPath &subseq) const
tests whether a given path is a subsequence of this path
Definition: pixpath.cpp:1033
PixPoint nearest(const PixPoint &, const_iterator *q=00) const
Return the PixPath member closest to a given query point.
Definition: pixpath.cpp:548
bool boundbox_within_boundbox(const PixPath &outer) const
Test whether the axis-aligned bounding box of this path lies within the axis-aligned bounding box of ...
Definition: pixpath.h:580
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
count
Definition: APPgetLargeConnectedEdges.m:71
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
PixPath operator+(const PixPath &) const
Add, element-by-element, two PixPaths of the same length.
Definition: pixpath.cpp:134
const PixPoint & operator[](unsigned index) const
Vector-like access to points (returning an rvalue).
Definition: pixpath.h:323
#define M_PI
Definition: fft.cpp:206
bool so_boundbox_holds_within(const PixPoint &q) const
sort of like boundbox_within_boundbox but works on a single point
Definition: pixpath.h:600
virtual ~PixPath()
obligatory dtor
Definition: pixpath.h:241
float closest_pair(const_iterator *pa=0, const_iterator *pb=0) const
Find the distance between closest pair of points, ignoring adjacency.
Definition: pixpath.cpp:1521
PixPoint back() const
Return (by value) the last point in the path.
Definition: pixpath.h:487
PixPath bresenham_line(const PixPoint &ca, const PixPoint &b)
ctor builds a sequence of points as a Bresenham straight line.
Definition: pixpath.cpp:262
virtual void swap(PixPath &vpp)
Swap the contents of two PixPaths.
Definition: pixpath.h:344
bool self_intersect(PixPoint *where=00) const
Reveal whether the path has any self-intersections.
Definition: pixpath.cpp:324
bool intersect_at_with(unsigned preindex1, unsigned preindex2, unsigned *endpoint_intersector_index=00) const
Test whether two segments of this path intersect.
Definition: pixpath.cpp:1118
Object thrown when the program does something thought impossible.
Definition: l_exception.h:358
virtual PixPoint boundbox_min_min() const
Return the corner point of a bounding box, with min x and y.
Definition: pixpath.cpp:492
bool do_segments_intersect(unsigned *s1=00, unsigned *s2=00, unsigned *count=00) const
quadratic time test whether any 2 path segments cross each other
Definition: pixpath.cpp:1230
Representation of an (x,y) pair of pixel coordinates.
Definition: pixpoint.h:57
bool connected8(bool emit_verbose_debug_output=false) const
Is the path all connected, using 8-connectivity?
Definition: pixpath.cpp:338
PixPath prefix(unsigned postlast) const
Variation on subrange: return a prefix of this path (by value)
Definition: pixpath.h:438
virtual void clear()
Discard all points.
Definition: pixpath.h:351
kjb::Vector2 centroid() const
return the "mean" of the points (nonempty, none may be unused)
Definition: pixpath.cpp:1362
for m
Definition: APPgetLargeConnectedEdges.m:64
static PixPath parse(const std::string &coords)
named ctor builds from string-format list of coordinates
Definition: pixpath.h:283
PixPath & ow_reverse()
Reverse the order of the points in the path (overwriting!)
Definition: pixpath.cpp:613
PixPath expel(size_t index_of_unwanted_point) const
Duplicate this path, except we omit the point with given index.
Definition: pixpath.h:680
VecPP::const_reverse_iterator const_reverse_iterator
constant reverse iterator through PixPath points
Definition: pixpath.h:238
double heading_shift_at(unsigned index) const
compute shift in "heading" angle at an interior point
Definition: pixpath.h:764
virtual PixPoint boundbox_max_max() const
Similar to boundbox_min_min() but returns maximum x, y coords.
Definition: pixpath.cpp:509
virtual PixPath & assign(unsigned index, const PixPoint &newp)
Change a member of the path to a new PixPoint.
Definition: pixpath.h:299
Contains definition for classes PixPath, PixPathAc, DoubleCircle.
PixPath()
Default ctor starts as empty, and you can push points onto it.
Definition: pixpath.h:198
int Integer
any signed integer valued type is fine
Definition: pixpoint.h:60
PixPoint value_type
Element type – required to use std::back_inserter() in c++11.
Definition: pixpath.h:222