Skip to content
Snippets Groups Projects
Commit 83d82ad0 authored by even's avatar even
Browse files

assigned width control relax

parent 4dc99b67
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ BlurredSegment::~BlurredSegment ()
}
AbsRat BlurredSegment::segmentRationalWidth () const
AbsRat BlurredSegment::minimalWidth () const
{
return (AbsRat (dss->width (), dss->period ()));
}
......
......@@ -43,7 +43,7 @@ public:
/**
* \brief Returns the minimal vertical or horizontal width.
*/
virtual AbsRat segmentRationalWidth () const;
virtual AbsRat minimalWidth () const;
/**
* \brief Returns if the segment has non null thickness (not aligned points).
......
......@@ -56,7 +56,7 @@ BlurredSegmentProto::~BlurredSegmentProto ()
}
AbsRat BlurredSegmentProto::segmentRationalWidth () const
AbsRat BlurredSegmentProto::minimalWidth () const
{
return (convexhull != NULL ? convexhull->rationalThickness ()
: AbsRat (0, 1));
......@@ -200,7 +200,7 @@ bool BlurredSegmentProto::addRight (Pt2i pix)
bool BlurredSegmentProto::addPoint (Pt2i p, bool onleft)
{
bool inserted = convexhull->addPointDS (p, onleft);
if ((segmentRationalWidth ()).greaterThan (maxWidth))
if ((minimalWidth ()).greaterThan (maxWidth))
{
if (inserted) convexhull->restore ();
return false;
......
......@@ -44,7 +44,7 @@ public:
/**
* \brief Returns the minimal vertical or horizontal width.
*/
AbsRat segmentRationalWidth () const;
AbsRat minimalWidth () const;
/**
* \brief Returns the requested max width of the segment.
......
......@@ -207,8 +207,7 @@ void BSDetector::detect (const Pt2i &p1, const Pt2i &p2,
if (l != 0)
{
Pt2i pcentral = bspre->getSegment()->centerOfIntersection (prep1, prep2);
AbsRat sw = bspre->segmentRationalWidth ();
int detw = 2 * (1 + bspre->segmentRationalWidth().floor ());
int detw = 2 * (1 + bspre->minimalWidth().floor ());
if (detw < PRELIM_MIN_HALF_WIDTH) detw = PRELIM_MIN_HALF_WIDTH;
int dx = (int) ((v0.y () * detw) / l);
int dy = (int) (- (v0.x () * detw) / l);
......
......@@ -270,12 +270,13 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
while (scanningRight || scanningLeft)
{
count ++;
AbsRat sw = bs.segmentRationalWidth ();
AbsRat sw = bs.minimalWidth ();
// Handles thickenning
if (thickenOn && stableWidthCount >= thickenningLimit)
{
bs.setMaxWidth (sw);
AbsRat finalWidth (sw.sum (1));
if (finalWidth.lessThan (bs.getMaxWidth ())) bs.setMaxWidth (finalWidth);
thickenOn = false;
}
......@@ -342,7 +343,7 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
stableWidthCount ++;
if (added)
{
if (sw.lessThan (bs.segmentRationalWidth ())) stableWidthCount = 0;
if (sw.lessThan (bs.minimalWidth ())) stableWidthCount = 0;
rscan = count;
if (rstop == 0) rstart = 0;
else
......@@ -390,7 +391,7 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
stableWidthCount ++;
if (added)
{
if (sw.lessThan (bs.segmentRationalWidth ())) stableWidthCount = 0;
if (sw.lessThan (bs.minimalWidth ())) stableWidthCount = 0;
lscan = count;
if (lstop == 0) lstart = 0;
else
......
......@@ -73,7 +73,7 @@ BlurredSegment *LineSpaceFilter::filter (BlurredSegment *bs)
const vector<Pt2i> *bslineright = bs->getRightLine ();
const vector<Pt2i> *bsright = bs->getRightPoints ();
Vr2i sv = bs->getSupportVector ();
AbsRat segwidth = bs->segmentRationalWidth ();
AbsRat segwidth = bs->minimalWidth ();
Vr2i bbs = bs->boundingBoxSize ();
init (bsstart.x (), bsstart.y (), -sv.y (), sv.x (),
sqrt (bbs.x () * bbs.x () + bbs.y () * bbs.y ()),
......@@ -115,7 +115,7 @@ BlurredSegment *LineSpaceFilter::filter (BlurredSegment *bs)
// Returns a blurred segment with the accepted points
int mw = 1;
AbsRat sw = bs->segmentRationalWidth ();
AbsRat sw = bs->minimalWidth ();
if (sw.denominator () != 0) mw += sw.numerator () / sw.denominator ();
BlurredSegmentProto resbs (mw, bsstart, leftIn, rightIn);
bsFinalSize = resbs.size ();
......
......@@ -155,6 +155,13 @@ public:
*/
void mult (const AbsRat &val);
/**
* @fn AbsRat sum (int val) const
* \brief Returns the sum of the rational with an integer value.
* @param val integer value.
*/
inline AbsRat sum (int val) const { return (AbsRat (num + val * den, den)); }
protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment