From 3d4de8feb231afc36c93dbeb8286877976d754b6 Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Wed, 1 May 2019 13:07:09 +0200 Subject: [PATCH] Article : intro and last comparisons --- Article/Expe_auto/compTable.tex | 20 ++++++++-------- Article/Fig_synth/statsTable.tex | 4 ++-- Article/abstract.tex | 8 +++---- Article/expeV2.tex | 3 ++- Article/introV2.tex | 17 +++++++------- Article/methodV2.tex | 2 +- Article/notionsV2.tex | 15 ++++++------ Code/FBSD/BSTools/bsdetectionwidget.cpp | 8 +++++++ Code/FBSD/BSTools/extlines.cpp | 23 ++++++++++++------- .../BlurredSegment/blurredsegmentproto.cpp | 9 ++++---- .../FBSD/BlurredSegment/blurredsegmentproto.h | 6 +++++ Code/FBSD/BlurredSegment/bsdetector.cpp | 2 +- Code/FBSD/BlurredSegment/bstracker.cpp | 12 ++++++---- Code/FBSD/ConvexHull/antipodal.cpp | 11 +++++---- Code/FBSD/ConvexHull/antipodal.h | 16 +++++++++---- Code/FBSD/ConvexHull/convexhull.cpp | 13 +++++------ Code/FBSD/ConvexHull/convexhull.h | 9 ++++---- 17 files changed, 107 insertions(+), 71 deletions(-) diff --git a/Article/Expe_auto/compTable.tex b/Article/Expe_auto/compTable.tex index 10ccfd0..619e13c 100644 --- a/Article/Expe_auto/compTable.tex +++ b/Article/Expe_auto/compTable.tex @@ -1,20 +1,20 @@ -\begin{tabular}{|l||r@{$\pm$}r|r@{$\pm$}r|r@{$\pm$}r|r@{$\pm$}r|r@{$\pm$}r|} +\begin{tabular}{|l||r@{~$\pm~$}r|r@{~$\pm$~}r|r@{~$\pm$~}r|r@{~$\pm$~}r|r@{~$\pm$~}r|} \hline Measure $M$ & \multicolumn{2}{c|}{$T$ (ms)} & \multicolumn{2}{c|}{$C$ (\%)} & \multicolumn{2}{c|}{$N$} & \multicolumn{2}{c|}{$L$ (pixels)} & \multicolumn{2}{c|}{$L/N$} \\ \hline LSD -& 63.2 & 14.0 & 60.9 & 11.2 -& 561 & 202 & 17956 & 5387 & 33.5 & 7.7 \\ +& 63.5 & 13.6~ & 60.9 & 11.2~ +& 536 & 193~ & 17745 & 5337 & 34.6 & 7.9~ \\ ED-Lines -& 55.5 & 10.0 & 64.0 & 11.2 -& 617 & 228 & 19775 & 5790 & 33.8 & 8.3 \\ +& 55.5 & 9.9~ & 64.0 & 11.2~ +& 570 & 210~ & 19351 & 5669 & 35.8 & 8.9~ \\ CannyLines -& 69.8 & 10.5 & 60.5 & 10.6 -& 478 & 142 & 17779 & 4407 & 38.8 & 10.1 \\ -Our detector -& 68.7 & 15.8 & \textbf{67.9} & \textbf{9.6} -& 449 & 104 & 19175 & 3912 & \textbf{43.7} & 7.7 \\ +& 69.6 & 10.5~ & 60.5 & 10.6~ +& 467 & 138~ & 17679 & 4398 & 39.5 & 10.1~ \\ +Our detector ~~ +& ~66.9 & 15.6~ & ~\textbf{67.9} & \textbf{9.6}~ +& ~478 & 110~ & 19472 & 3914 & ~\textbf{41.7} & \textbf{7.5}~ \\ \hline \end{tabular} diff --git a/Article/Fig_synth/statsTable.tex b/Article/Fig_synth/statsTable.tex index d93b912..e74ea9a 100644 --- a/Article/Fig_synth/statsTable.tex +++ b/Article/Fig_synth/statsTable.tex @@ -14,9 +14,9 @@ Recall (ratio of true detection, \%): $R = \#(D\cap S)/\#S$ & 89.20 & $\pm$ & 3.94 & \textbf{90.08} & $\pm$ & \textbf{2.77} \\ F-measure (harmonic mean,\%): $F = 2\times P\times R/(P+R)$ & 79.85 & $\pm$ & 6.78 & \textbf{84.17} & $\pm$ & \textbf{4.17} \\ -Thickness difference (in pixels) to matched input segment +Thickness difference (pixels) to matched input segment & 0.92 & $\pm$ & 0.31 & \textbf{0.76} & $\pm$ & \textbf{0.23} \\ -Angle difference (in degrees) to matched input segment +Angle difference (degrees) to matched input segment & 1.48 & $\pm$ & 1.42 & \textbf{1.05} & $\pm$ & \textbf{0.80} \\ \hline \end{tabular} diff --git a/Article/abstract.tex b/Article/abstract.tex index 74c13ef..5cd7860 100755 --- a/Article/abstract.tex +++ b/Article/abstract.tex @@ -2,9 +2,9 @@ detector in gray-level images, where line segments are enriched with a thickness parameter intended to provide a quality criterion on the extracted feature. -This study firstly enhances previous works on interactive -line detection with a better estimation of the segment thickness and -orientation through two main improvements: adaptive directional scans and -the control of assigned thickness to the detection algorithm. +This study is based on a previous work on interactive line detection +in gray level images. At first, a better estimation of the segment thickness +and orientation is achieved through two main improvements: +adaptive directional scans and control of assigned thickness. Then, a new contribution to the automatic detection of all the segments in a single image is also proposed and left available in an online demonstration. diff --git a/Article/expeV2.tex b/Article/expeV2.tex index 942de10..1fddd26 100755 --- a/Article/expeV2.tex +++ b/Article/expeV2.tex @@ -74,7 +74,8 @@ that the new detector is faster and finds more edges than the previous one. \caption{Measured performance of both versions of the detector on a set of synthesized images. Old refers to the previous version \cite{KerautretEven09}, whereas new is -the present detector augmented with ADS and CAW concepts. +the present detector (with adaptive directional scans and control of +assigned width). $S$ is the set of all the input segments, $D$ the set of all the detected blurred segments.} \label{tab:synth} diff --git a/Article/introV2.tex b/Article/introV2.tex index 52688b0..b317741 100755 --- a/Article/introV2.tex +++ b/Article/introV2.tex @@ -20,7 +20,7 @@ quality, based on intrinsic properties such as sharpness, connectivity or scattering. This information could be useful to get some confidence level and help to classify these features for further exploitation. -In computer vision applications, it could also be a base for uncertainty +It could also be a base for uncertainty propagation within 3D interpretation tools, in order to dispose of complementary measures to reprojection errors for local accuracy evaluation. @@ -48,15 +48,16 @@ with optimal thickness and orientation in gray-level images for as well supervised as unsupervised contexts. User-friendly solutions are sought, with ideally no parameter to set, or at least quite few values with intuitive meaning. -A first attempt was already made in a previous work \cite{KerautretEven09} -but the segment thickness was initially fixed by the user and not estimated, +%A first attempt was already made in a previous work \cite{KerautretEven09} +An interactive tool was already designed for live line extractions in +gray level images \cite{KerautretEven09}. +But the segment thickness was initially fixed by the user and not estimated, leading to erroneous orientations of the detected lines. -In the present work, the limitations of this first detector were solved +Here, the limitations of this first detector are solved by the introduction of two new concepts: -(i) adaptive directional scan designed to get some -compliance to the unpredictable orientation problem; -(ii) control of assigned thickness to the blurred segment -recognition algorithm. +(i) adaptive directional scans (ADS) designed to better track the detected line; +%get some compliance to the unpredictable orientation problem; +(ii) control of assigned thickness (CAT) to bound its scattering. % intended to derive more reliable information on the %line orientation and quality. As a side effect, these two major evolutions also led to a noticeable diff --git a/Article/methodV2.tex b/Article/methodV2.tex index 23bac4e..573f496 100755 --- a/Article/methodV2.tex +++ b/Article/methodV2.tex @@ -83,7 +83,7 @@ following sections \ref{subsec:ads} and \ref{subsec:caw}. The output segment $\mathcal{B}'$ is finally accepted according to the application needs. For the present work, only a size test is performed so that blurred -segments with less than 12 pixels are rejected. +segments with less than 10 pixels are rejected. %Too short, too sparse or too fragmented segments %can be rejected. Length, sparsity or fragmentation thresholds are %intuitive parameters left at the end user disposal. diff --git a/Article/notionsV2.tex b/Article/notionsV2.tex index 8933340..42619cb 100755 --- a/Article/notionsV2.tex +++ b/Article/notionsV2.tex @@ -22,15 +22,16 @@ its period (i.e. the length of its periodic pattern). When $\nu = p(\mathcal{L})$, then $\mathcal{L}$ is the narrowest 8-connected line and is called a {\it naive line}. -The {\it thickness} $\mu = \frac{\nu}{max(|a|,|b|)}$ of the digital straight -line $\mathcal{L}(a,b,c,\nu)$ is the minimum of the vertical and horizontal +The {\it thickness} $\mu = \frac{\nu}{max(|a|,|b|)}$ of +% the digital straight line +$\mathcal{L}(a,b,c,\nu)$ is the minimum of the vertical and horizontal distances between lines $ax + by = c$ and $ax + by = c + \nu$. \begin{definition} A \textbf{blurred segment} $\mathcal{B}$ of assigned thickness $\varepsilon$ -is a set of points in $\mathbb{Z}^2$ that all belong to a digital straight -line $\mathcal{L}$ of thickness $\mu = \varepsilon$. -The \textbf{optimal line} of the blurred segment is the digital straight +is a set of points in $\mathbb{Z}^2$ that all belong to a covering digital +straight line $\mathcal{L}$ of thickness $\mu = \varepsilon$. +The \textbf{optimal line} of the blurred segment is the covering line with minimal thickness. The \textbf{thickness} of the blurred segment is the thickness of its optimal line. @@ -89,7 +90,7 @@ $\vec{V}(\mathcal{N}_i) \cdot \vec{V}(\mathcal{D}) = 0$ expresses the orthogonality constraint between the scan lines $\mathcal{N}_i$ and the scan strip $\mathcal{D}$. Then the shift of the period $p(\mathcal{D})$ between successive scans -guarantees that all points of the scan strip are travelled one and only one +guarantees that all points of the scan strip are traversed one and only one time. The scans $S_i$ are developed on each side of a start scan $S_0$, @@ -164,7 +165,7 @@ If we note $p_{\vec{D}} = max (|X_D|,|Y_D|)$, $\nu_{\vec{D}} = \lceil w\cdot p_{\vec{D}} \rceil$, $c_3 = x_C\cdot Y_D - y_C\cdot X_D - \frac{\nu_{\vec{D}}}{2}$, -$c_4 = X_D\cdot x_C + Y_D\cdot y_C - \frac{p_{\vec{D}}}{2}$, +and $c_4 = x_C\cdot X_D + y_C\cdot Y_D - \frac{p_{\vec{D}}}{2}$, it is then defined by the following scan strip $\mathcal{D}^{C,\vec{D},w}$ and scan lines $\mathcal{N}_i^{C,\vec{D},w}$: diff --git a/Code/FBSD/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp index cd6969d..ca0ccf1 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.cpp +++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp @@ -899,6 +899,14 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) yorkview = new BSYorkView (&loadedImage, &detector); yorkview->show (); break; + + case Qt::Key_Period : + // Switches the thickenning control + detector.switchStrict (); + cout << "Assigned strict (leaning lines) thickness control " + << (detector.isStrictOn () ? "on" : "off") << endl; + extract (); + break; // DEV OUT case Qt::Key_Plus : diff --git a/Code/FBSD/BSTools/extlines.cpp b/Code/FBSD/BSTools/extlines.cpp index 3c37dd2..0cb8240 100755 --- a/Code/FBSD/BSTools/extlines.cpp +++ b/Code/FBSD/BSTools/extlines.cpp @@ -176,7 +176,7 @@ double ExtLines::covering (const char *name, int nbinfo, cl.ey = height - 1 - val[3]; clLength = sqrt ((cl.sx - cl.ex) * (cl.sx - cl.ex) + (cl.sy - cl.ey) * (cl.sy - cl.ey)); - if (clLength > minl) + if (clLength >= minl) { cannys.push_back (cl); lg += clLength; @@ -245,6 +245,7 @@ double ExtLines::covering (const char *name, int nbinfo, int ExtLines::count (const char *name, int nbinfo, double &lg, double minl) const { +cout << "COUNTING" << endl; vector<ExtLine> cannys; double val[nbinfo]; double clLength = 0.; @@ -314,21 +315,27 @@ void ExtLines::stats (const QImage &im) outf.close (); } - double lbs = 0.; - int nbs = (int) bss.size (); + double mylength, mylg = 0.; + int mynb = 0; + // int nbs = (int) bss.size (); vector<BlurredSegment *>::iterator it = bss.begin (); while (it != bss.end ()) { Pt2i lastleft = (*it)->getLastLeft (); Pt2i lastright = (*it)->getLastRight (); - lbs += sqrt ((lastleft.x () - lastright.x ()) - * (lastleft.x () - lastright.x ()) - + (lastleft.y () - lastright.y ()) - * (lastleft.y () - lastright.y ())); + mylength = sqrt ((lastleft.x () - lastright.x ()) + * (lastleft.x () - lastright.x ()) + + (lastleft.y () - lastright.y ()) + * (lastleft.y () - lastright.y ())); + if (mylength >= MIN_LENGTH) + { + mylg += mylength; + mynb++; + } it ++; } ofstream outl ("Data/fbsdln.txt", ios::out); - outl << nbs << " " << lbs << " " << (lbs / nbs) << endl; + outl << mynb << " " << mylg << " " << (mylg / mynb) << endl; outl.close (); for (int i = 0; i < height; i++) delete [] tabImage[i]; diff --git a/Code/FBSD/BlurredSegment/blurredsegmentproto.cpp b/Code/FBSD/BlurredSegment/blurredsegmentproto.cpp index 925ae8a..b357866 100755 --- a/Code/FBSD/BlurredSegment/blurredsegmentproto.cpp +++ b/Code/FBSD/BlurredSegment/blurredsegmentproto.cpp @@ -58,7 +58,7 @@ BlurredSegmentProto::~BlurredSegmentProto () AbsRat BlurredSegmentProto::strictThickness () const { - return (convexhull != NULL ? convexhull->strictThickness () : AbsRat (0, 1)); + return (convexhull != NULL ? convexhull->thickness () : AbsRat (0, 1)); } @@ -83,9 +83,10 @@ DigitalStraightLine *BlurredSegmentProto::getLine () const convexhull->antipodalEdgeAndVertex (s, e, v); return (new DigitalStraightLine (s, e, v)); } - if (bsFlat) return (new DigitalStraightLine (getLastLeft (), getLastRight (), - DigitalStraightLine::DSL_THIN)); - return (NULL); + if (bsFlat || leftOK || rightOK) + return (new DigitalStraightLine (getLastLeft (), getLastRight (), + DigitalStraightLine::DSL_THIN)); + return (NULL); // No line if only one point } diff --git a/Code/FBSD/BlurredSegment/blurredsegmentproto.h b/Code/FBSD/BlurredSegment/blurredsegmentproto.h index bad3be9..28589ce 100755 --- a/Code/FBSD/BlurredSegment/blurredsegmentproto.h +++ b/Code/FBSD/BlurredSegment/blurredsegmentproto.h @@ -40,6 +40,12 @@ public: */ ~BlurredSegmentProto (); + /** + * \brief Checks if the blurred segment has at least two points. + */ + inline bool isLineable () const { + return (bsOK || bsFlat || leftOK || rightOK); } + /** * \brief Returns the built-in blurred segment strict thickness. * The strict thickness is the distance between bounding lines, ie (nu-1)/p. diff --git a/Code/FBSD/BlurredSegment/bsdetector.cpp b/Code/FBSD/BlurredSegment/bsdetector.cpp index 0ebae63..81fb515 100755 --- a/Code/FBSD/BlurredSegment/bsdetector.cpp +++ b/Code/FBSD/BlurredSegment/bsdetector.cpp @@ -69,7 +69,7 @@ BSDetector::BSDetector () finalDensityTestOn = false; finalLengthTestOn = false; finalSpreadTestOn = true; - finalSpreadMin = 12; + finalSpreadMin = 10; // nbSmallBS = 0; multiSelection = false; autodet = false; diff --git a/Code/FBSD/BlurredSegment/bstracker.cpp b/Code/FBSD/BlurredSegment/bstracker.cpp index a5ca5c4..9dce6c6 100755 --- a/Code/FBSD/BlurredSegment/bstracker.cpp +++ b/Code/FBSD/BlurredSegment/bstracker.cpp @@ -280,7 +280,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, if (thickenOn && stableWidthCount >= thickenningLimit) { AbsRat dth (sw); - if (strictOn) dth = bs.digitalThickness (); + if (! strictOn) dth = bs.digitalThickness (); AbsRat finalWidth (dth.sumHalf ()); if (finalWidth.lessThan (bs.getMaxWidth ())) bs.setMaxWidth (finalWidth); thickenOn = false; @@ -306,7 +306,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, } // Resets the scan stripe - if (dynamicScans && count > fittingDelay && bs.getLine () != NULL) + if (dynamicScans && count > fittingDelay && bs.isLineable ()) { // Stops the detection if the segment gets crosswise if (count == fittingDelay + 1) @@ -324,7 +324,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, bs.getLine()->getMedialAxis (ppa, ppb, ppc); ds->bindTo (ppa, ppb, ppc); } - else if (trackCrosswise && count > 3 && bs.getLine () != NULL) + else if (trackCrosswise && count > 3 && bs.isLineable ()) { Vr2i dirn = bs.getSupportVector (); if (4 * dirn.squaredScalarProduct (scandir) @@ -360,7 +360,8 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, stableWidthCount ++; if (added) { - if (sw.lessThan (bs.strictThickness ())) stableWidthCount = 0; + if (thickenOn + && sw.lessThan (bs.strictThickness ())) stableWidthCount = 0; rscan = count; if (rstop == 0) rstart = 0; else @@ -408,7 +409,8 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, stableWidthCount ++; if (added) { - if (sw.lessThan (bs.strictThickness ())) stableWidthCount = 0; + if (thickenOn + && sw.lessThan (bs.strictThickness ())) stableWidthCount = 0; lscan = count; if (lstop == 0) lstart = 0; else diff --git a/Code/FBSD/ConvexHull/antipodal.cpp b/Code/FBSD/ConvexHull/antipodal.cpp index c9ef9c7..738fbce 100755 --- a/Code/FBSD/ConvexHull/antipodal.cpp +++ b/Code/FBSD/ConvexHull/antipodal.cpp @@ -64,7 +64,7 @@ void Antipodal::init (CHVertex *v1, CHVertex *v2, CHVertex *v3) } -AbsRat Antipodal::strictThickness () const +AbsRat Antipodal::thickness () const { int den = ept2->get (iy) - ept1->get (iy); return (AbsRat (((vpt->get (ix) - ept1->get (ix)) * den @@ -73,14 +73,17 @@ AbsRat Antipodal::strictThickness () const } -void Antipodal::width (int &num, int &den) const +/* +void Antipodal::thickness (int &num, int &den) const { den = ept2->get (iy) - ept1->get (iy); - if (den < 0) den = -den; num = (vpt->get (ix) - ept1->get (ix)) * den - - (vpt->get (iy) - ept1->get (iy)) * (ept2->get (ix) - ept1->get (ix)); + - (vpt->get (iy) - ept1->get (iy)) + * (ept2->get (ix) - ept1->get (ix)); if (num < 0) num = -num; + if (den < 0) den = -den; } +*/ int Antipodal::remainder (CHVertex *v) const diff --git a/Code/FBSD/ConvexHull/antipodal.h b/Code/FBSD/ConvexHull/antipodal.h index 36cd073..df2b9a5 100755 --- a/Code/FBSD/ConvexHull/antipodal.h +++ b/Code/FBSD/ConvexHull/antipodal.h @@ -44,13 +44,19 @@ public: /** Returns the leaning edge end of the antipodal pair. */ inline CHVertex *edgeEnd () const { return ept2; } - /** Returns the antipodal pair strict thickness. - * Strict thickness is the vertex horizontal distance to the edge. + /** + * Returns the antipodal pair horizontal thickness. + * It is computed as the vertex horizontal distance to the edge. */ - AbsRat strictThickness () const; + AbsRat thickness () const; - /** Gets the rational main axis width of the antipodal pair. */ - void width (int &num, int &den) const; + /** + * Computes the antipodal pair horizontal thickness. + * It is the vertex horizontal distance to the edge. + * @param num Numerator of the thickness rational value. + * @param den Denominator of the thickness rational value. + */ + //void thickness (int &num, int &den) const; /** Returns the remainder of the edge line equation for given vertex. */ int remainder (CHVertex *v) const; diff --git a/Code/FBSD/ConvexHull/convexhull.cpp b/Code/FBSD/ConvexHull/convexhull.cpp index b20d532..7256ab4 100755 --- a/Code/FBSD/ConvexHull/convexhull.cpp +++ b/Code/FBSD/ConvexHull/convexhull.cpp @@ -114,20 +114,19 @@ bool ConvexHull::moveLastPoint (const Pt2i &pix) } -AbsRat ConvexHull::strictThickness () const +AbsRat ConvexHull::thickness () const { - AbsRat aphw = aph.strictThickness (); - AbsRat apvw = apv.strictThickness (); + AbsRat aphw = aph.thickness (); + AbsRat apvw = apv.thickness (); return (apvw.lessThan (aphw) ? apvw : aphw); } void ConvexHull::antipodalEdgeAndVertex (Pt2i &s, Pt2i &e, Pt2i &v) const { - int n1, d1, n2, d2; - aph.width (n1, d1); - apv.width (n2, d2); - const Antipodal *ap = ((n2 * d1 < n1 * d2) ? &apv : &aph); + AbsRat aphw = aph.thickness (); + AbsRat apvw = apv.thickness (); + const Antipodal *ap = (apvw.lessThan (aphw) ? &apv : &aph); s.set (*(ap->edgeStart ())); e.set (*(ap->edgeEnd ())); v.set (*(ap->vertex ())); diff --git a/Code/FBSD/ConvexHull/convexhull.h b/Code/FBSD/ConvexHull/convexhull.h index 731bfff..4d06a05 100755 --- a/Code/FBSD/ConvexHull/convexhull.h +++ b/Code/FBSD/ConvexHull/convexhull.h @@ -70,11 +70,12 @@ public: */ void antipodalEdgeAndVertex (Pt2i &s, Pt2i &e, Pt2i &v) const; - /** Returns the convex hull strict thickness. - * Strict thickness is defined as the minimal value of both antipodal pairs. - * It is also the minimal vertical or horizontal width of the convex hull. + /** + * Returns the convex hull thickness. + * The thickness is the minimal vertical or horizontal thickness. + * It is computed as the minimal value of both antipodal pairs. */ - AbsRat strictThickness () const; + AbsRat thickness () const; /** * Returns a string that represents the convex hull. -- GitLab