diff --git a/Code/Seg/BlurredSegment/blurredsegment.cpp b/Code/Seg/BlurredSegment/blurredsegment.cpp index dd5717aadf9a5dff54043b4eadb1f761cf2b6338..a9bfae2e791c193667d1625c26a62375fcb81528 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 495cd6a39596e161928f3638e48efdf31ab7c3a8..603d214647e62e9535b41b78507e7536a31a60ac 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 87824830c1d0ca2c80c8c837c8c6fc3399b7b765..8f48d13a39d92aec6fc7e38783d0ff708c32f1c8 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 ba2b51da4632340040c54928a6dbe2b69e970237..bcf16db72cbe09270f0f656810978e7e6ed82998 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 1bfc85b4ba918463097de3cedc437fb050fe4d4b..a34c86fb67064478733494a46fc4ba4652860379 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 d76a5cd2954dff6ecd016deae359c8bd74660c8a..e185a4e0f83f3369e88da1864561d7afdeb701ea 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 719a8c2154da62bf2b6a2c02e3a14ede50738acc..85248f34bc1b49e9377184f5f1212fe029fc7cde 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 410633ec2d30a5c8277bc1b66ef00178aafb671b..2ed9b922ff5ee4836e88da04757180d77a374536 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: