From 83d82ad0604143509094e924a29574af4be6f740 Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Thu, 13 Dec 2018 10:32:02 +0100 Subject: [PATCH] assigned width control relax --- Code/Seg/BlurredSegment/blurredsegment.cpp | 2 +- Code/Seg/BlurredSegment/blurredsegment.h | 2 +- Code/Seg/BlurredSegment/blurredsegmentproto.cpp | 4 ++-- Code/Seg/BlurredSegment/blurredsegmentproto.h | 2 +- Code/Seg/BlurredSegment/bsdetector.cpp | 3 +-- Code/Seg/BlurredSegment/bstracker.cpp | 9 +++++---- Code/Seg/BlurredSegment/linespacefilter.cpp | 4 ++-- Code/Seg/ImageTools/absrat.h | 7 +++++++ 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Code/Seg/BlurredSegment/blurredsegment.cpp b/Code/Seg/BlurredSegment/blurredsegment.cpp index dd5717a..a9bfae2 100755 --- a/Code/Seg/BlurredSegment/blurredsegment.cpp +++ b/Code/Seg/BlurredSegment/blurredsegment.cpp @@ -27,7 +27,7 @@ BlurredSegment::~BlurredSegment () } -AbsRat BlurredSegment::segmentRationalWidth () const +AbsRat BlurredSegment::minimalWidth () const { return (AbsRat (dss->width (), dss->period ())); } diff --git a/Code/Seg/BlurredSegment/blurredsegment.h b/Code/Seg/BlurredSegment/blurredsegment.h index 495cd6a..603d214 100755 --- a/Code/Seg/BlurredSegment/blurredsegment.h +++ b/Code/Seg/BlurredSegment/blurredsegment.h @@ -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). diff --git a/Code/Seg/BlurredSegment/blurredsegmentproto.cpp b/Code/Seg/BlurredSegment/blurredsegmentproto.cpp index 8782483..8f48d13 100755 --- a/Code/Seg/BlurredSegment/blurredsegmentproto.cpp +++ b/Code/Seg/BlurredSegment/blurredsegmentproto.cpp @@ -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; diff --git a/Code/Seg/BlurredSegment/blurredsegmentproto.h b/Code/Seg/BlurredSegment/blurredsegmentproto.h index ba2b51d..bcf16db 100755 --- a/Code/Seg/BlurredSegment/blurredsegmentproto.h +++ b/Code/Seg/BlurredSegment/blurredsegmentproto.h @@ -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. diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/Seg/BlurredSegment/bsdetector.cpp index 1bfc85b..a34c86f 100755 --- a/Code/Seg/BlurredSegment/bsdetector.cpp +++ b/Code/Seg/BlurredSegment/bsdetector.cpp @@ -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); diff --git a/Code/Seg/BlurredSegment/bstracker.cpp b/Code/Seg/BlurredSegment/bstracker.cpp index d76a5cd..e185a4e 100755 --- a/Code/Seg/BlurredSegment/bstracker.cpp +++ b/Code/Seg/BlurredSegment/bstracker.cpp @@ -270,12 +270,13 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i ¢er, 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 ¢er, 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 ¢er, 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 diff --git a/Code/Seg/BlurredSegment/linespacefilter.cpp b/Code/Seg/BlurredSegment/linespacefilter.cpp index 719a8c2..85248f3 100755 --- a/Code/Seg/BlurredSegment/linespacefilter.cpp +++ b/Code/Seg/BlurredSegment/linespacefilter.cpp @@ -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 (); diff --git a/Code/Seg/ImageTools/absrat.h b/Code/Seg/ImageTools/absrat.h index 410633e..2ed9b92 100755 --- a/Code/Seg/ImageTools/absrat.h +++ b/Code/Seg/ImageTools/absrat.h @@ -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: -- GitLab