From fbc7a2753769c710bacb6607131b0a2a6292514c Mon Sep 17 00:00:00 2001
From: even <philippe.even@loria.fr>
Date: Tue, 23 Apr 2019 17:54:30 +0200
Subject: [PATCH] Paper conclusion and angle tests

---
 Article/Expe_auto/compTable.tex               |   2 +-
 Article/conclusion.tex                        |   9 +-
 Article/expeV2.tex                            |  36 ++++--
 Article/introV2.tex                           |   8 +-
 Article/methodV2.tex                          |  14 +--
 Code/FBSD/BSTools/bsyorkitem.cpp              |  45 ++++++-
 Code/FBSD/BSTools/bsyorkitem.h                |  13 +-
 Code/FBSD/BSTools/extlines.cpp                | 119 +++++++++++++++++-
 Code/FBSD/BSTools/extlines.h                  |  16 ++-
 Code/FBSD/ImageTools/digitalstraightline.h    |   6 +
 .../ImageTools/digitalstraightsegment.cpp     |  20 +++
 Code/FBSD/ImageTools/digitalstraightsegment.h |   5 +
 Code/FBSD/main.cpp                            |  54 +++++++-
 Methode/ctrl.tex                              |   4 +
 14 files changed, 308 insertions(+), 43 deletions(-)

diff --git a/Article/Expe_auto/compTable.tex b/Article/Expe_auto/compTable.tex
index 5f579fc..e779148 100644
--- a/Article/Expe_auto/compTable.tex
+++ b/Article/Expe_auto/compTable.tex
@@ -2,7 +2,7 @@
 \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$ (pixels)} \\
+& \multicolumn{2}{c|}{$L$ (pixels)} & \multicolumn{2}{c|}{$L/N$} \\
 \hline
 LSD
 & 63.5 & 13.1 & 61.3 & 11.2
diff --git a/Article/conclusion.tex b/Article/conclusion.tex
index de85fc7..2ff8321 100755
--- a/Article/conclusion.tex
+++ b/Article/conclusion.tex
@@ -17,14 +17,13 @@ gradient magnitude, and on
 %The main limitations of the former approach were solved through
 the integration of two new concepts:
 adaptive directional scans that continuously adjust the scan strip
-to the detected edge direction
-the control of the assigned width based on the observation of the
+to the detected edge direction, and
+control of the assigned width based on the observation of the
 blurred segment growth.
-Experiments on synthetic ground truth images show the better performance
+Experiments on synthetic images show the better performance
 and especially the more accurate estimation of the line width brought by
 these concepts.
-Moreover reached performance are quite comparable to those of recent well
-established edge detectors.
+Moreover the performance is quite comparable to other recent edge detectors.
 
 A residual weakness of the approach is the sensitivity to the initial
 conditions.
diff --git a/Article/expeV2.tex b/Article/expeV2.tex
index a9e816b..44f7b97 100755
--- a/Article/expeV2.tex
+++ b/Article/expeV2.tex
@@ -81,19 +81,19 @@ $D$ the set of all the detected blurred segments.}
 \end{table}
 
 Next experiments aim at comparing the achieved performance of the new
-detector with those of well established line detectors : LSD \cite{GioiAl10},
+detector with those of other line detectors : LSD \cite{GioiAl10},
 ED-Lines \cite{AkinlarTopal12} and CannyLines \cite{LuAl15}.
-The tests are run on the set of 102 ground truth images of the York Urban
-database \cite{DenisAl08}.
+The tests are run on the York Urban database \cite{DenisAl08} composed
+of 102 images with their ground truth lines.
 As this database was set in the scope of Manhattan-world environments,
 only lines in the three main directions are identified.
-The results on one image is displayed on \RefFig{fig:york}.
+Results on one image are displayed in \RefFig{fig:york}.
 Compared measures $M$ are execution time $T$, covering ratio $C$,
 detected lines amount $N$, cumulated length of detected lines $L$ and
 mean length ratio $L/N$.
-On each image of the database we measure the execution time of 100
-detections, gradient extraction included; $T$ is the mean value measured on
-the whole image set.
+On each image of the database we measure the execution time of 100 repetitions
+of a complete detection, gradient extraction included, for each line detector;
+$T$ is the mean value computed on the whole image set.
 If we assume that a pixel of a ground truth line is identified
 if there is a detected line in its 8-neighborhood, then the measure $C$ is
 the mean ratio of the length of ground truth line pixels identified on the
@@ -127,9 +127,9 @@ Found measures are given in \RefTab{tab:comp}.
     \end{picture}
   \end{tabular}
   \caption{Comparison of line detectors on one of the 102 ground truth
-           images of the York Urban database : a) Image P1020928,
-           b) ground truth lines, c) LSD result, d) ED-Lines result,
-           e) CannyLines result, f) our detector result.}
+           images of the York Urban database : a) input image, % P1020928
+           b) ground truth lines, c) LSD output, d) ED-Lines output,
+           e) CannyLines output, f) thick lines of the new detector.}
   \label{fig:york}
 \end{figure}
 
@@ -142,7 +142,17 @@ on the York Urban Database \cite{DenisAl08}.}
 \label{tab:comp}
 \end{table}
 
-Globally the performance of the new detector are pretty similar to those
-of the other ones. CannyLines provides longer lines and ED-Lines is much
-faster. But additionnaly, our detector provides an indication
+\begin{table}
+\centering
+\input{Expe_auto/compTable}
+
+\caption{Measured performance of recent line detectors and of our detector
+on the York Urban Database \cite{DenisAl08}.}
+\label{tab:comp}
+\end{table}
+
+On these images, CannyLines provides longer lines and ED-Lines is much faster.
+Globally, the performance of the new detector is pretty similar and
+competitive to the other ones, and
+additionnaly, our detector provides an indication
 on the detected lines quality through the additional width parameter.
diff --git a/Article/introV2.tex b/Article/introV2.tex
index f8fd5de..3bbc5fc 100755
--- a/Article/introV2.tex
+++ b/Article/introV2.tex
@@ -6,8 +6,8 @@ Straight lines are commonly used visual features for many image analysis
 processes.
 For instance in computer vision, they are used to estimate the vanishing
 points associated to main directions of the 3D world, thus allowing camera
-orientation. They are also used to detect structured features to help a
-3D reconstruction process.
+orientation. They are also used to detect structured features for
+3D reconstruction.
 
 Therefore, straight line detection is always an active research topic
 centered on the quest of still faster, more accurate or more robust-to-noise
@@ -32,7 +32,9 @@ geometric objects, such as lines or circles, have been developed
 to better fit to the discrete nature of most of today's data to process.
 In particular, the notion of blurred segment \cite{Buzer07,DebledAl05} was
 introduced to cope with the image noise or other sources of imperfections
-from the real world using a width parameter.
+from the real world using a width\footnote{We use equivalently the terms
+width and thickness in this work.}
+parameter.
 Efficient algorithms have already been designed to recognize
 these digital objects in binary images \cite{DebledAl06}.
 Blurred segments seem well suited to reflect the required line quality
diff --git a/Article/methodV2.tex b/Article/methodV2.tex
index 538bba1..3ff5ec2 100755
--- a/Article/methodV2.tex
+++ b/Article/methodV2.tex
@@ -284,13 +284,13 @@ straight edges in the image. A stroke that crosses the whole image, is
 swept in both directions, vertical then horizontal, from the center to
 the borders. At each position, the multi-detection algorithm is run
 to collect all the segments found under the stroke.
-In the present work, the stroke sweeping step $\delta$ is set to 15 pixels.
-Then small (less than 10 pixels) blurred segments are rejected in order to
-avoid the formation of small mis-aligned segments when the sweeping stroke
-crosses an image edge near one of its ends.
-In such situation, any nearby disturbing gradient is
-likely to deviate the blurred segment direction, and the expansion is
-quickly stopped. A length threshold value of 30 pixels is experimentally set.
+Then small blurred segments are rejected in order to avoid the formation
+of mis-aligned segments when the sweeping stroke crosses an image edge
+near one of its ends.
+In such situation, any nearby disturbing gradient is likely to deviate
+the blurred segment direction, and its expansion is quickly stopped.
+In the present work, the stroke sweeping step is set to 15 pixels
+and the length threshold to 10 pixels.
 
 The automatic detection of blurred segments in a whole image is available
 for testing from the online demonstration
diff --git a/Code/FBSD/BSTools/bsyorkitem.cpp b/Code/FBSD/BSTools/bsyorkitem.cpp
index cd0d168..ed5ae18 100755
--- a/Code/FBSD/BSTools/bsyorkitem.cpp
+++ b/Code/FBSD/BSTools/bsyorkitem.cpp
@@ -17,12 +17,13 @@ const int BSYorkItem::YORK_OVER_ED = 6;
 const int BSYorkItem::CANNY_ALONE = 7;
 const int BSYorkItem::DILATED_CANNY_ALONE = 8;
 const int BSYorkItem::YORK_OVER_CANNY = 9;
-const int BSYorkItem::FBSD_ALONE = 10;
-const int BSYorkItem::YORK_OVER_BS = 11;
-const int BSYorkItem::YORK_OVER_DSS = 12;
-const int BSYorkItem::YORK_WITH_CANNY = 13;
-const int BSYorkItem::YORK_WITH_DSS = 14;
-const int BSYorkItem::NO_INFO = 15;
+const int BSYorkItem::FBSD_LINES = 10;
+const int BSYorkItem::FBSD_ALONE = 11;
+const int BSYorkItem::YORK_OVER_BS = 12;
+const int BSYorkItem::YORK_OVER_DSS = 13;
+const int BSYorkItem::YORK_WITH_CANNY = 14;
+const int BSYorkItem::YORK_WITH_DSS = 15;
+const int BSYorkItem::NO_INFO = 16;
 const QColor BSYorkItem::ALONE_COLOR = Qt::black;
 const QColor BSYorkItem::OVER_COLOR = Qt::lightGray;
 const QColor BSYorkItem::UNDER_COLOR = Qt::yellow;
@@ -46,6 +47,7 @@ BSYorkItem::BSYorkItem (int width, int height, const QImage *im,
   cannys = new ExtLines ("Data/cannylines.txt", w, h, 5);
   lsds = new ExtLines ("Data/lsdlines.txt", w, h, 7);
   eds = new ExtLines ("Data/edlines.txt", w, h, 4);
+  fbsds = new ExtLines ("Data/naivelines.txt", w, h, 5);
 }
 
 
@@ -91,6 +93,7 @@ void BSYorkItem::paint (QPainter *painter,
     drawCannyLines (painter, false);
     drawYorkLines (painter, false);
   }
+  else if (type == FBSD_LINES) drawFbsdLines (painter, true);
   else if (type == FBSD_ALONE) drawDSS (painter, true);
   else if (type == YORK_OVER_BS)
   {
@@ -443,6 +446,36 @@ cout << "Dilation of " << dil << endl;
 }
 
 
+void BSYorkItem::drawFbsdLines (QPainter *painter, bool alone, bool disp)
+{
+  int n = 0;
+  Pt2i *pts = NULL;
+  int nb = fbsds->countOfLines ();
+  for (int i = 0; i < nb; i++)
+  {
+    pts = Pt2i (fbsds->xStart (i), fbsds->yStart (i)).drawing (
+          Pt2i (fbsds->xEnd (i), fbsds->yEnd (i)), &n);
+    for (int i = 0; i < n; i++)
+    {
+      if (pts[i].x () >= 0 && pts[i].x () < w
+          && pts[i].y () >= 0 && pts[i].y () < h)
+      {
+        if (disp)
+        {
+          painter->setPen (QPen (alone ? ALONE_COLOR : UNDER_COLOR,
+                             DEFAULT_PEN_WIDTH, Qt::SolidLine,
+                             Qt::RoundCap, Qt::RoundJoin));
+          painter->drawPoint (QPoint (pts[i].x (),
+                                      h - 1 - pts[i].y ()));  // dec 1
+        }
+        bsmap[pts[i].y()*w+pts[i].x()] = true;
+      }
+    }
+    delete [] pts;
+  }
+}
+
+
 void BSYorkItem::computeBScovering ()
 {
   det->detectAll ();
diff --git a/Code/FBSD/BSTools/bsyorkitem.h b/Code/FBSD/BSTools/bsyorkitem.h
index f8db92a..0185132 100755
--- a/Code/FBSD/BSTools/bsyorkitem.h
+++ b/Code/FBSD/BSTools/bsyorkitem.h
@@ -90,8 +90,10 @@ public:
       return ("Canny lines");
     else if (type == YORK_OVER_CANNY)
       return ("York over Canny lines");
+    else if (type == FBSD_LINES)
+      return ("FBSD output lines");
     else if (type == FBSD_ALONE)
-      return ("FBSD lines");
+      return ("FBSD detection");
     else if (type == YORK_OVER_BS)
       return ("York over blurred segments points");
     else if (type == YORK_OVER_DSS)
@@ -127,7 +129,9 @@ private:
   static const int DILATED_CANNY_ALONE;
   /** York over Canny display modality. */
   static const int YORK_OVER_CANNY;
-  /** FBSD lines alone display modality. */
+  /** FBSD output lines alone display modality. */
+  static const int FBSD_LINES;
+  /** FBSD detected lines alone display modality. */
   static const int FBSD_ALONE;
   /** York over BS display modality. */
   static const int YORK_OVER_BS;
@@ -158,6 +162,8 @@ private:
   ExtLines *eds;
   /** Set of Canny lines. */
   ExtLines *cannys;
+  /** Set of Fbsd lines. */
+  ExtLines *fbsds;
 
   /** Background image. */
   const QImage *im;
@@ -206,6 +212,9 @@ private:
   /** Displays dilated Canny lines */
   void drawDilatedCannyLines (QPainter *painter, bool disp = true);
 
+  /** Displays Fbsd lines */
+  void drawFbsdLines (QPainter *painter, bool alone, bool disp = true);
+
 };
 
 #endif
diff --git a/Code/FBSD/BSTools/extlines.cpp b/Code/FBSD/BSTools/extlines.cpp
index 5bd54df..1b6382c 100755
--- a/Code/FBSD/BSTools/extlines.cpp
+++ b/Code/FBSD/BSTools/extlines.cpp
@@ -9,6 +9,8 @@ using namespace std;
 
 const int ExtLines::COV_DILATION = 4;
 const double ExtLines::MIN_LENGTH = 10.;
+const double ExtLines::MIN_DTHETA = 4.;
+const double ExtLines::MIN_SHIFT = 2.;
 
 
 ExtLines::ExtLines (bool groundTruth)
@@ -49,6 +51,7 @@ ExtLines::ExtLines (bool groundTruth)
   stats ("Data/cannylines.txt", 5, "Data/cannycov.txt", "Data/cannyln.txt");
   stats ("Data/edlines.txt", 4, "Data/edcov.txt", "Data/edln.txt");
   stats ("Data/lsdlines.txt", 7, "Data/lsdcov.txt", "Data/lsdln.txt");
+  stats ("Data/naivelines.txt", 5, "Data/naivecov.txt", "Data/naiveln.txt");
 }
 
 
@@ -162,11 +165,11 @@ double ExtLines::covering (const char *name, int nbinfo,
         cl.sy = height - 1 - val[1];
         cl.ex = val[2];
         cl.ey = height - 1 - val[3];
-        cannys.push_back (cl);
         clLength = sqrt ((cl.sx - cl.ex) * (cl.sx - cl.ex)
                          + (cl.sy - cl.ey) * (cl.sy - cl.ey));
         if (clLength > minl)
         {
+          cannys.push_back (cl);
           lg += clLength;
           nb++;
         }
@@ -230,6 +233,115 @@ double ExtLines::covering (const char *name, int nbinfo,
 }
 
 
+double ExtLines::diffangle (const char *name, int nbinfo, double minl) const
+{
+  // 1. Reading external lines file
+  vector<ExtLine> cannys;
+  double val[nbinfo];
+  double clLength = 0.;
+  int i = 0;
+  ifstream input (name, ios::in);
+  bool reading = true;
+  if (input)
+  {
+    while (reading)
+    {
+      input >> val[i];
+      if (input.eof ()) reading = false;
+      if (++i == nbinfo)
+      {
+        ExtLine cl;
+        cl.sx = val[0];
+        cl.sy = height - 1 - val[1];
+        cl.ex = val[2];
+        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) cannys.push_back (cl);
+        i = 0;
+      }
+    }
+  }
+
+  // 2. Matching
+  bool opposite = false;
+  double totl = 0., totdtheta = 0.;
+  double cosang = 0., dtheta = 0., shift = 0., cx = 0., cy = 0.;
+  double px = 0., py = 0., qx = 0., qy = 0., lgth = 0.;
+  vector<ExtLine>::const_iterator it = exts.begin ();
+  while (it != exts.end ())
+  {
+    Vr2i vref (it->ex - it->sx, it->ey - it->sy);
+    double aref = it->ey - it->sy;
+    double bref = it->sx - it->ex;
+    double cref = aref * it->sx + bref * it->sy;
+    double dref = sqrt (aref * aref + bref * bref);
+
+    vector<ExtLine>::iterator rit = cannys.begin ();
+    while (rit != cannys.end ())
+    {
+      opposite = false;
+      Vr2i vtest (rit->ex - rit->sx, rit->ey - rit->sy);
+      cosang = vtest.scalarProduct (vref)
+               / (sqrt (vtest.norm2 ()) * sqrt (vref.norm2 ()));
+      if (cosang < 0.)
+      {
+        opposite = true;
+        cosang = - cosang;
+      }
+      dtheta = (180. / M_PI) * acos (cosang);
+      if (dtheta < MIN_DTHETA)
+      {
+        cx = (rit->sx + rit->ex) / 2;
+        cy = (rit->sy + rit->ey) / 2;
+        shift = (cref - aref * cx - bref * cy) / dref;
+        if (shift < 0) shift = - shift;
+        if (shift < MIN_SHIFT)
+        {
+          Vr2i vecac (cx - it->sx, cy - it->sy);
+          Vr2i vecbc (cx - it->ex, cy - it->ey);
+          if (vref.scalarProduct (vecac) >= 0.
+              && vref.scalarProduct (vecbc) <= 0.)
+          {
+            if (opposite)
+            {
+              px = rit->ex;
+              py = rit->ey;
+              qx = rit->sx;
+              qy = rit->sy;
+            }
+            else
+            {
+              px = rit->sx;
+              py = rit->sy;
+              qx = rit->ex;
+              qy = rit->ey;
+            }
+            Vr2i vecap (px - it->sx, py - it->sy);
+            if (vref.scalarProduct (vecap) < 0.)
+            {
+              px = it->sx;
+              py = it->sy;
+            }
+            Vr2i vecqb (it->ex - qx, it->sy - qy);
+            if (vref.scalarProduct (vecqb) < 0.)
+            {
+              qx = it->ex;
+              qy = it->ey;
+            }
+            lgth = sqrt ((qx - px) * (qx - px) + (qy - py) * (qy - py));
+            totl += lgth;
+            totdtheta += dtheta * lgth;
+          }
+        }
+      }
+      rit ++;
+    }
+  }
+  return (totl != 0. ? totdtheta / totl : 0.);
+}
+
+
 int ExtLines::count (const char *name, int nbinfo,
                      double &lg, double minl) const
 {
@@ -332,14 +444,15 @@ void ExtLines::stats (const char *lname, int nbinfo,
   if (gt)
   {
     double covel = covering (lname, nbinfo, nel, lel, MIN_LENGTH);
+    double dang = diffangle (lname, nbinfo, MIN_LENGTH);
 
     ofstream outf (covname, ios::out);
-    outf << covel << endl;
+    outf << covel << " " << dang << endl;
     outf.close ();
   }
   else nel = count (lname, nbinfo, lel, MIN_LENGTH);
 
   ofstream outl (lgname, ios::out);
-  outl << nel << " " << lel << " " << (lel / nel) << endl;
+  outl << nel << " " << lel << " " << (lel / nel) << " " << endl;
   outl.close ();
 }
diff --git a/Code/FBSD/BSTools/extlines.h b/Code/FBSD/BSTools/extlines.h
index 26660b0..34127aa 100755
--- a/Code/FBSD/BSTools/extlines.h
+++ b/Code/FBSD/BSTools/extlines.h
@@ -77,6 +77,14 @@ public:
   double covering (const char *name, int nbinfo,
                    int &nb, double &lg, double minl) const;
 
+  /**
+   * \brief Returns the angular difference.
+   * @param name External lines file name.
+   * @param nbinfo count of data per line.
+   * @param minl Minimal length of extarcted lines.
+   */
+  double diffangle (const char *name, int nbinfo, double minl) const;
+
   /**
    * \brief Returns the count and cumulated length of external lines.
    * @param name External lines file name.
@@ -89,10 +97,14 @@ public:
 
 private:
 
-  /** Minimal length of considered lines. */
-  static const double MIN_LENGTH;
   /** Dilation distance for lines covering estimation. */
   static const int COV_DILATION;
+  /** Minimal length of considered lines. */
+  static const double MIN_LENGTH;
+  /** Minimal angular deviation for line matching with ground truth. */
+  static const double MIN_DTHETA;
+  /** Minimal distance shift for line matching with ground truth. */
+  static const double MIN_SHIFT;
 
  /** Aggregation of segment extraction results with initial conditions. */
   struct ExtLine
diff --git a/Code/FBSD/ImageTools/digitalstraightline.h b/Code/FBSD/ImageTools/digitalstraightline.h
index 23982d9..cf53256 100755
--- a/Code/FBSD/ImageTools/digitalstraightline.h
+++ b/Code/FBSD/ImageTools/digitalstraightline.h
@@ -213,6 +213,12 @@ public:
    */
   const Pt2i centerOfIntersection (Pt2i p1, Pt2i p2) const;
 
+  /**
+   * \brief Returns the squared Euclidean thickness of the digital line.
+   */
+  const AbsRat squaredEuclideanThickness () const {
+    return (AbsRat (nu * nu, a * a + b * b)); }
+
 
 protected:
 
diff --git a/Code/FBSD/ImageTools/digitalstraightsegment.cpp b/Code/FBSD/ImageTools/digitalstraightsegment.cpp
index 1e63a8d..10c9bc8 100755
--- a/Code/FBSD/ImageTools/digitalstraightsegment.cpp
+++ b/Code/FBSD/ImageTools/digitalstraightsegment.cpp
@@ -166,6 +166,26 @@ void DigitalStraightSegment::getPoints (vector<Pt2i> &pts) const
 }
 
 
+void DigitalStraightSegment::naiveLine (AbsRat &x1, AbsRat &y1,
+                                        AbsRat &x2, AbsRat &y2) const
+{
+  if (a < (b < 0 ? -b : b))
+  {
+    x1.set (min, 1);
+    y1.set (2 * c + nu - 1 - 2 * a * min, 2 * b);
+    x2.set (max, 1);
+    y2.set (2 * c + nu - 1 - 2 * a * max, 2 * b);
+  }
+  else
+  {
+    y1.set (min, 1);
+    x1.set (2 * c + nu - 1 - 2 * b * min, 2 * a);
+    y2.set (max, 1);
+    x2.set (2 * c + nu - 1 - 2 * b * max, 2 * a);
+  }
+}
+
+
 DigitalStraightSegment *DigitalStraightSegment::erosion (int num, int den) const
 {
   int newwidth = nu;
diff --git a/Code/FBSD/ImageTools/digitalstraightsegment.h b/Code/FBSD/ImageTools/digitalstraightsegment.h
index fb681f5..ca8c162 100755
--- a/Code/FBSD/ImageTools/digitalstraightsegment.h
+++ b/Code/FBSD/ImageTools/digitalstraightsegment.h
@@ -67,6 +67,11 @@ public:
    */
   void getPoints (vector<Pt2i> &pts) const;
 
+  /**
+   * \brief Provides the naive central segment end points coordinates.
+   */
+  void naiveLine (AbsRat &x1, AbsRat &y1, AbsRat &x2, AbsRat &y2) const;
+
   /**
    * \brief Returns an erosion of the segment.
    * @param num Erosion value numerator.
diff --git a/Code/FBSD/main.cpp b/Code/FBSD/main.cpp
index 85053dc..94bad17 100755
--- a/Code/FBSD/main.cpp
+++ b/Code/FBSD/main.cpp
@@ -12,6 +12,7 @@ int main (int argc, char *argv[])
   int imageName = 0;
   bool random = false, testing = false;
   bool yt = false;    // DEV
+  bool out = false;    // DEV
   QApplication app (argc, argv);
 
 // DEV IN
@@ -44,6 +45,7 @@ int main (int argc, char *argv[])
         new ExtLines (true);
         return (EXIT_SUCCESS);
       }
+      else if (string(argv[i]) == string ("-out")) out = true;
       else if (string(argv[i]) == string ("-yt")) yt = true;
       else if (string(argv[i]) == string ("-profile"))
         window.toggleProfWindow ();
@@ -96,6 +98,57 @@ int main (int argc, char *argv[])
     return (EXIT_SUCCESS);
   }
 // DEV IN
+  else if (out)
+  {
+    QImage im;
+    if (imageName != 0) im.load (argv[imageName]);
+    else im.load ("Images/couloir.gif");
+    int width = im.width ();
+    int height = im.height ();
+    int **tabImage = new int*[height];
+    for (int i = 0; i < height; i++)
+    { 
+      tabImage[i] = new int[width];
+      for(int j = 0; j < width; j++)
+      {
+        QColor c = QColor (im.pixel (j, height - i - 1));
+        tabImage[i][j] = c.value ();
+      }
+    }
+    BSDetector detector;
+    AbsRat x1, y1, x2, y2;
+    VMap *gMap = NULL;
+    if (gMap != NULL) delete gMap;
+    gMap = new VMap (width, height, tabImage, VMap::TYPE_SOBEL_5X5);
+    detector.setGradientMap (gMap);
+    // buildGradientImage (0);
+    detector.detectAll ();
+    ofstream outf ("naivelines.txt", ios::out);
+    vector<BlurredSegment *> bss = detector.getBlurredSegments ();
+    vector<BlurredSegment *>::iterator it = bss.begin ();
+    while (it != bss.end ())
+    {
+      if (*it != NULL)
+      {
+        DigitalStraightSegment *dss = (*it)->getSegment ();
+        if (dss != NULL)
+        {
+          dss->naiveLine (x1, y1, x2, y2);
+          AbsRat th = dss->squaredEuclideanThickness ();
+          outf << (x1.numerator () / (double) x1.denominator ()) << " "
+               << (height - 1
+                   - y1.numerator () / (double) y1.denominator ()) << " "
+               << (x2.numerator () / (double) x2.denominator ()) << " "
+               << (height - 1
+                   - y2.numerator () / (double) y2.denominator ()) << " "
+               << (th.numerator () / (double) th.denominator ()) << endl;
+        }
+      }
+      it ++;
+    }
+    outf.close ();
+    return (EXIT_SUCCESS);
+  }
   else if (yt)
   {
     QImage im;
@@ -112,7 +165,6 @@ int main (int argc, char *argv[])
         tabImage[i][j] = c.value ();
       }
     }
-    BSDetectionWidget bsdw;
     BSDetector detector;
     clock_t start = clock ();
     VMap *gMap = NULL;
diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex
index 1bd616e..f9b4a59 100755
--- a/Methode/ctrl.tex
+++ b/Methode/ctrl.tex
@@ -109,6 +109,10 @@ $\wedge \vee$ && Parcours des bandes \\
 \hline \hline
 \multicolumn{3}{|l|}{Analyse de la d\'etection initiale :} \\
 $< \wedge > \vee$ && D\'ecalage de l'observation \\
+\hline \hline
+\multicolumn{3}{|l|}{Param\`etres d'ex\'ecution :} \\
+{\tt -out} && Sort les lignes d'une d\'etection auto sur l'image fournie
+dans {\tt naivelines.txt}. \\
 \hline
 \end{tabular}
 
-- 
GitLab