STIRA  0.1
Public Member Functions | List of all members
stira::common::Curve Class Reference

class that contains a curve. For us, a curve is a list of 8-neighborhood connected pixels in an stl vector More...

#include <Curve.h>

Public Member Functions

 Curve ()
 empty constructor
 
 Curve (std::vector< Point< int > > pointsOnCurve)
 constructor with initial set of points More...
 
void Clear ()
 
double GetAverageX () const
 gets the average of all the x coordinates of the pixels on the curve
 
double GetAverageY () const
 gets the average of all the y coordinates of the pixels on the curve
 
int GetCorrespondingY (int x) const
 gets the y coordinate of point on the curve for a given x coordinate for now, we assume 1 point on the curve for a given x coordinate if no point with this x coordinate is found, -1 is returned
 
int GetLength () const
 gets the number of the pixels on the curve
 
int GetY (int x) const
 Gets y coordinate that corresponds to the given x coordinate along the curve If there are more points, the first that is encountered is returned; if no point was found, -1 is returned. More...
 
void AddPoint (Point< int > point)
 adds a single point at the end of the curve More...
 
void AddPoints (std::vector< Point< int > > points)
 adds a series of points at the end of the curve More...
 
std::vector< Point< int > > GetPoints ()
 gets the stl vector with the points on the curve
 
Point< int > GetStartPoint () const
 gets first point in the stl vector with the points on the curve
 
Point< int > GetEndPoint () const
 gets last point in the stl vector with the points on the curve
 
std::vector< Point< int > > GetExtremePointsX (int &xMin, int &xMax, bool usePoints=false)
 Gets the points on the curve with minimum and maximum x coordinate. More...
 
std::vector< Point< int > > GetPointsMinimumX (int &xMin, bool usePoints=false)
 Gets the points on the curve with minimum x coordinate. More...
 
std::vector< Point< int > > GetPointsMaximumX (int &xMax, bool usePoints=false)
 Gets the points on the curve with maximum x coordinate. More...
 
Point< int > GetPoint (int i) const
 gets point with index i in the stl vector with the points on the curve
 
bool ChangeCoordinatesForPoint (int i, int x, int y)
 
void SortOnCoordinateX ()
 sorts all points in the stl vector on their x coordinates
 
void SortOnCoordinateY ()
 sorts all points in the stl vector on their y coordinates
 
void WritePointsToStdOut (int intervalSize=10)
 writes points of the curve to standard out More...
 
bool GetIsUsed ()
 Gets if the curve is already used.
 
void SetIsUsed (bool isUsed)
 Sets if the curve is already used. More...
 
bool GetHadBranches ()
 
void SetHadBranches (bool hadBranches)
 
bool GetDoesCurveSpanFullImage ()
 
void SetDoesCurveSpanFullImage (bool doesSpan)
 
std::pair< Point< int >, Point< int > > GetClosestEndPoints (Curve otherCurve)
 given two open curves, we find which of the end points of the two curves are closest This method is used to determine how to connect two curves by their closest end points More...
 
Curve CreateMergedCurve (Curve otherCurve)
 creates a new curve that is build from the current curve connected with the curve passed in the argument More...
 
void ConnectToCurve (Curve otherCurve)
 connects the curve passed in the argument to the current curve More...
 
std::pair< double, double > ComputeVerticalDistanceToCurve (Curve otherCurve)
 computes point-to-point absolute distance between the y coordinates of the curve passed in the argument and this curve More...
 
bool AreNeighbors (Point< int > inPoint1, Point< int > inPoint2)
 checks if two given points are neighbors More...
 
void SmoothCurveY (int smoothHalfDistance)
 smooths a curve in the y direction by averaging y coordinates of points along the curve More...
 
bool WritePointsToText (std::string fileName)
 writes points of current curve to a text file More...
 

Detailed Description

class that contains a curve. For us, a curve is a list of 8-neighborhood connected pixels in an stl vector

Constructor & Destructor Documentation

stira::common::Curve::Curve ( std::vector< Point< int > >  pointsOnCurve)

constructor with initial set of points

Parameters
pointsOnCurvestl vector containing all points on the curve
Warning
does not check if the points are connected to each other; please do this yourself

Member Function Documentation

void stira::common::Curve::AddPoint ( Point< int >  point)

adds a single point at the end of the curve

Parameters
pointpoint added at end of curve
Warning
does not check if the point is connected to the curve; please do this yourself

Referenced by AddPoints().

void stira::common::Curve::AddPoints ( std::vector< Point< int > >  points)

adds a series of points at the end of the curve

Warning
does not check if the points are connected to each other or to the curve; please do this yourself

References AddPoint().

Referenced by ConnectToCurve(), and CreateMergedCurve().

bool stira::common::Curve::AreNeighbors ( Point< int >  inPoint1,
Point< int >  inPoint2 
)

checks if two given points are neighbors

Parameters
inPoint1first point to be checked
inPoint2second point to be checked

References stira::common::Point< T >::x, and stira::common::Point< T >::y.

std::pair< double, double > stira::common::Curve::ComputeVerticalDistanceToCurve ( Curve  otherCurve)

computes point-to-point absolute distance between the y coordinates of the curve passed in the argument and this curve

Parameters
otherCurvethe other curve to merge this curve with (adds it to this curve, so original curve doen not exist anymore )
Returns
a pair of doubles, representing first the maximum distance between the curves and second the mean distance between the curves

References GetLength(), and GetPoints().

void stira::common::Curve::ConnectToCurve ( Curve  otherCurve)

connects the curve passed in the argument to the current curve

Parameters
otherCurvethe other curve to merge this curve with (adds it to this curve, so original curve doen not exist anymore )

References AddPoints(), stira::common::DrawFigures::BresenhamDrawLine(), stira::common::Point< T >::GetDistance(), GetEndPoint(), GetPoints(), GetStartPoint(), SortOnCoordinateX(), stira::common::Point< T >::x, and stira::common::Point< T >::y.

Referenced by CreateMergedCurve().

Curve stira::common::Curve::CreateMergedCurve ( Curve  otherCurve)

creates a new curve that is build from the current curve connected with the curve passed in the argument

Parameters
otherCurvethe other curve to merge this curve with (returns new merged curve, leaving this curve unaltered)

References AddPoints(), and ConnectToCurve().

std::pair< Point< int >, Point< int > > stira::common::Curve::GetClosestEndPoints ( Curve  otherCurve)

given two open curves, we find which of the end points of the two curves are closest This method is used to determine how to connect two curves by their closest end points

Parameters
otherCurvethe other curve to check the end points from
Returns
a pair of end points, the first from the first curve and the second from the second curve

References stira::common::Point< T >::GetDistance(), GetEndPoint(), GetStartPoint(), and stira::common::Point< T >::SetType().

std::vector< Point< int > > stira::common::Curve::GetExtremePointsX ( int &  xMin,
int &  xMax,
bool  usePoints = false 
)

Gets the points on the curve with minimum and maximum x coordinate.

Parameters
xMinthe minimum x coordinate; if usePoints is false, it will be computed in this method
xMaxthe maximum x coordinate; if usePoints is false, it will be computed in this method
usePointsif true, the xMin and xMax values will be used without checking; if false, the values are determined in this method

References GetPointsMaximumX(), and GetPointsMinimumX().

std::vector< Point< int > > stira::common::Curve::GetPointsMaximumX ( int &  xMax,
bool  usePoints = false 
)

Gets the points on the curve with maximum x coordinate.

Parameters
xMaxthe maximum x coordinate; if usePoints is false, it will be computed in this method
usePointsif true, the xMax value the points will be used without checking; if false, the values are determined in this method

Referenced by GetExtremePointsX().

std::vector< Point< int > > stira::common::Curve::GetPointsMinimumX ( int &  xMin,
bool  usePoints = false 
)

Gets the points on the curve with minimum x coordinate.

Parameters
xMinthe minimum x coordinate; if usePoints is false, it will be computed in this method
usePointsif true, the xMin value will be used without checking; if false, the values are determined in this method

Referenced by GetExtremePointsX().

int stira::common::Curve::GetY ( int  x) const

Gets y coordinate that corresponds to the given x coordinate along the curve If there are more points, the first that is encountered is returned; if no point was found, -1 is returned.

Parameters
xx coordinate
void stira::common::Curve::SetIsUsed ( bool  isUsed)

Sets if the curve is already used.

Parameters
isUsedflag if current curve is used
void stira::common::Curve::SmoothCurveY ( int  smoothHalfDistance)

smooths a curve in the y direction by averaging y coordinates of points along the curve

Parameters
smoothHalfDistancehalf of the smoothing window

References GetLength(), and SortOnCoordinateX().

void stira::common::Curve::WritePointsToStdOut ( int  intervalSize = 10)

writes points of the curve to standard out

Parameters
intervalSizewe write only every intervalSize'th point to standard out
bool stira::common::Curve::WritePointsToText ( std::string  fileName)

writes points of current curve to a text file

Parameters
fileNamename of text file to write the points to

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