From 8c4e6986da5e66f666a03c995b702cf2d9916230 Mon Sep 17 00:00:00 2001
From: even <philippe.even@loria.fr>
Date: Sun, 13 Jan 2019 12:47:49 +0100
Subject: [PATCH] Code: renaming for diffusion

---
 .../BSTools/bsdetectionwidget.cpp             | 1054 +----------------
 .../{Seg => FBSD}/BSTools/bsdetectionwidget.h |   11 +-
 Code/{Seg => FBSD}/BSTools/bsidetitem.cpp     |    0
 Code/{Seg => FBSD}/BSTools/bsidetitem.h       |    0
 Code/{Seg => FBSD}/BSTools/bsidetview.cpp     |    0
 Code/{Seg => FBSD}/BSTools/bsidetview.h       |    0
 Code/{Seg => FBSD}/BSTools/bsprofileitem.cpp  |    0
 Code/{Seg => FBSD}/BSTools/bsprofileitem.h    |    0
 Code/{Seg => FBSD}/BSTools/bsprofileview.cpp  |    0
 Code/{Seg => FBSD}/BSTools/bsprofileview.h    |    0
 Code/FBSD/BSTools/bsrandomtester.cpp          |  702 +++++++++++
 Code/FBSD/BSTools/bsrandomtester.h            |  169 +++
 .../{Seg => FBSD}/BSTools/bsstructureitem.cpp |    0
 Code/{Seg => FBSD}/BSTools/bsstructureitem.h  |    5 +
 .../{Seg => FBSD}/BSTools/bsstructureview.cpp |   10 +-
 Code/{Seg => FBSD}/BSTools/bsstructureview.h  |    5 +
 Code/{Seg => FBSD}/BSTools/bswindow.cpp       |   12 +-
 Code/{Seg => FBSD}/BSTools/bswindow.h         |    5 -
 .../{Seg => FBSD}/BlurredSegment/biptlist.cpp |    0
 Code/{Seg => FBSD}/BlurredSegment/biptlist.h  |    1 -
 .../BlurredSegment/blurredsegment.cpp         |   17 +
 .../BlurredSegment/blurredsegment.h           |   15 +-
 .../BlurredSegment/blurredsegmentproto.cpp    |    0
 .../BlurredSegment/blurredsegmentproto.h      |    2 -
 .../BlurredSegment/bsdetector.cpp             |    0
 .../{Seg => FBSD}/BlurredSegment/bsdetector.h |    7 +-
 .../{Seg => FBSD}/BlurredSegment/bsfilter.cpp |    0
 Code/{Seg => FBSD}/BlurredSegment/bsfilter.h  |    0
 .../BlurredSegment/bstracker.cpp              |    0
 Code/{Seg => FBSD}/BlurredSegment/bstracker.h |    1 -
 Code/{Seg => FBSD}/ConvexHull/antipodal.cpp   |    2 +
 Code/{Seg => FBSD}/ConvexHull/antipodal.h     |    9 +-
 Code/{Seg => FBSD}/ConvexHull/chvertex.cpp    |    2 +
 Code/{Seg => FBSD}/ConvexHull/chvertex.h      |   11 +-
 Code/{Seg => FBSD}/ConvexHull/convexhull.cpp  |    2 +
 Code/{Seg => FBSD}/ConvexHull/convexhull.h    |   47 +-
 .../DirectionalScanner/adaptivescannero1.cpp} |   17 +-
 .../DirectionalScanner/adaptivescannero1.h}   |   56 +-
 .../DirectionalScanner/adaptivescannero2.cpp} |   17 +-
 .../DirectionalScanner/adaptivescannero2.h}   |   62 +-
 .../DirectionalScanner/adaptivescannero7.cpp} |   17 +-
 .../DirectionalScanner/adaptivescannero7.h}   |   62 +-
 .../DirectionalScanner/adaptivescannero8.cpp} |   17 +-
 .../DirectionalScanner/adaptivescannero8.h}   |   63 +-
 .../DirectionalScanner/directionalscanner.cpp |    0
 .../DirectionalScanner/directionalscanner.h   |    2 -
 .../directionalscannero1.cpp                  |    1 -
 .../DirectionalScanner/directionalscannero1.h |    3 +-
 .../directionalscannero2.cpp                  |    1 -
 .../DirectionalScanner/directionalscannero2.h |    3 +-
 .../directionalscannero7.cpp                  |    1 -
 .../DirectionalScanner/directionalscannero7.h |    3 +-
 .../directionalscannero8.cpp                  |    1 -
 .../DirectionalScanner/directionalscannero8.h |    3 +-
 .../DirectionalScanner/scannerprovider.cpp    |   24 +-
 .../DirectionalScanner/scannerprovider.h      |    2 +-
 .../DirectionalScanner/vhscannero1.cpp        |    5 +-
 .../DirectionalScanner/vhscannero1.h          |    8 +-
 .../DirectionalScanner/vhscannero2.cpp        |    5 +-
 .../DirectionalScanner/vhscannero2.h          |   10 +-
 .../DirectionalScanner/vhscannero7.cpp        |    5 +-
 .../DirectionalScanner/vhscannero7.h          |    8 +-
 .../DirectionalScanner/vhscannero8.cpp        |    5 +-
 .../DirectionalScanner/vhscannero8.h          |    8 +-
 Code/{Seg/Seg.pro => FBSD/FBSD.pro}           |   20 +-
 Code/{Seg => FBSD}/IPOLdemo/IPOLdemo.pro      |   16 +-
 Code/{Seg => FBSD}/IPOLdemo/Input/couloir.gif |  Bin
 Code/{Seg => FBSD}/IPOLdemo/Input/points.txt  |    0
 .../{Seg => FBSD}/IPOLdemo/Scripts/convert.sh |    0
 .../IPOLdemo/Scripts/displaySegments.sh       |    0
 .../Scripts/displaySegmentsInteract.sh        |    0
 Code/{Seg => FBSD}/IPOLdemo/mainIPOL.cpp      |    1 -
 Code/{Seg => FBSD}/ImageTools/absrat.cpp      |    0
 Code/{Seg => FBSD}/ImageTools/absrat.h        |    2 -
 .../ImageTools/digitalstraightline.cpp        |    0
 .../ImageTools/digitalstraightline.h          |    2 -
 .../ImageTools/digitalstraightsegment.cpp     |    0
 .../ImageTools/digitalstraightsegment.h       |    1 -
 Code/{Seg => FBSD}/ImageTools/pt2i.cpp        |    0
 Code/{Seg => FBSD}/ImageTools/pt2i.h          |    2 -
 Code/{Seg => FBSD}/ImageTools/strucel.cpp     |    0
 Code/{Seg => FBSD}/ImageTools/strucel.h       |    3 +-
 Code/{Seg => FBSD}/ImageTools/vmap.cpp        |    0
 Code/{Seg => FBSD}/ImageTools/vmap.h          |    4 +-
 Code/{Seg => FBSD}/ImageTools/vr2i.cpp        |    0
 Code/{Seg => FBSD}/ImageTools/vr2i.h          |    3 +-
 Code/{Seg => FBSD}/main.cpp                   |   26 +-
 README.md                                     |    3 -
 88 files changed, 1236 insertions(+), 1345 deletions(-)
 rename Code/{Seg => FBSD}/BSTools/bsdetectionwidget.cpp (50%)
 rename Code/{Seg => FBSD}/BSTools/bsdetectionwidget.h (97%)
 rename Code/{Seg => FBSD}/BSTools/bsidetitem.cpp (100%)
 rename Code/{Seg => FBSD}/BSTools/bsidetitem.h (100%)
 rename Code/{Seg => FBSD}/BSTools/bsidetview.cpp (100%)
 rename Code/{Seg => FBSD}/BSTools/bsidetview.h (100%)
 rename Code/{Seg => FBSD}/BSTools/bsprofileitem.cpp (100%)
 rename Code/{Seg => FBSD}/BSTools/bsprofileitem.h (100%)
 rename Code/{Seg => FBSD}/BSTools/bsprofileview.cpp (100%)
 rename Code/{Seg => FBSD}/BSTools/bsprofileview.h (100%)
 create mode 100755 Code/FBSD/BSTools/bsrandomtester.cpp
 create mode 100755 Code/FBSD/BSTools/bsrandomtester.h
 rename Code/{Seg => FBSD}/BSTools/bsstructureitem.cpp (100%)
 rename Code/{Seg => FBSD}/BSTools/bsstructureitem.h (98%)
 rename Code/{Seg => FBSD}/BSTools/bsstructureview.cpp (95%)
 rename Code/{Seg => FBSD}/BSTools/bsstructureview.h (93%)
 rename Code/{Seg => FBSD}/BSTools/bswindow.cpp (93%)
 rename Code/{Seg => FBSD}/BSTools/bswindow.h (96%)
 rename Code/{Seg => FBSD}/BlurredSegment/biptlist.cpp (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/biptlist.h (99%)
 rename Code/{Seg => FBSD}/BlurredSegment/blurredsegment.cpp (92%)
 rename Code/{Seg => FBSD}/BlurredSegment/blurredsegment.h (93%)
 rename Code/{Seg => FBSD}/BlurredSegment/blurredsegmentproto.cpp (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/blurredsegmentproto.h (99%)
 rename Code/{Seg => FBSD}/BlurredSegment/bsdetector.cpp (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/bsdetector.h (99%)
 rename Code/{Seg => FBSD}/BlurredSegment/bsfilter.cpp (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/bsfilter.h (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/bstracker.cpp (100%)
 rename Code/{Seg => FBSD}/BlurredSegment/bstracker.h (99%)
 rename Code/{Seg => FBSD}/ConvexHull/antipodal.cpp (99%)
 rename Code/{Seg => FBSD}/ConvexHull/antipodal.h (92%)
 rename Code/{Seg => FBSD}/ConvexHull/chvertex.cpp (98%)
 rename Code/{Seg => FBSD}/ConvexHull/chvertex.h (85%)
 rename Code/{Seg => FBSD}/ConvexHull/convexhull.cpp (99%)
 rename Code/{Seg => FBSD}/ConvexHull/convexhull.h (96%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero1.cpp => FBSD/DirectionalScanner/adaptivescannero1.cpp} (92%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero1.h => FBSD/DirectionalScanner/adaptivescannero1.h} (70%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero2.cpp => FBSD/DirectionalScanner/adaptivescannero2.cpp} (92%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero2.h => FBSD/DirectionalScanner/adaptivescannero2.h} (67%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero7.cpp => FBSD/DirectionalScanner/adaptivescannero7.cpp} (92%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero8.h => FBSD/DirectionalScanner/adaptivescannero7.h} (67%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero8.cpp => FBSD/DirectionalScanner/adaptivescannero8.cpp} (92%)
 rename Code/{Seg/DirectionalScanner/dynamicalscannero7.h => FBSD/DirectionalScanner/adaptivescannero8.h} (67%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscanner.cpp (100%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscanner.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero1.cpp (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero1.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero2.cpp (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero2.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero7.cpp (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero7.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero8.cpp (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/directionalscannero8.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/scannerprovider.cpp (91%)
 rename Code/{Seg => FBSD}/DirectionalScanner/scannerprovider.h (99%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero1.cpp (95%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero1.h (96%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero2.cpp (95%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero2.h (95%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero7.cpp (95%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero7.h (96%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero8.cpp (95%)
 rename Code/{Seg => FBSD}/DirectionalScanner/vhscannero8.h (96%)
 rename Code/{Seg/Seg.pro => FBSD/FBSD.pro} (86%)
 rename Code/{Seg => FBSD}/IPOLdemo/IPOLdemo.pro (89%)
 rename Code/{Seg => FBSD}/IPOLdemo/Input/couloir.gif (100%)
 rename Code/{Seg => FBSD}/IPOLdemo/Input/points.txt (100%)
 rename Code/{Seg => FBSD}/IPOLdemo/Scripts/convert.sh (100%)
 rename Code/{Seg => FBSD}/IPOLdemo/Scripts/displaySegments.sh (100%)
 rename Code/{Seg => FBSD}/IPOLdemo/Scripts/displaySegmentsInteract.sh (100%)
 rename Code/{Seg => FBSD}/IPOLdemo/mainIPOL.cpp (99%)
 rename Code/{Seg => FBSD}/ImageTools/absrat.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/absrat.h (99%)
 rename Code/{Seg => FBSD}/ImageTools/digitalstraightline.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/digitalstraightline.h (99%)
 rename Code/{Seg => FBSD}/ImageTools/digitalstraightsegment.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/digitalstraightsegment.h (99%)
 rename Code/{Seg => FBSD}/ImageTools/pt2i.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/pt2i.h (99%)
 rename Code/{Seg => FBSD}/ImageTools/strucel.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/strucel.h (98%)
 rename Code/{Seg => FBSD}/ImageTools/vmap.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/vmap.h (99%)
 rename Code/{Seg => FBSD}/ImageTools/vr2i.cpp (100%)
 rename Code/{Seg => FBSD}/ImageTools/vr2i.h (99%)
 rename Code/{Seg => FBSD}/main.cpp (84%)
 delete mode 100644 README.md

diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp
similarity index 50%
rename from Code/Seg/BSTools/bsdetectionwidget.cpp
rename to Code/FBSD/BSTools/bsdetectionwidget.cpp
index e6e535c..511c432 100755
--- a/Code/Seg/BSTools/bsdetectionwidget.cpp
+++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp
@@ -83,7 +83,7 @@ QSize BSDetectionWidget::openImage (const QString &fileName, int type)
   if (profileview != NULL) profileview->setImage (&loadedImage, gMap);
   if (strucview != NULL) strucview->setGradientImage (&gradImage);
 
-  return newSize;
+  return newSize.boundedTo (QSize (768, 512));
 }
 
 
@@ -145,7 +145,8 @@ void BSDetectionWidget::buildGradientImage (int dir)
 {
   int w = gMap->getWidth ();
   int h = gMap->getHeight ();
-  double gn[w * h];
+  double *gn = new double[w * h];
+  // double gn[w * h];
   for (int j = 0; j < h; j++)
     for (int i = 0; i < w; i++)
     {
@@ -374,7 +375,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
   {
     case Qt::Key_A :
       // Registers the last extracted blurred segment
-      saveExtractedSegment ();
+      if (saveExtractedSegment ())
+        cout << "Last blurred segment(s) registered" << endl;
+      else cout << "No last segment(s) to register" << endl;
       break;
 
     case Qt::Key_B :
@@ -399,6 +402,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
     case Qt::Key_C :
       // Clears the registered blurred segments
       clearSavedSegments ();
+      cout << "Registered segments withdrawn" << endl;
       break;
 
     case Qt::Key_D :
@@ -420,13 +424,13 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       switch (detector.edgeDirectionConstraint ())
       {
         case 0 :
-          cout << "Stroke detection" << endl;
+          cout << "Line detection mode set" << endl;
           break;
         case 1 :
-          cout << "Edge detection" << endl;
+          cout << "Main edge detection mode set" << endl;
           break;
         case -1 :
-          cout << "Opposite edge detection" << endl;
+          cout << "Opposite edge detection mode set" << endl;
           break;
       }
       extract ();
@@ -456,10 +460,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       else
       {
         // Tunes the gradient threshold for maximal value detection
-        detector.incGradientThreshold (
+        detector.incSensitivity (
           (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
-        cout << "Gradient threshold = "
-             << detector.getGradientThreshold () << endl;
+        cout << "Sensitivity = " << detector.getSensitivity () << endl;
         extract ();
       }
       break;
@@ -502,7 +505,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       {
         // Switches the final step connectivity constraint
         detector.switchConnectivityConstraint ();
-        cout << "Connectivity constraint "
+        cout << "Fragmentation test "
              << (detector.isConnectivityConstraintOn () ? "on" : "off")
              << endl;
         extract ();
@@ -512,7 +515,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         // Tunes the minimal size of connected components
         detector.incConnectedComponentMinSize (
                     (event->modifiers () & Qt::ShiftModifier) == 0);
-        cout << "Connected components min size = "
+        cout << "Fragments minimal size = "
              << detector.getConnectedComponentMinSize () << endl;
         extract ();
       }
@@ -532,7 +535,8 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         // Tunes the output blurred segment minimal size
         detector.setBSminSize (detector.getBSminSize () +
           (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
-        cout << "Output BS min size = " << detector.getBSminSize () << endl;
+        cout << "Detected blurred segments min size = "
+             << detector.getBSminSize () << endl;
         extract ();
       }
       break;
@@ -551,6 +555,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         udef = false;
         detector.resetMaxDetections ();
         extract ();
+        cout << "All segments detected" << endl;
       }
       break;
 
@@ -599,7 +604,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       {
         // Switches the preliminary detection
         detector.switchPreliminary ();
-        cout << "Preliminary detection "
+        cout << "Initial detection duplication "
              << (detector.isPreliminary () ? "on" : "off") << endl;
         extract ();
       }
@@ -624,6 +629,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       {
         // Displays registered blurred segments
         displaySavedSegments ();
+        cout << "All registered segments displayed" << endl;
       }
       break;
 
@@ -641,7 +647,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         // Tunes the automatic detection grid resolution
         detector.setAutoGridResolution (detector.getAutoGridResolution () +
           (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
-        cout << "Auto grid resolution = "
+        cout << "Automatic detection grid resolution = "
              << detector.getAutoGridResolution () << " pixels" << endl;
       }
       break;
@@ -661,8 +667,8 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         detector.setPixelLackTolerence (detector.getPixelLackTolerence () +
           (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
         extract ();
-        cout << "Lack tolerence = " << detector.getPixelLackTolerence ()
-             << " pixels" << endl;
+        cout << "Tolerence to detection lacks = "
+             << detector.getPixelLackTolerence () << " pixels" << endl;
       }
       break;
 
@@ -684,7 +690,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       {
         // Switches the display of the detected blurred segment bounds
         bsBoundsVisible = ! bsBoundsVisible;
-        cout << "Segments bounds "
+        cout << "Enclosing segments "
              << (bsBoundsVisible ? "visible" : "hidden") << endl;
         extract ();
       }
@@ -738,7 +744,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         detector.setFineTracksMaxWidth (detector.fineTracksMaxWidth () +
           (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
         extract ();
-        cout << "Fine tracks max width = "
+        cout << "Initial assigned width = "
              << detector.fineTracksMaxWidth () << endl;
       }
       break;
@@ -748,7 +754,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
       {
         // Switches the display of the detected blurred segment pixels
         bsPointsVisible = ! bsPointsVisible;
-        cout << "Segments points "
+        cout << "Blurred segment "
              << (bsPointsVisible ? "visible" : "hidden") << endl;
         displayDetectionResult ();
       }
@@ -769,7 +775,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
         if (detector.isThickenningOn () && detector.isThinningOn ())
           detector.toggleThinning ();
         extract ();
-        cout << "Thickenning "
+        cout << "Assigned width control "
              << (detector.isThickenningOn () ? "on" : "off") << endl;
       }
       else
@@ -829,7 +835,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
     case Qt::Key_6 :
       detector.switchDetector ();
       cout << (detector.oldDetectorOn () ?
-               "Old detector set" : "Present detector set") << endl;
+               "Old detector set" : "New detector set") << endl;
       extract ();
       break;
 
@@ -1123,11 +1129,12 @@ void BSDetectionWidget::displaySavedSegments ()
 }
 
 
-void BSDetectionWidget::saveExtractedSegment ()
+bool BSDetectionWidget::saveExtractedSegment ()
 {
   if (detector.isMultiSelection ())
   {
     vector<BlurredSegment *> bss = detector.getBlurredSegments ();
+    if (bss.empty ()) return false;
     vector<BlurredSegment *>::const_iterator it = bss.begin ();
     while (it != bss.end ())
     {
@@ -1142,16 +1149,15 @@ void BSDetectionWidget::saveExtractedSegment ()
   else
   {
     BlurredSegment *bs = detector.getBlurredSegment ();
-    if (bs != NULL)
-    {
-      ExtractedSegment es;
-      es.bs = bs;
-      es.p1 = p1;
-      es.p2 = p2;
-      extractedSegments.push_back (es);
-      detector.preserveFormerBlurredSegment ();
-    }
+    if (bs == NULL) return false;
+    ExtractedSegment es;
+    es.bs = bs;
+    es.p1 = p1;
+    es.p2 = p2;
+    extractedSegments.push_back (es);
+    detector.preserveFormerBlurredSegment ();
   }
+  return true;
 }
 
 
@@ -1477,989 +1483,3 @@ void BSDetectionWidget::localTest ()
   extract ();
   cout << "Test run" << endl;
 }
-
-
-void BSDetectionWidget::createMap (QString name,
-                                   bool *tofind, bool *found, int iw, int ih)
-{
-  QImage mymap = QImage (width, height, QImage::Format_RGB32);
-  for (int j = 0; j < ih; j ++)
-    for (int i = 0; i < iw; i ++)
-    {
-      int col = 0;
-      if (tofind[j * iw + i])
-        if (found[j * iw + i]) col = 255 * 256;
-        else col = 255;
-      else if (found[j * iw + i]) col = 255 * 256 * 256;
-      mymap.setPixel (i, j, col);
-    }
-  mymap.save (name);
-}
-
-
-QSize BSDetectionWidget::setRandomImage (int type)
-{
-  int swidth = 256;
-  int sheight = 256;
-  int sminwidth = 2;
-  int smaxwidth = 5;
-  int sminlength = 20;
-  int margin = 10;
-  int longEdgeThreshold = 1600;
-  width = swidth + 2 * margin;
-  height = sheight + 2 * margin;
-  loadedImage = QImage (width, height, QImage::Format_RGB32);
-  srand (time (NULL));
-  udef = false;
-  detector.setFineTracksMaxWidth (7);
-  if (! detector.isFinalLengthTestOn ()) detector.switchFinalLengthTest ();
-
-  int nbsegs = 10;
-  Pt2i rp1[nbsegs];
-  Pt2i rp2[nbsegs];
-  Vr2i rdir[nbsegs];
-  int rw[nbsegs];
-  vector<BlurredSegment *> rbs[nbsegs];
-   
-  bool unbiasOn = true;
-  AbsRat biasVal (7, 5);
-  bool dispEach = false;
-  bool dispLast = false;
-  int nbruns = 1000;
-  int nbIniPts[nbruns];
-  int oldTrials[nbruns];
-  int newTrials[nbruns];
-  int oldDetections[nbruns];
-  int newDetections[nbruns];
-  int oldLongDetections[nbruns];
-  int newLongDetections[nbruns];
-  int oldNbNomatch[nbruns];
-  int newNbNomatch[nbruns];
-  int oldUndet[nbruns];
-  int newUndet[nbruns];
-  int oldTrueArea[nbruns];
-  int newTrueArea[nbruns];
-  int oldFalseArea[nbruns];
-  int newFalseArea[nbruns];
-  int oldRedet[nbruns];
-  int newRedet[nbruns];
-  int oldFalse[nbruns];
-  int newFalse[nbruns];
-  double oldPrec[nbruns];
-  double newPrec[nbruns];
-  double oldRecall[nbruns];
-  double newRecall[nbruns];
-  double oldFmeas[nbruns];
-  double newFmeas[nbruns];
-  double oldNbMatched[nbruns];
-  double newNbMatched[nbruns];
-  double oldWidthBias[nbruns];
-  double newWidthBias[nbruns];
-  double oldWidth[nbruns];
-  double newWidth[nbruns];
-  double oldWidthDiff[nbruns];
-  double newWidthDiff[nbruns];
-  double oldAbsWDiff[nbruns];
-  double newAbsWDiff[nbruns];
-  double oldAngDiff[nbruns];
-  double newAngDiff[nbruns];
-  double oldAbsADiff[nbruns];
-  double newAbsADiff[nbruns];
-  double oldLongADiff[nbruns];
-  double newLongADiff[nbruns];
-
-  for (int run = 0; run < nbruns; run ++)
-  {
-    if (dispEach) cout << "Generating new segments" << endl;
-    int val;
-    for (int i = 0; i < width; i ++)
-      for (int j = 0; j < height; j ++)
-      {
-//        val = rand () % 30;   // ZZZ
-        val = 255 - (rand () % 30);
-        loadedImage.setPixel (i, j, val + val * 256 + val * 256 * 256);
-      }
-    for (int i = 0; i < nbsegs; i++)
-    {
-      rp1[i].set (margin + rand () % swidth, margin + rand () % sheight);
-      bool nok = false;
-      do
-      {
-        nok = false;
-        rp2[i].set (margin + rand () % swidth, margin + rand () % sheight);
-        if (rp1[i].chessboard (rp2[i]) < sminlength) nok = true;
-        else
-        {
-          double score1, score2, score3;
-          rdir[i] = rp1[i].vectorTo (rp2[i]);
-          Pt2i bsc ((rp1[i].x () + rp2[i].x ()) / 2,
-                    (rp1[i].y () + rp2[i].y ()) / 2);
-          for (int si = 0; (! nok) && si < i - 1; si ++)
-          {
-            score1 = rdir[si].squaredScalarProduct (rdir[i])
-                            / (rdir[si].norm2 () * rdir[i].norm2 ());
-            Vr2i ali = rp1[si].vectorTo (bsc);
-            score2 = rdir[si].squaredScalarProduct (ali)
-                     / (rdir[si].norm2 () * ali.norm2 ());
-            bsc.set ((rp1[si].x () + rp2[si].x ()) / 2,
-                     (rp1[si].y () + rp2[si].y ()) / 2);
-            ali = rp1[i].vectorTo (bsc);
-            score3 = rdir[i].squaredScalarProduct (ali)
-                     / (rdir[i].norm2 () * ali.norm2 ());
-            if (score1 > 0.7 && (score2 > 0.7 || score3 > 0.7)) nok = true;
-          }
-        }
-      }
-      while (nok);
-      rw[i] = sminwidth + rand () % (smaxwidth - sminwidth);
-
-      DigitalStraightSegment dss (rp1[i], rp2[i], rw[i]);
-      vector<Pt2i> pix;
-      dss.getPoints (pix);
-      vector<Pt2i>::iterator it = pix.begin ();
-      while (it != pix.end ())
-      {
-        Pt2i p = *it++;
-        if (p.x () >= 0 && p.x () < width && p.y () >= 0 && p.y () < height)
-          loadedImage.setPixel (p.x (), height - 1 - p.y (), 0);
-//          loadedImage.setPixel (p.x (), height - 1 - p.y (),  // ZZZ
-//                                255 + 255 * 256 + 255 * 256 * 256);  // ZZZ
-      }
-    }
-
-    if (dispEach) cout << "Initializing the detector" << endl;
-    if (gMap != NULL) delete gMap;
-    gMap = new VMap (width, height, getBitmap (loadedImage), type);
-    detector.setGradientMap (gMap);
-    buildGradientImage (0);
-    gMap->incGradientThreshold (50 - gMap->getGradientThreshold ());
-
-    if (dispEach) cout << "Preparing the result maps" << endl;
-    nbIniPts[run] = 0;
-    bool tofind[width * height];
-    bool stilltofind[width * height];
-    bool found[width * height];
-    bool foundin[width * height];
-    bool foundout[width * height];
-    for (int j = 0; j < height; j++)
-      for (int i = 0; i < width; i++)
-      {
-        tofind[j * width + i] = QColor (loadedImage.pixel (i, height - 1 - j))
-                                .value () < 10;
-//                                .value () > 200;   // ZZZ
-        stilltofind[j * width + i] = tofind[j * width + i];
-        found[j * width + i] = false;
-        foundin[j * width + i] = false;
-        foundout[j * width + i] = false;
-        if (tofind[j * width + i]) nbIniPts[run] ++;
-      }
-if (nbIniPts[run] == 0) cout << "CARTE VIDE" << endl;
-    int detmap[width * height];
-    int *dm = detmap;
-    for (int i = 0; i < width * height; i++) *dm++ = 0;
-
-    if (dispEach) cout << "Running the old detection" << endl;
-    if (! detector.oldDetectorOn ()) detector.switchDetector ();
-    extract ();
-
-    if (dispEach) cout << "Analyzing the old blurred segments" << endl;
-    for (int i = 0; i < nbsegs; i++) rbs[i].clear ();
-    oldNbNomatch[run] = 0;
-    int nbdssnul = 0;
-    oldLongDetections[run] = 0;
-    double nomatchlength = 0.;
-    vector<BlurredSegment *> bss = detector.getBlurredSegments ();
-    vector<BlurredSegment *>::iterator bsit = bss.begin ();
-    while (bsit != bss.end ())
-    {
-      DigitalStraightSegment *dss = (*bsit)->getSegment ();
-      if (dss != NULL)
-      {
-        if (unbiasOn) dss = dss->erosion (biasVal.numerator (),
-                                          biasVal.denominator ());
-        vector<Pt2i> dsspts;
-        dss->getPoints (dsspts);
-        vector<Pt2i>::iterator dssit = dsspts.begin ();
-        while (dssit != dsspts.end ())
-        {
-          Pt2i dsspt = *dssit++;
-          if (dsspt.x () >= 0 && dsspt.x () < width
-              && dsspt.y () >= 0 && dsspt.y () < height)
-          {
-            stilltofind[dsspt.y () * width + dsspt.x ()] = false;
-            found[dsspt.y () * width + dsspt.x ()] = true;
-            if (tofind[dsspt.y () * width + dsspt.x ()])
-            {
-              detmap[dsspt.y () * width + dsspt.x ()] ++;
-              foundin[dsspt.y () * width + dsspt.x ()] = true;
-            }
-            else
-            {
-              detmap[dsspt.y () * width + dsspt.x ()] --;
-              foundout[dsspt.y () * width + dsspt.x ()] = true;
-            }
-          }
-        }
-
-        Vr2i dssdir = dss->supportVector ();
-        Pt2i ptb = (*bsit)->getLastRight ();
-        Pt2i ptf = (*bsit)->getLastLeft ();
-        Pt2i bsc ((ptb.x () + ptf.x ()) / 2, (ptb.y () + ptf.y ()) / 2);
-        double bsl2 = (ptb.x () - ptf.x ()) * (ptb.x () - ptf.x ())
-                      + (ptb.y () - ptf.y ()) * (ptb.y () - ptf.y ());
-        if (bsl2 > longEdgeThreshold) oldLongDetections[run] ++;
-        double score[nbsegs];
-        double minscore = 0.;
-        int bestfit = -1;
-        for (int si = 0; si < nbsegs; si++)
-        {
-          double denom = rdir[si].norm2 () * dssdir.norm2 ();
-          score[si] = rdir[si].squaredScalarProduct (dssdir) / denom;
-          Vr2i bsac = rp1[si].vectorTo (bsc);
-          denom = rdir[si].norm2 () * bsac.norm2 ();
-          score[si] *= rdir[si].squaredScalarProduct (bsac) / denom;
-          if (rdir[si].scalarProduct (bsac) < 0) score[si] = 0.;
-          Vr2i bscb = bsc.vectorTo (rp2[si]);
-          if (rdir[si].scalarProduct (bscb) < 0) score[si] = 0.;
-          if (minscore < score[si])
-          {
-            minscore = score[si];
-            bestfit = si;
-          }
-        }
-        if (minscore > 0.7) rbs[bestfit].push_back (*bsit);
-        else
-        {
-          oldNbNomatch[run] ++;
-          nomatchlength += sqrt (bsl2);
-        }
-        delete dss;
-      }
-      else nbdssnul ++;
-      bsit ++;
-    }
-
-    if (dispEach) cout << "  OLD DETECTOR :" << endl;
-    oldTrials[run] = detector.countOfTrials ();
-    oldDetections[run] = (int) (detector.getBlurredSegments().size ());
-    if (dispEach)
-    {
-      cout << oldDetections[run] << " blurred segments detected on "
-           << oldTrials[run] << " trials " << endl;
-      cout << oldLongDetections[run] << " long blurred segments detected on "
-           << oldTrials[run] << " trials " << endl;
-    }
-    if (dispLast && run == nbruns - 1)
-      createMap ("oldmap.png", tofind, found, width, height);
-    oldUndet[run] = 0;
-    oldTrueArea[run] = 0;
-    oldFalseArea[run] = 0;
-    for (int i = 0; i < width * height; i++)
-    {
-      if (stilltofind[i]) oldUndet[run] ++;
-      if (foundin[i]) oldTrueArea[run] ++;
-      if (foundout[i]) oldFalseArea[run] ++;
-    }
-    if (dispEach)
-      cout << (nbIniPts[run] - oldUndet[run]) << " points detected on "
-           << nbIniPts[run] << " ("
-           << (nbIniPts[run] - oldUndet[run]) * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-    oldRedet[run] = 0;
-    for (int i = 0; i < width * height; i++)
-      if (detmap[i] > 1) oldRedet[run] += (detmap[i] - 1);
-    if (dispEach)
-      cout << oldRedet[run] << " points redetected on " << nbIniPts[run]
-           << " (" << oldRedet[run] * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-    oldFalse[run] = 0;
-    for (int i = 0; i < width * height; i++)
-      if (detmap[i] < 0) oldFalse[run] ++;
-    oldPrec[run] = nbIniPts[run] - oldUndet[run];
-    oldRecall[run] = oldPrec[run] / nbIniPts[run];
-    oldPrec[run] = oldPrec[run] / (oldPrec[run] + oldFalse[run]);
-    oldFmeas[run] = 2 * oldPrec[run] * oldRecall[run]
-                    / (oldPrec[run] + oldRecall[run]);
-    if (dispEach)
-    {
-      cout << oldFalse[run] << " false points detected on " << nbIniPts[run]
-           << " (" << oldFalse[run] * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-      cout << "Precision : " << oldPrec[run] << endl;
-      cout << "Recall : " << oldRecall[run] << endl;
-      cout << "F-measure : " << oldFmeas[run] << endl;
-      cout << oldNbNomatch[run] << " unmatched blurred segment (mean length : "
-           << (oldNbNomatch[run] != 0 ? nomatchlength / oldNbNomatch[run] : 0)
-           << ")" << endl;
-      cout << nbdssnul << " DSS nuls" << endl;
-    }
-
-    oldWidthBias[run] = 0.;
-    oldWidth[run] = 0.;
-    oldWidthDiff[run] = 0.;
-    oldAbsWDiff[run] = 0.;
-    oldAngDiff[run] = 0.;
-    oldAbsADiff[run] = 0.;
-    oldLongADiff[run] = 0.;
-    oldNbMatched[run] = 0;
-    for (int si = 0; si < nbsegs; si ++)
-    {
-      if (! rbs[si].empty ()) oldNbMatched[run] ++;
-      vector<BlurredSegment *>::iterator sit = rbs[si].begin ();
-      while (sit != rbs[si].end ())
-      {
-        Pt2i ptb = (*sit)->getLastRight ();
-        Pt2i ptf = (*sit)->getLastLeft ();
-        double bsl2 = (ptb.x () - ptf.x ()) * (ptb.x () - ptf.x ())
-                      + (ptb.y () - ptf.y ()) * (ptb.y () - ptf.y ());
-        DigitalStraightSegment *mydss = (*sit)->getSegment ();
-        oldWidthBias[run] += (mydss->width () / (double) (mydss->period ()))
-                             * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        if (unbiasOn) mydss = mydss->erosion (biasVal.numerator (),
-                                              biasVal.denominator ());
-        oldWidth[run] += (mydss->width () / (double) (mydss->period ()))
-                         * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        double wd = (mydss->width () / (double) (mydss->period ()) - rw[si])
-                    * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        oldWidthDiff[run] += wd;
-        if (wd < 0) wd = -wd;
-        oldAbsWDiff[run] += wd;
-        Vr2i mydir = mydss->supportVector ();
-        double ang = rdir[si].scalarProduct (mydir);
-        bool onleft = rdir[si].leftside (mydir);
-        if (ang < 0.)
-        {
-          ang = - ang;
-          onleft = - onleft;
-        }
-        double den = sqrt (rdir[si].norm2 ()) * sqrt (mydir.norm2 ());
-        if (den > ang)
-        {
-          ang = acos (ang / den) * 180 / M_PI;
-          ang *= sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-          oldAbsADiff[run] += ang;
-          oldAngDiff[run] += (onleft ? ang : -ang);
-          if (bsl2 > longEdgeThreshold) oldLongADiff[run] += ang;
-        }
-        delete mydss;
-        sit ++;
-      }
-    }
-    if (dispEach)
-    {
-      cout << "Biased width = "
-         << (oldNbMatched[run] != 0 ?
-             oldWidthBias[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Width = "
-         << (oldNbMatched[run] != 0 ?
-             oldWidth[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Width difference = "
-         << (oldNbMatched[run] != 0 ?
-             oldWidthDiff[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Absolute width difference = "
-         << (oldNbMatched[run] != 0 ?
-             oldAbsWDiff[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Angle difference = "
-           << (oldNbMatched[run] != 0 ?
-               oldAngDiff[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Absolute angle difference = "
-           << (oldNbMatched[run] != 0 ?
-               oldAbsADiff[run] / oldNbMatched[run] : 0) << endl;
-      cout << "Long edge angle difference = "
-           << (oldNbMatched[run] != 0 ?
-               oldLongADiff[run] / oldNbMatched[run] : 0) << endl;
-    }
-
-    if (dispEach) cout << "Resetting the result maps" << endl;
-    for (int j = 0; j < height; j++)
-      for (int i = 0; i < width; i++)
-      {
-        stilltofind[j * width + i] = tofind[j * width + i];
-        found[j * width + i] = false;
-        foundin[j * width + i] = false;
-        foundout[j * width + i] = false;
-      }
-    dm = detmap;
-    for (int i = 0; i < width * height; i++) *dm++ = 0;
-
-    if (dispEach) cout << "Running the new detection" << endl;
-    detector.switchDetector ();
-    extract ();
-
-    if (dispEach) cout << "Analyzing the new blurred segments" << endl;
-    for (int i = 0; i < nbsegs; i++) rbs[i].clear ();
-    newNbNomatch[run] = 0;
-    nbdssnul = 0;
-    newLongDetections[run] = 0;
-    nomatchlength = 0.;
-    bss = detector.getBlurredSegments ();
-    bsit = bss.begin ();
-    while (bsit != bss.end ())
-    {
-      DigitalStraightSegment *dss = (*bsit)->getSegment ();
-      if (dss != NULL)
-      {
-        if (unbiasOn) dss = dss->erosion (biasVal.numerator (),
-                                          biasVal.denominator ());
-        vector<Pt2i> dsspts;
-        dss->getPoints (dsspts);
-        vector<Pt2i>::iterator dssit = dsspts.begin ();
-        while (dssit != dsspts.end ())
-        {
-          Pt2i dsspt = *dssit++;
-          if (dsspt.x () >= 0 && dsspt.x () < width
-              && dsspt.y () >= 0 && dsspt.y () < height)
-          {
-            stilltofind[dsspt.y () * width + dsspt.x ()] = false;
-            found[dsspt.y () * width + dsspt.x ()] = true;
-            if (tofind[dsspt.y () * width + dsspt.x ()])
-            {
-              detmap[dsspt.y () * width + dsspt.x ()] ++;
-              foundin[dsspt.y () * width + dsspt.x ()] = true;
-            }
-            else
-            {
-              detmap[dsspt.y () * width + dsspt.x ()] --;
-              foundout[dsspt.y () * width + dsspt.x ()] = true;
-            }
-          }
-        }
-
-        Vr2i dssdir = dss->supportVector ();
-        Pt2i ptb = (*bsit)->getLastRight ();
-        Pt2i ptf = (*bsit)->getLastLeft ();
-        Pt2i bsc ((ptb.x () + ptf.x ()) / 2, (ptb.y () + ptf.y ()) / 2);
-        double bsl2 = (ptb.x () - ptf.x ()) * (ptb.x () - ptf.x ())
-                      + (ptb.y () - ptf.y ()) * (ptb.y () - ptf.y ());
-        if (bsl2 > longEdgeThreshold) newLongDetections[run] ++;
-        double score[nbsegs];
-        double minscore = 0.;
-        int bestfit = -1;
-        for (int si = 0; si < nbsegs; si++)
-        {
-          double denom = rdir[si].norm2 () * dssdir.norm2 ();
-          score[si] = rdir[si].squaredScalarProduct (dssdir) / denom;
-          Vr2i bsac = rp1[si].vectorTo (bsc);
-          denom = rdir[si].norm2 () * bsac.norm2 (); 
-          score[si] *= rdir[si].squaredScalarProduct (bsac) / denom;
-          if (rdir[si].scalarProduct (bsac) < 0) score[si] = 0.;
-          Vr2i bscb = bsc.vectorTo (rp2[si]); 
-          if (rdir[si].scalarProduct (bscb) < 0) score[si] = 0.;
-          if (minscore < score[si])
-          { 
-            minscore = score[si];
-            bestfit = si;
-          }
-        }
-        if (minscore > 0.7) rbs[bestfit].push_back (*bsit);
-        else
-        {
-          newNbNomatch[run] ++;
-          nomatchlength += sqrt (bsl2);
-        }
-        delete dss;
-      }
-      else nbdssnul ++;
-      bsit ++;
-    }
-
-    if (dispEach) cout << "  NEW DETECTOR :" << endl;
-    newTrials[run] = detector.countOfTrials ();
-    newDetections[run] = (int) (detector.getBlurredSegments().size ());
-    if (dispEach)
-    {
-      cout << newDetections[run] << " blurred segments detected on "
-           << newTrials[run] << " trials " << endl;
-      cout << newLongDetections[run] << " long blurred segments detected on "
-           << newTrials[run] << " trials " << endl;
-    }
-    if (dispLast && run == nbruns - 1)
-      createMap ("newmap.png", tofind, found, width, height);
-    newUndet[run] = 0;
-    newTrueArea[run] = 0;
-    newFalseArea[run] = 0;
-    for (int i = 0; i < width * height; i++)
-    {
-      if (stilltofind[i]) newUndet[run] ++;
-      if (foundin[i]) newTrueArea[run] ++;
-      if (foundout[i]) newFalseArea[run] ++;
-    }
-    if (dispEach)
-      cout << (nbIniPts[run] - newUndet[run]) << " points detected on "
-           << nbIniPts[run] << " ("
-           << (nbIniPts[run] - newUndet[run]) * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-    newRedet[run] = 0;
-    for (int i = 0; i < width * height; i++)
-      if (detmap[i] > 1) newRedet[run] += (detmap[i] - 1);
-    if (dispEach)
-      cout << (newRedet[run]) << " points redetected on " << nbIniPts[run]
-           << " (" << newRedet[run] * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-    newFalse[run] = 0;
-    for (int i = 0; i < width * height; i++)
-      if (detmap[i] < 0) newFalse[run] ++;
-    newPrec[run] = nbIniPts[run] - newUndet[run];
-    newRecall[run] = newPrec[run] / nbIniPts[run];
-    newPrec[run] = newPrec[run] / (newPrec[run] + newFalse[run]);
-    newFmeas[run] = 2 * newPrec[run] * newRecall[run]
-                    / (newPrec[run] + newRecall[run]);
-    if (dispEach)
-    {
-      cout << newFalse[run] << " false points detected on " << nbIniPts[run]
-           << " (" << newFalse[run] * 100 / (double) nbIniPts[run]
-           << " %)" << endl;
-      cout << "Precision : " << newPrec[run] << endl;
-      cout << "Recall : " << newRecall[run] << endl;
-      cout << "F-measure : " << newFmeas[run] << endl;
-      cout << newNbNomatch[run] << " unmatched blurred segment (mean length : "
-           << (newNbNomatch[run] != 0 ? nomatchlength / newNbNomatch[run] : 0)
-           << ")" << endl;
-      cout << nbdssnul << " DSS nuls" << endl;
-    }
-
-    newWidthBias[run] = 0.;
-    newWidth[run] = 0.;
-    newWidthDiff[run] = 0.;
-    newAbsWDiff[run] = 0.;
-    newAngDiff[run] = 0.;
-    newAbsADiff[run] = 0.;
-    newLongADiff[run] = 0.;
-    newNbMatched[run] = 0;
-    for (int si = 0; si < nbsegs; si ++)
-    {
-      if (! rbs[si].empty ()) newNbMatched[run] ++;
-      vector<BlurredSegment *>::iterator sit = rbs[si].begin ();
-      while (sit != rbs[si].end ())
-      {
-        Pt2i ptb = (*sit)->getLastRight ();
-        Pt2i ptf = (*sit)->getLastLeft ();
-        double bsl2 = (ptb.x () - ptf.x ()) * (ptb.x () - ptf.x ())
-                      + (ptb.y () - ptf.y ()) * (ptb.y () - ptf.y ());
-        DigitalStraightSegment *mydss = (*sit)->getSegment ();
-        newWidthBias[run] += (mydss->width () / (double) (mydss->period ()))
-                             * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        if (unbiasOn) mydss = mydss->erosion (biasVal.numerator (),
-                                              biasVal.denominator ());
-        newWidth[run] += (mydss->width () / (double) (mydss->period ()))
-                         * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        double wd = (mydss->width () / (double) (mydss->period ()) - rw[si])
-                    * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-        newWidthDiff[run] += wd;
-        if (wd < 0) wd = -wd;
-        newAbsWDiff[run] += wd;
-        Vr2i mydir = mydss->supportVector ();
-        double ang = rdir[si].scalarProduct (mydir);
-        bool onleft = rdir[si].leftside (mydir);
-        if (ang < 0.)
-        {
-          ang = - ang;
-          onleft = - onleft;
-        }
-        double den = sqrt (rdir[si].norm2 ()) * sqrt (mydir.norm2 ());
-        if (den > ang)
-        {
-          ang = acos (ang / den) * 180 / M_PI;
-          ang *= sqrt (bsl2) / sqrt (rdir[si].norm2 ());
-          newAbsADiff[run] += ang;
-          newAngDiff[run] += (onleft ? ang : -ang);
-          if (bsl2 > longEdgeThreshold) newLongADiff[run] += ang;
-        }
-        delete mydss;
-        sit ++;
-      }
-    }
-    if (dispEach)
-    {
-      cout << "Biased width = "
-           << (newNbMatched[run] != 0 ?
-               newWidthBias[run] / newNbMatched[run] : 0) << endl;
-      cout << "Width = "
-           << (newNbMatched[run] != 0 ?
-               newWidth[run] / newNbMatched[run] : 0) << endl;
-      cout << "Width difference = "
-           << (newNbMatched[run] != 0 ?
-               newWidthDiff[run] / newNbMatched[run] : 0) << endl;
-      cout << "Absolute width difference = "
-           << (newNbMatched[run] != 0 ?
-               newAbsWDiff[run] / newNbMatched[run] : 0) << endl;
-      cout << "Angle difference = "
-           << (newNbMatched[run] != 0 ?
-               newAngDiff[run] / newNbMatched[run] : 0) << endl;
-      cout << "Absolute angle difference = "
-           << (newNbMatched[run] != 0 ?
-               newAbsADiff[run] / newNbMatched[run] : 0) << endl;
-      cout << "Long edge angle difference = "
-           << (newNbMatched[run] != 0 ?
-               newLongADiff[run] / newNbMatched[run] : 0) << endl;
-    }
-  }
-
-  double mean, sdev, total;
-  double total_nbIniPts = 0;
-  for (int i = 0; i < nbruns; i++) total_nbIniPts += nbIniPts[i];
-
-  cout << "  RESULTS FOR THE OLD DETECTOR" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldTrials[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldTrials[i] - mean) * (oldTrials[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") segments searches (local min) / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldDetections[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldDetections[i] - mean) * (oldDetections[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") provided segments / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldLongDetections[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldLongDetections[i] - mean) * (oldLongDetections[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") provided long segments / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldNbNomatch[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldNbNomatch[i] - mean) * (oldNbNomatch[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") undetected segments per image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += nbIniPts[i] - oldUndet[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += ((nbIniPts[i] - oldUndet[i]) / (double) nbIniPts[i] - mean)
-            * ((nbIniPts[i] - oldUndet[i]) / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Recall : " << 100 * mean << " (pm " << 100 * sdev
-       << ") % of points found" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldRedet[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldRedet[i] / (double) nbIniPts[i] - mean)
-            * (oldRedet[i] / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << 100 * mean << " (pm " << 100 * sdev
-       << ") % of points found more than once (redetections)" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldFalse[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldFalse[i] / (double) nbIniPts[i] - mean)
-            * (oldFalse[i] / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << 100 * mean << " (pm " << 100 * sdev
-       << ") % false points produced" << endl;
-  mean = 0.;
-  sdev = 0.;
-  int numer = 0;
-  int denom = 0;
-  for (int i = 0; i < nbruns; i++)
-  {
-    numer += nbIniPts[i] - oldUndet[i];
-    denom += oldFalse[i] + nbIniPts[i] - oldUndet[i];
-  }
-  mean = numer / (double) denom;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldPrec[i] - mean) * (oldPrec[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Precision : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldPrec[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldPrec[i] - mean) * (oldPrec[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical precision : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldRecall[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldRecall[i] - mean) * (oldRecall[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical recall : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldFmeas[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldFmeas[i] - mean) * (oldFmeas[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical F-measure : " << mean << " (pm " << sdev << ")" << endl;
-  total = 0;
-  for (int i = 0; i < nbruns; i++) total += oldNbMatched[i];
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldWidthBias[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldWidthBias[i] / (double) oldNbMatched[i] - mean)
-            * (oldWidthBias[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Biased width : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldWidth[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldWidth[i] / (double) oldNbMatched[i] - mean)
-            * (oldWidth[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Width : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldWidthDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldWidthDiff[i] / (double) oldNbMatched[i] - mean)
-            * (oldWidthDiff[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Width difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldAbsWDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldAbsWDiff[i] / (double) oldNbMatched[i] - mean)
-            * (oldAbsWDiff[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Absolute width difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldAngDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldAngDiff[i] / (double) oldNbMatched[i] - mean)
-            * (oldAngDiff[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Angle difference : " << mean << " (" << sdev
-       << ") degrees per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldAbsADiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldAbsADiff[i] / (double) oldNbMatched[i] - mean)
-            * (oldAbsADiff[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Absolute angle difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += oldLongADiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (oldLongADiff[i] / (double) oldNbMatched[i] - mean)
-            * (oldLongADiff[i] / (double) oldNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Absolute long edge angle difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-
-  cout << "  RESULTS FOR THE NEW DETECTOR" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newTrials[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newTrials[i] - mean) * (newTrials[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") segments searches (local min) / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newDetections[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newDetections[i] - mean) * (newDetections[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") provided segments / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newLongDetections[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newLongDetections[i] - mean) * (newLongDetections[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") provided long segments / image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newNbNomatch[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newNbNomatch[i] - mean) * (newNbNomatch[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << mean << " (pm " << sdev
-       << ") undetected segments per image" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += nbIniPts[i] - newUndet[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += ((nbIniPts[i] - newUndet[i]) / (double) nbIniPts[i] - mean)
-            * ((nbIniPts[i] - newUndet[i]) / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Recall : " << 100 * mean << " (pm " << 100 * sdev
-       << ") % of points found" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newRedet[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newRedet[i] / (double) nbIniPts[i]- mean)
-            * (newRedet[i] / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << 100 * mean << " (pm " << 100 * sdev
-       << ") % of points found more than once (redetections)" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newFalse[i];
-  mean /= total_nbIniPts;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newFalse[i] / (double) nbIniPts[i] - mean)
-            * (newFalse[i] / (double) nbIniPts[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << 100 * mean << " (pm " << 100 * sdev
-       << ") % false points produced" << endl;
-  mean = 0.;
-  sdev = 0.;
-  numer = 0;
-  denom = 0;
-  for (int i = 0; i < nbruns; i++)
-  {
-    numer += nbIniPts[i] - newUndet[i];
-    denom += newFalse[i] + nbIniPts[i] - newUndet[i];
-  }
-  mean = numer / (double) denom;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newPrec[i] - mean) * (newPrec[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Precision : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newPrec[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newPrec[i] - mean) * (newPrec[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical precision : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newRecall[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newRecall[i] - mean) * (newRecall[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical recall : " << mean << " (pm " << sdev << ")" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newFmeas[i];
-  mean /= nbruns;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newFmeas[i] - mean) * (newFmeas[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Statistical F-measure : " << mean << " (pm " << sdev << ")" << endl;
-  total = 0;
-  for (int i = 0; i < nbruns; i++) total += newNbMatched[i];
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newWidthBias[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newWidthBias[i] / (double) newNbMatched[i] - mean)
-            * (newWidthBias[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Biased width : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newWidth[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newWidth[i] / (double) newNbMatched[i] - mean)
-            * (newWidth[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Width : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newWidthDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newWidthDiff[i] / (double) newNbMatched[i] - mean)
-            * (newWidthDiff[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Width difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newAbsWDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newAbsWDiff[i] / (double) newNbMatched[i] - mean)
-            * (newAbsWDiff[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Absolute width difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newAngDiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newAngDiff[i] / (double) newNbMatched[i] - mean)
-            * (newAngDiff[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Angle difference : " << mean << " (" << sdev
-       << ") degrees per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newAbsADiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newAbsADiff[i] / (double) newNbMatched[i] - mean)
-            * (newAbsADiff[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Absolute angle difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-  mean = 0.;
-  sdev = 0.;
-  for (int i = 0; i < nbruns; i++) mean += newLongADiff[i];
-  mean /= total;
-  for (int i = 0; i < nbruns; i++)
-    sdev += (newLongADiff[i] / (double) newNbMatched[i] - mean)
-            * (newLongADiff[i] / (double) newNbMatched[i] - mean);
-  sdev = sqrt (sdev / (nbruns - 1));
-  cout << "Long edge absolute angle difference : " << mean << " (" << sdev
-       << ") per matched segment" << endl;
-
-  cout << "Updating the displays" << endl;
-  augmentedImage = loadedImage;
-  update ();
-  if (idetview != NULL) idetview->setImage (&loadedImage, gMap);
-  if (profileview != NULL) profileview->setImage (&loadedImage, gMap);
-  if (strucview != NULL) strucview->setGradientImage (&gradImage);
-  return loadedImage.size ();
-}
diff --git a/Code/Seg/BSTools/bsdetectionwidget.h b/Code/FBSD/BSTools/bsdetectionwidget.h
similarity index 97%
rename from Code/Seg/BSTools/bsdetectionwidget.h
rename to Code/FBSD/BSTools/bsdetectionwidget.h
index 57993cb..bdc1521 100755
--- a/Code/Seg/BSTools/bsdetectionwidget.h
+++ b/Code/FBSD/BSTools/bsdetectionwidget.h
@@ -38,14 +38,6 @@ public:
    */
   ~BSDetectionWidget ();
 
-void createMap (QString name, bool *tofind, bool *found, int iw, int ih);
-
-  /**
-   * \brief Creates and opens a random image to be processed.
-   * @param type Gradient extraction method.
-   */
-  QSize setRandomImage (int type = 0);
-
   /**
    * \brief Opens the image to be processed.
    * @param type Name of the image file to open.
@@ -396,8 +388,9 @@ private:
 
   /**
    * \brief Registers the last extracted blurred segment.
+   * Returns whether something is saved or not.
    */
-  void saveExtractedSegment ();
+  bool saveExtractedSegment ();
 
   /**
    * \brief Clears off the saved blurred segments.
diff --git a/Code/Seg/BSTools/bsidetitem.cpp b/Code/FBSD/BSTools/bsidetitem.cpp
similarity index 100%
rename from Code/Seg/BSTools/bsidetitem.cpp
rename to Code/FBSD/BSTools/bsidetitem.cpp
diff --git a/Code/Seg/BSTools/bsidetitem.h b/Code/FBSD/BSTools/bsidetitem.h
similarity index 100%
rename from Code/Seg/BSTools/bsidetitem.h
rename to Code/FBSD/BSTools/bsidetitem.h
diff --git a/Code/Seg/BSTools/bsidetview.cpp b/Code/FBSD/BSTools/bsidetview.cpp
similarity index 100%
rename from Code/Seg/BSTools/bsidetview.cpp
rename to Code/FBSD/BSTools/bsidetview.cpp
diff --git a/Code/Seg/BSTools/bsidetview.h b/Code/FBSD/BSTools/bsidetview.h
similarity index 100%
rename from Code/Seg/BSTools/bsidetview.h
rename to Code/FBSD/BSTools/bsidetview.h
diff --git a/Code/Seg/BSTools/bsprofileitem.cpp b/Code/FBSD/BSTools/bsprofileitem.cpp
similarity index 100%
rename from Code/Seg/BSTools/bsprofileitem.cpp
rename to Code/FBSD/BSTools/bsprofileitem.cpp
diff --git a/Code/Seg/BSTools/bsprofileitem.h b/Code/FBSD/BSTools/bsprofileitem.h
similarity index 100%
rename from Code/Seg/BSTools/bsprofileitem.h
rename to Code/FBSD/BSTools/bsprofileitem.h
diff --git a/Code/Seg/BSTools/bsprofileview.cpp b/Code/FBSD/BSTools/bsprofileview.cpp
similarity index 100%
rename from Code/Seg/BSTools/bsprofileview.cpp
rename to Code/FBSD/BSTools/bsprofileview.cpp
diff --git a/Code/Seg/BSTools/bsprofileview.h b/Code/FBSD/BSTools/bsprofileview.h
similarity index 100%
rename from Code/Seg/BSTools/bsprofileview.h
rename to Code/FBSD/BSTools/bsprofileview.h
diff --git a/Code/FBSD/BSTools/bsrandomtester.cpp b/Code/FBSD/BSTools/bsrandomtester.cpp
new file mode 100755
index 0000000..84551ec
--- /dev/null
+++ b/Code/FBSD/BSTools/bsrandomtester.cpp
@@ -0,0 +1,702 @@
+#include <QtGui>
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+#include <ctime>
+#include "bsrandomtester.h"
+
+using namespace std;
+
+
+
+BSRandomTester::BSRandomTester ()
+{
+  swidth = 256;
+  sheight = 256;
+  margin = 10;
+  width = swidth + 2 * margin;
+  height = sheight + 2 * margin;
+  isize = width * height;
+
+  nbdets = 2;
+  nbruns = 1000;
+  nbsegs = 10;
+  sminwidth = 2;
+  smaxwidth = 5;
+  swmargin = 2;
+  sminlength = 20;
+  longEdgeThreshold = 1600;
+
+  unbiasOn = true;
+  biasVal.set (7, 5);
+
+  dispEach = false;
+  dispLast = false;
+
+  rp1 = new Pt2i[nbsegs];
+  rp2 = new Pt2i[nbsegs];
+  rdir = new Vr2i[nbsegs];
+  rw = new int[nbsegs];
+  tofind_map = new bool[isize];
+  hit_map = new int[isize];
+  stilltofind_map = new bool[isize];
+  found_map = new bool[isize];
+  foundin_map = new bool[isize];
+  foundout_map = new bool[isize];
+
+  nbIniPts = new int[nbruns];
+  int nbt = nbdets * nbruns;
+
+  c_trials = new int[nbt];
+  c_det = new int[nbt];
+  c_ldet = new int[nbt];
+  c_unmatch = new int[nbt];
+  c_undet = new int[nbt];
+  c_trueArea = new int[nbt];
+  c_falseArea = new int[nbt];
+  c_redetArea = new int[nbt];
+  c_false = new int[nbt];
+
+  m_precision = new double[nbt];
+  m_recall = new double[nbt];
+  m_fmeasure = new double[nbt];
+  m_matched = new double[nbt];
+  m_biased_width = new double[nbt];
+  m_width = new double[nbt];
+  m_wdiff = new double[nbt];
+  m_abswdiff = new double[nbt];
+  m_adiff = new double[nbt];
+  m_absadiff = new double[nbt];
+  m_long_absadiff = new double[nbt];
+
+  detectors = new BSDetector[nbdets];
+  for (int i = 0; i < nbdets; i++)
+  {
+    detectors[i].setFineTracksMaxWidth (smaxwidth + swmargin);
+    if (! detectors[i].isFinalLengthTestOn ())
+      detectors[i].switchFinalLengthTest ();
+  }
+  if (! detectors[0].oldDetectorOn ()) detectors[0].switchDetector ();
+  if (detectors[1].oldDetectorOn ()) detectors[1].switchDetector ();
+  names = new QString[nbdets];
+  names[0] = "old";
+  names[1] = "new";
+
+  image = QImage (width, height, QImage::Format_RGB32);
+  srand (time (NULL));
+}
+
+
+BSRandomTester::~BSRandomTester ()
+{
+  if (gMap != NULL) delete gMap;
+  delete [] names;
+  delete [] detectors;
+  delete [] m_long_absadiff;
+  delete [] m_absadiff;
+  delete [] m_adiff;
+  delete [] m_abswdiff;
+  delete [] m_wdiff;
+  delete [] m_width;
+  delete [] m_biased_width;
+  delete [] m_matched;
+  delete [] m_fmeasure;
+  delete [] m_recall;
+  delete [] m_precision;
+  delete [] c_false;
+  delete [] c_redetArea;
+  delete [] c_falseArea;
+  delete [] c_trueArea;
+  delete [] c_undet;
+  delete [] c_unmatch;
+  delete [] c_ldet;
+  delete [] c_det;
+  delete [] c_trials;
+  delete [] nbIniPts;
+  delete [] foundout_map;
+  delete [] foundin_map;
+  delete [] found_map;
+  delete [] stilltofind_map;
+  delete [] hit_map;
+  delete [] tofind_map;
+  delete [] rw;
+  delete [] rdir;
+  delete [] rp2;
+  delete [] rp1;
+}
+
+
+void BSRandomTester::randomTest ()
+{
+  // List of detected segments match to each input segment
+  vector<BlurredSegment *> rbs[nbsegs];
+
+  cout << "Testing ..." << endl;
+  for (int run = 0; run < nbruns; run ++)
+  {
+    // Generates an image and provide it to the detectors
+    if (dispEach) cout << "Generating new segments" << endl;
+    generateImage ();
+    if (gMap != NULL) delete gMap;
+    gMap = new VMap (width, height, getBitmap (image), VMap::TYPE_SOBEL_5X5);
+    gMap->incGradientThreshold (50 - gMap->getGradientThreshold ());
+    for (int det = 0; det < nbdets; det ++)
+      detectors[det].setGradientMap (gMap);
+
+    for (int det = 0; det < nbdets; det ++)
+    {
+      int num = det * nbruns + run;
+
+      // Detects the segments
+      if (dispEach) cout << "Running detector " << (det + 1) << endl;
+      detectors[det].detectAll ();
+
+      nbIniPts[run] = 0;
+      for (int i = 0; i < isize; i++)
+      {
+        stilltofind_map[i] = tofind_map[i];
+        found_map[i] = false;
+        foundin_map[i] = false;
+        foundout_map[i] = false;
+        if (tofind_map[i]) nbIniPts[run] ++;
+        hit_map[i] = 0;
+      }
+
+      if (dispEach) cout << "Analyzing the blurred segments" << endl;
+      for (int i = 0; i < nbsegs; i++) rbs[i].clear ();
+      c_unmatch[num] = 0;
+      int nbdssnul = 0;
+      c_ldet[run] = 0;
+      double nomatchlength = 0.;
+      vector<BlurredSegment *> bss = detectors[det].getBlurredSegments ();
+      vector<BlurredSegment *>::iterator bsit = bss.begin ();
+      while (bsit != bss.end ())
+      {
+        DigitalStraightSegment *dss = (*bsit)->getSegment ();
+        if (dss != NULL)
+        {
+          // Fills in occupancy maps
+          if (unbiasOn) dss = dss->erosion (biasVal.numerator (),
+                                            biasVal.denominator ());
+          vector<Pt2i> dsspts;
+          dss->getPoints (dsspts);
+          vector<Pt2i>::iterator dssit = dsspts.begin ();
+          while (dssit != dsspts.end ())
+          {
+            Pt2i dsspt = *dssit++;
+            if (dsspt.x () >= 0 && dsspt.x () < width
+                && dsspt.y () >= 0 && dsspt.y () < height)
+            {
+              stilltofind_map[dsspt.y () * width + dsspt.x ()] = false;
+              found_map[dsspt.y () * width + dsspt.x ()] = true;
+              if (tofind_map[dsspt.y () * width + dsspt.x ()])
+              {
+                hit_map[dsspt.y () * width + dsspt.x ()] ++;
+                foundin_map[dsspt.y () * width + dsspt.x ()] = true;
+              }
+              else
+              {
+                hit_map[dsspt.y () * width + dsspt.x ()] --;
+                foundout_map[dsspt.y () * width + dsspt.x ()] = true;
+              }
+            }
+          }
+
+          // Matches the detected segment with the nearest input segment
+          Vr2i dssdir = dss->supportVector ();
+          Pt2i bsc = (*bsit)->getMiddle ();
+          double bsl2 = (*bsit)->getSquarredLength ();
+          if (bsl2 > longEdgeThreshold) c_ldet[num] ++;
+          double score[nbsegs];
+          double minscore = 0.;
+          int bestfit = -1;
+          for (int si = 0; si < nbsegs; si++)
+          {
+            double denom = rdir[si].norm2 () * dssdir.norm2 ();
+            score[si] = rdir[si].squaredScalarProduct (dssdir) / denom;
+            Vr2i bsac = rp1[si].vectorTo (bsc);
+            denom = rdir[si].norm2 () * bsac.norm2 ();
+            score[si] *= rdir[si].squaredScalarProduct (bsac) / denom;
+            if (rdir[si].scalarProduct (bsac) < 0) score[si] = 0.;
+            Vr2i bscb = bsc.vectorTo (rp2[si]);
+            if (rdir[si].scalarProduct (bscb) < 0) score[si] = 0.;
+            if (minscore < score[si])
+            {
+              minscore = score[si];
+              bestfit = si;
+            }
+          }
+          if (minscore > 0.7) rbs[bestfit].push_back (*bsit);
+          else
+          {
+            c_unmatch[num] ++;
+            nomatchlength += sqrt (bsl2);
+          }
+          delete dss;
+        }
+        else nbdssnul ++;
+        bsit ++;
+      }
+
+      if (dispEach) cout << "  DETECTOR "
+                         << names[det].toStdString () << " :" << endl;
+      c_trials[num] = detectors[det].countOfTrials ();
+      c_det[num] = (int) (detectors[det].getBlurredSegments().size ());
+      if (dispEach)
+      {
+        cout << c_det[num] << " blurred segments detected on "
+             << c_trials[num] << " trials " << endl;
+        cout << c_ldet[num] << " long blurred segments detected on "
+             << c_trials[num] << " trials " << endl;
+      }
+      if (dispLast && run == nbruns - 1) createMap (names[det]);
+      c_undet[num] = 0;
+      c_trueArea[num] = 0;
+      c_falseArea[num] = 0;
+      for (int i = 0; i < width * height; i++)
+      {
+        if (stilltofind_map[i]) c_undet[num] ++;
+        if (foundin_map[i]) c_trueArea[num] ++;
+        if (foundout_map[i]) c_falseArea[num] ++;
+      }
+      if (dispEach)
+        cout << (nbIniPts[run] - c_undet[num]) << " points detected on "
+             << nbIniPts[run] << " ("
+             << (nbIniPts[run] - c_undet[num]) * 100 / (double) nbIniPts[run]
+             << " %)" << endl;
+      c_redetArea[num] = 0;
+      for (int i = 0; i < width * height; i++)
+        if (hit_map[i] > 1) c_redetArea[num] += (hit_map[i] - 1);
+      if (dispEach)
+        cout << c_redetArea[num] << " points redetected on " << nbIniPts[run]
+             << " (" << c_redetArea[num] * 100 / (double) nbIniPts[run]
+             << " %)" << endl;
+      c_false[num] = 0;
+      for (int i = 0; i < width * height; i++)
+        if (hit_map[i] < 0) c_false[num] ++;
+      m_precision[num] = nbIniPts[run] - c_undet[num];
+      m_recall[num] = m_precision[num] / nbIniPts[run];
+      m_precision[num] = m_precision[num] / (m_precision[num] + c_false[num]);
+      m_fmeasure[num] = 2 * m_precision[num] * m_recall[num]
+                      / (m_precision[num] + m_recall[num]);
+      if (dispEach)
+      {
+        cout << c_false[num] << " false points detected on " << nbIniPts[run]
+             << " (" << c_false[num] * 100 / (double) nbIniPts[run]
+             << " %)" << endl;
+        cout << "Precision : " << m_precision[num] << endl;
+        cout << "Recall : " << m_recall[num] << endl;
+        cout << "F-measure : " << m_fmeasure[num] << endl;
+        cout << c_unmatch[num] << " unmatched blurred segment (mean length : "
+             << (c_unmatch[num] != 0 ? nomatchlength / c_unmatch[num] : 0)
+             << ")" << endl;
+        cout << nbdssnul << " DSS nuls" << endl;
+      }
+
+      m_biased_width[num] = 0.;
+      m_width[num] = 0.;
+      m_wdiff[num] = 0.;
+      m_abswdiff[num] = 0.;
+      m_adiff[num] = 0.;
+      m_absadiff[num] = 0.;
+      m_long_absadiff[num] = 0.;
+      m_matched[num] = 0;
+      for (int si = 0; si < nbsegs; si ++)
+      {
+        // Compares input and detected segments
+        if (! rbs[si].empty ()) m_matched[num] ++;
+        vector<BlurredSegment *>::iterator sit = rbs[si].begin ();
+        while (sit != rbs[si].end ())
+        {
+          double bsl2 = (*sit)->getSquarredLength ();
+          DigitalStraightSegment *mydss = (*sit)->getSegment ();
+          m_biased_width[num] += (mydss->width () / (double) (mydss->period ()))
+                                 * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
+          if (unbiasOn) mydss = mydss->erosion (biasVal.numerator (),
+                                                biasVal.denominator ());
+          m_width[num] += (mydss->width () / (double) (mydss->period ()))
+                           * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
+          double wd = (mydss->width () / (double) (mydss->period ()) - rw[si])
+                      * sqrt (bsl2) / sqrt (rdir[si].norm2 ());
+          m_wdiff[num] += wd;
+          if (wd < 0) wd = -wd;
+          m_abswdiff[num] += wd;
+          Vr2i mydir = mydss->supportVector ();
+          double ang = rdir[si].scalarProduct (mydir);
+          bool onleft = rdir[si].leftside (mydir);
+          if (ang < 0.)
+          {
+            ang = - ang;
+            onleft = - onleft;
+          }
+          double den = sqrt (rdir[si].norm2 ()) * sqrt (mydir.norm2 ());
+          if (den > ang)
+          {
+            ang = acos (ang / den) * 180 / M_PI;
+            ang *= sqrt (bsl2) / sqrt (rdir[si].norm2 ());
+            m_absadiff[num] += ang;
+            m_adiff[num] += (onleft ? ang : -ang);
+            if (bsl2 > longEdgeThreshold) m_long_absadiff[num] += ang;
+          }
+          delete mydss;
+          sit ++;
+        }
+      }
+      if (dispEach)
+      {
+        cout << "Biased width = "
+           << (m_matched[num] != 0 ?
+               m_biased_width[num] / m_matched[num] : 0) << endl;
+        cout << "Width = "
+             << (m_matched[num] != 0 ?
+                 m_width[num] / m_matched[num] : 0) << endl;
+        cout << "Width difference = "
+             << (m_matched[num] != 0 ?
+                 m_wdiff[num] / m_matched[num] : 0) << endl;
+        cout << "Absolute width difference = "
+             << (m_matched[num] != 0 ?
+                 m_abswdiff[num] / m_matched[num] : 0) << endl;
+        cout << "Angle difference = "
+             << (m_matched[num] != 0 ?
+                 m_adiff[num] / m_matched[num] : 0) << endl;
+        cout << "Absolute angle difference = "
+             << (m_matched[num] != 0 ?
+                 m_absadiff[num] / m_matched[num] : 0) << endl;
+        cout << "Long edge angle difference = "
+             << (m_matched[num] != 0 ?
+                 m_long_absadiff[num] / m_matched[num] : 0) << endl;
+      }
+    }
+  }
+
+  double total = 0., mean = 0., sdev = 0.;
+  double total_nbIniPts = 0;
+  for (int i = 0; i < nbruns; i++) total_nbIniPts += nbIniPts[i];
+
+  for (int det = 0; det < nbdets; det ++)
+  {
+    cout << "  RESULTS FOR THE DETECTOR " << names[det].toStdString () << endl;
+    for (int i = 0; i < nbruns; i++) mean += c_trials[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_trials[det * nbruns + i] - mean)
+              * (c_trials[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << mean << " (pm " << sdev
+         << ") segments searches (local min) / image" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += c_det[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_det[det * nbruns + i] - mean)
+              * (c_det[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << mean << " (pm " << sdev
+         << ") provided segments / image" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += c_ldet[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_ldet[det * nbruns + i] - mean)
+              * (c_ldet[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << mean << " (pm " << sdev
+         << ") provided long segments / image" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += c_unmatch[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_unmatch[det * nbruns + i] - mean)
+              * (c_unmatch[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << mean << " (pm " << sdev
+         << ") undetected segments per image" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++)
+      mean += nbIniPts[i] - c_undet[det * nbruns + i];
+    mean /= total_nbIniPts;
+    for (int i = 0; i < nbruns; i++)
+      sdev += ((nbIniPts[i] - c_undet[det * nbruns + i])
+               / (double) nbIniPts[i] - mean)
+              * ((nbIniPts[i] - c_undet[det * nbruns + i])
+                 / (double) nbIniPts[i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Recall : " << 100 * mean << " (pm " << 100 * sdev
+         << ") % of points found" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += c_redetArea[det * nbruns + i];
+    mean /= total_nbIniPts;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_redetArea[det * nbruns + i] / (double) nbIniPts[i] - mean)
+              * (c_redetArea[det * nbruns + i] / (double) nbIniPts[i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << 100 * mean << " (pm " << 100 * sdev
+         << ") % of points found more than once (redetections)" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += c_false[det * nbruns + i];
+    mean /= total_nbIniPts;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (c_false[det * nbruns + i] / (double) nbIniPts[i] - mean)
+              * (c_false[det * nbruns + i] / (double) nbIniPts[i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << 100 * mean << " (pm " << 100 * sdev
+         << ") % false points produced" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    int numer = 0;
+    int denom = 0;
+    for (int i = 0; i < nbruns; i++)
+    {
+      numer += nbIniPts[i] - c_undet[det * nbruns + i];
+      denom += c_false[det * nbruns + i]
+               + nbIniPts[i] - c_undet[det * nbruns + i];
+    }
+    mean = numer / (double) denom;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_precision[det * nbruns + i] - mean)
+              * (m_precision[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Precision : " << mean << " (pm " << sdev << ")" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_precision[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_precision[det * nbruns + i] - mean)
+              * (m_precision[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Statistical precision : " << mean
+         << " (pm " << sdev << ")" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_recall[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_recall[det * nbruns + i] - mean)
+              * (m_recall[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Statistical recall : " << mean << " (pm " << sdev << ")" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_fmeasure[det * nbruns + i];
+    mean /= nbruns;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_fmeasure[det * nbruns + i] - mean)
+              * (m_fmeasure[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Statistical F-measure : " << mean
+         << " (pm " << sdev << ")" << endl;
+    total = 0;
+    for (int i = 0; i < nbruns; i++) total += m_matched[det * nbruns + i];
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_biased_width[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_biased_width[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_biased_width[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Biased width : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_width[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_width[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_width[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Width : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_wdiff[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_wdiff[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_wdiff[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Width difference : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_abswdiff[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_abswdiff[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_abswdiff[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Absolute width difference : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_adiff[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_adiff[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_adiff[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Angle difference : " << mean << " (" << sdev
+         << ") degrees per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_absadiff[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_absadiff[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_absadiff[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Absolute angle difference : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+
+    mean = 0.;
+    sdev = 0.;
+    for (int i = 0; i < nbruns; i++) mean += m_long_absadiff[det * nbruns + i];
+    mean /= total;
+    for (int i = 0; i < nbruns; i++)
+      sdev += (m_long_absadiff[det * nbruns + i]
+               / (double) m_matched[det * nbruns + i] - mean)
+              * (m_long_absadiff[det * nbruns + i]
+                / (double) m_matched[det * nbruns + i] - mean);
+    sdev = sqrt (sdev / (nbruns - 1));
+    cout << "Absolute long edge angle difference : " << mean << " (" << sdev
+         << ") per matched segment" << endl;
+  }
+}
+
+
+void BSRandomTester::generateImage ()
+{
+  if (dispEach) cout << "Generating new segments" << endl;
+  int val;
+  for (int i = 0; i < width; i ++)
+    for (int j = 0; j < height; j ++)
+    {
+      // val = rand () % 30;   // ZZZ
+      val = 255 - (rand () % 30);
+      image.setPixel (i, j, val + val * 256 + val * 256 * 256);
+    }
+  for (int i = 0; i < nbsegs; i++)
+  {
+    rp1[i].set (margin + rand () % swidth, margin + rand () % sheight);
+    bool nok = false;
+    do
+    {
+      nok = false;
+      rp2[i].set (margin + rand () % swidth, margin + rand () % sheight);
+      if (rp1[i].chessboard (rp2[i]) < sminlength) nok = true;
+      else
+      {
+        double score1, score2, score3;
+        rdir[i] = rp1[i].vectorTo (rp2[i]);
+        Pt2i bsc ((rp1[i].x () + rp2[i].x ()) / 2,
+                  (rp1[i].y () + rp2[i].y ()) / 2);
+        for (int si = 0; (! nok) && si < i - 1; si ++)
+        {
+          score1 = rdir[si].squaredScalarProduct (rdir[i])
+                          / (rdir[si].norm2 () * rdir[i].norm2 ());
+          Vr2i ali = rp1[si].vectorTo (bsc);
+          score2 = rdir[si].squaredScalarProduct (ali)
+                   / (rdir[si].norm2 () * ali.norm2 ());
+          bsc.set ((rp1[si].x () + rp2[si].x ()) / 2,
+                   (rp1[si].y () + rp2[si].y ()) / 2);
+          ali = rp1[i].vectorTo (bsc);
+          score3 = rdir[i].squaredScalarProduct (ali)
+                   / (rdir[i].norm2 () * ali.norm2 ());
+          if (score1 > 0.7 && (score2 > 0.7 || score3 > 0.7)) nok = true;
+        }
+      }
+    }
+    while (nok);
+    rw[i] = sminwidth + rand () % (smaxwidth - sminwidth);
+
+    DigitalStraightSegment dss (rp1[i], rp2[i], rw[i]);
+    vector<Pt2i> pix;
+    dss.getPoints (pix);
+    vector<Pt2i>::iterator it = pix.begin ();
+    while (it != pix.end ())
+    {
+      Pt2i p = *it++;
+      if (p.x () >= 0 && p.x () < width && p.y () >= 0 && p.y () < height)
+        image.setPixel (p.x (), height - 1 - p.y (), 0);
+        // image.setPixel (p.x (), height - 1 - p.y (),  // ZZZ
+        //                 255 + 255 * 256 + 255 * 256 * 256);  // ZZZ
+    }
+  }
+
+  for (int j = 0; j < height; j++)
+    for (int i = 0; i < width; i++)
+      tofind_map[j * width + i] =
+        QColor (image.pixel (i, height - 1 - j)).value () < 10;
+        // QColor (image.pixel (i, height - 1 - j)).value () > 200; // ZZZ
+}
+
+
+void BSRandomTester::createMap (QString name)
+{
+  QImage mymap = QImage (width, height, QImage::Format_RGB32);
+  for (int j = 0; j < height; j ++)
+    for (int i = 0; i < width; i ++)
+    {
+      int col = 0; 
+      if (tofind_map[j * width + i])
+        if (found_map[j * width + i]) col = 255 * 256;
+        else col = 255;
+      else if (found_map[j * width + i]) col = 255 * 256 * 256;
+      mymap.setPixel (i, j, col);
+    }
+  mymap.save (name + "_map.png");
+}
+
+
+int **BSRandomTester::getBitmap (const QImage &image)
+{
+  int w = image.width ();
+  int h = image.height ();
+
+  int **tabImage = new int*[h];
+  for (int i = 0; i < h; i++)
+  {
+    tabImage[i] = new int[w];
+    for(int j = 0; j < w; j++)
+    {
+      QColor c = QColor (image.pixel (j, h - i - 1));
+      tabImage[i][j] = c.value ();
+    }
+  }
+  return tabImage;
+}
diff --git a/Code/FBSD/BSTools/bsrandomtester.h b/Code/FBSD/BSTools/bsrandomtester.h
new file mode 100755
index 0000000..5b162f5
--- /dev/null
+++ b/Code/FBSD/BSTools/bsrandomtester.h
@@ -0,0 +1,169 @@
+#ifndef BS_RANDOM_TESTER_H
+#define BS_RANDOM_TESTER_H
+
+#include <QImage>
+#include <QString>
+#include "bsdetector.h"
+
+using namespace std;
+
+
+/** 
+ * @class BSRandomTester bsrandomtester.h
+ * \brief Segment detection random tester.
+ * Tests different detectors on randomly generated images.
+ * \author {P. Even}
+ */
+class BSRandomTester
+{
+public:
+
+  /**
+   * \brief Creates and initializes a segment detection random tester.
+   */
+  BSRandomTester ();
+
+  /**
+   * \brief Deletes the random tester.
+   */
+  ~BSRandomTester ();
+
+  /**
+   * \brief Runs a random test.
+   */
+  void randomTest ();
+
+
+private:
+ 
+  /** Effective test area width. */
+  int swidth;
+  /** Effective test area height. */
+  int sheight;
+  /** Test image margin size. */
+  int margin;
+
+  /** Number of random test images. */
+  int nbruns;
+  /** Number of randomly generated segments per image. */
+  int nbsegs;
+  /** Minimal thickness of randomly generated segments. */
+  int sminwidth;
+  /** Maximal thickness of randomly generated segments. */
+  int smaxwidth;
+  /** Assigned width tolerence to maximal segment width. */
+  int swmargin;
+  /** Minimal length of randomly generated segments. */
+  int sminlength;
+  /** Minimal squared length of detected segments considered as long. */
+  int longEdgeThreshold;
+
+  /** Generated image. */
+  QImage image;
+  /** Gradient map of the loaded picture. */
+  VMap *gMap;
+  /** Width of the present image. */
+  int width;
+  /** Height of the present image. */
+  int height;
+  /** Size of the present image. */
+  int isize;
+
+  /** Generated segments start point. */
+  Pt2i *rp1;
+  /** Generated segments end point. */
+  Pt2i *rp2;
+  /** Generated segments support vector. */
+  Vr2i *rdir;
+  /** Generated segments width. */
+  int *rw;
+  /** Occupancy map. */
+  bool *tofind_map;
+  /** Detected points map. */
+  int *hit_map;
+  /** Undetected points map. */
+  bool *stilltofind_map;
+  /** Found points map. */
+  bool *found_map;
+  /** Correct found points map. */
+  bool *foundin_map;
+  /** Incorrect found points map. */
+  bool *foundout_map;
+
+  /** Per image results display modality. */
+  bool dispEach;
+  /** Last image results display modality. */
+  bool dispLast;
+
+  /** Number of tested detector configurations. */
+  int nbdets;
+  /** Blurred segment detectors. */
+  BSDetector *detectors;
+  /** Detectors names. */
+  QString *names;
+  /** Gradient extraction bias removal modality. */
+  bool unbiasOn;
+  /** Gradient extraction bias value. */
+  AbsRat biasVal;
+
+  /** ???. */
+  int *nbIniPts;
+  /** Amount of tests on local minima per each detection. */
+  int *c_trials;
+  /** Amount of detected segments per each detection. */
+  int *c_det;
+  /** Amount of long detected segments per each detection. */
+  int *c_ldet;
+  /** Amount of unmatched segments per each detection. */
+  int *c_unmatch;
+  /** Amount of ??? per each detection. */
+  int *c_undet;
+  /** Amount of true area pixels per each detection. */
+  int *c_trueArea;
+  /** Amount of false area pixels per each detection. */
+  int *c_falseArea;
+  /** Amount of redetected area pixels per each detection. */
+  int *c_redetArea;
+  /** Amount of false pixels per each detection. */
+  int *c_false;
+
+  /** Measured precision per detector and per test. */
+  double *m_precision;
+  /** Measured recall per detector and per test. */
+  double *m_recall;
+  /** Measured F-measure per detector and per test. */
+  double *m_fmeasure;
+  /** Amount of matched segments per detector and per test. */
+  double *m_matched;
+  /** Measured biased width per detector and per test. */
+  double *m_biased_width;
+  /** Measured (debiased) width per detector and per test. */
+  double *m_width;
+  /** Measured width offset per detector and per test. */
+  double *m_wdiff;
+  /** Measured absolute width offset per detector and per test. */
+  double *m_abswdiff;
+  /** Measured angle offset per detector and per test. */
+  double *m_adiff;
+  /** Measured absolute angle offset per detector and per test. */
+  double *m_absadiff;
+  /** Measured absolute angle offset of long segments. */
+  double *m_long_absadiff;
+
+
+  /**
+   * \brief Generates a new random image of segments.
+   */
+  void generateImage ();
+
+  /**
+   * \brief Builds and returns the tested maps.
+   */
+  void createMap (QString name);
+
+  /**
+   * \brief Builds and returns the image bitmap.
+   */
+  int **getBitmap (const QImage &image);
+};
+#endif
diff --git a/Code/Seg/BSTools/bsstructureitem.cpp b/Code/FBSD/BSTools/bsstructureitem.cpp
similarity index 100%
rename from Code/Seg/BSTools/bsstructureitem.cpp
rename to Code/FBSD/BSTools/bsstructureitem.cpp
diff --git a/Code/Seg/BSTools/bsstructureitem.h b/Code/FBSD/BSTools/bsstructureitem.h
similarity index 98%
rename from Code/Seg/BSTools/bsstructureitem.h
rename to Code/FBSD/BSTools/bsstructureitem.h
index d1e8e80..217eab1 100755
--- a/Code/Seg/BSTools/bsstructureitem.h
+++ b/Code/FBSD/BSTools/bsstructureitem.h
@@ -6,6 +6,11 @@
 #include "bsdetector.h"
 
 
+/** 
+ * @class BSStructureItem bsstructureitem.h
+ * \brief Detection stage analysis view and controller.
+ * \author {P. Even}
+ */
 class BSStructureItem : public QGraphicsItem
 {
 public:
diff --git a/Code/Seg/BSTools/bsstructureview.cpp b/Code/FBSD/BSTools/bsstructureview.cpp
similarity index 95%
rename from Code/Seg/BSTools/bsstructureview.cpp
rename to Code/FBSD/BSTools/bsstructureview.cpp
index 758d5ce..4b11d22 100755
--- a/Code/Seg/BSTools/bsstructureview.cpp
+++ b/Code/FBSD/BSTools/bsstructureview.cpp
@@ -145,11 +145,11 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event)
       break;
 
     case Qt::Key_P : // Capture
-      viewport()->grab (
-        QRect (QPoint (0, 0),
-               QSize (grid->getWidth(), grid->getHeight()))
-        ).toImage().save ("structure.png");
-      cout << "Structure shot in structure.png" << endl;
+      // viewport()->grab (
+      //   QRect (QPoint (0, 0),
+      //          QSize (grid->getWidth(), grid->getHeight()))
+      //   ).toImage().save ("structure.png");
+      // cout << "Structure shot in structure.png" << endl;
       break;
 
     case Qt::Key_Y : // Background lightening
diff --git a/Code/Seg/BSTools/bsstructureview.h b/Code/FBSD/BSTools/bsstructureview.h
similarity index 93%
rename from Code/Seg/BSTools/bsstructureview.h
rename to Code/FBSD/BSTools/bsstructureview.h
index e113dd8..72df9db 100755
--- a/Code/Seg/BSTools/bsstructureview.h
+++ b/Code/FBSD/BSTools/bsstructureview.h
@@ -6,6 +6,11 @@
 #include "bsstructureitem.h"
 
 
+/** 
+ * @class BSStructureView bsstructureview.h
+ * \brief A Qt window containing informations about detection stages.
+ * \author {P. Even}
+ */
 class BSStructureView : public QGraphicsView
 {
 
diff --git a/Code/Seg/BSTools/bswindow.cpp b/Code/FBSD/BSTools/bswindow.cpp
similarity index 93%
rename from Code/Seg/BSTools/bswindow.cpp
rename to Code/FBSD/BSTools/bswindow.cpp
index 4ea7253..465abd7 100755
--- a/Code/Seg/BSTools/bswindow.cpp
+++ b/Code/FBSD/BSTools/bswindow.cpp
@@ -18,7 +18,7 @@ BSWindow::BSWindow (int *val)
   // setFocus();  
   // createActions ();
   // createMenus ();
-  setWindowTitle (tr ("Blurred Segments"));
+  setWindowTitle (tr ("FBSD"));
   resize (400, 400);
 }
 
@@ -35,18 +35,11 @@ BSWindow::BSWindow ()
   // setFocus ();
   // createActions ();
   // createMenus ();
-  setWindowTitle (tr ("Blurred Segments"));
+  setWindowTitle (tr ("FBSD"));
   resize (400, 400);
 }
 
 
-void BSWindow::setRandom ()
-{
-  resize (detectionWidget->setRandomImage (gradType));
-  detectionWidget->setDefaults ();
-}
-
-
 void BSWindow::setFile (QString fileName)
 {
   resize (detectionWidget->openImage (fileName, gradType));
@@ -89,7 +82,6 @@ void BSWindow::open ()
     windowSize = detectionWidget->openImage (fileName, gradType);
     updateActions ();
   }
-  resize (windowSize);
 }
 
 
diff --git a/Code/Seg/BSTools/bswindow.h b/Code/FBSD/BSTools/bswindow.h
similarity index 96%
rename from Code/Seg/BSTools/bswindow.h
rename to Code/FBSD/BSTools/bswindow.h
index 441147b..cf96abd 100755
--- a/Code/Seg/BSTools/bswindow.h
+++ b/Code/FBSD/BSTools/bswindow.h
@@ -27,11 +27,6 @@ public:
    */
   BSWindow (int *val);
 
-  /**
-   * Sets a random processed image.
-   */
-  void setRandom ();
-
   /**
    * Sets the processed image.
    */
diff --git a/Code/Seg/BlurredSegment/biptlist.cpp b/Code/FBSD/BlurredSegment/biptlist.cpp
similarity index 100%
rename from Code/Seg/BlurredSegment/biptlist.cpp
rename to Code/FBSD/BlurredSegment/biptlist.cpp
diff --git a/Code/Seg/BlurredSegment/biptlist.h b/Code/FBSD/BlurredSegment/biptlist.h
similarity index 99%
rename from Code/Seg/BlurredSegment/biptlist.h
rename to Code/FBSD/BlurredSegment/biptlist.h
index be01993..178ac0a 100755
--- a/Code/Seg/BlurredSegment/biptlist.h
+++ b/Code/FBSD/BlurredSegment/biptlist.h
@@ -127,6 +127,5 @@ private:
   int start;
   /** Length of the point list. */
   int cpt;
-
 };
 #endif
diff --git a/Code/Seg/BlurredSegment/blurredsegment.cpp b/Code/FBSD/BlurredSegment/blurredsegment.cpp
similarity index 92%
rename from Code/Seg/BlurredSegment/blurredsegment.cpp
rename to Code/FBSD/BlurredSegment/blurredsegment.cpp
index a9bfae2..205f4cf 100755
--- a/Code/Seg/BlurredSegment/blurredsegment.cpp
+++ b/Code/FBSD/BlurredSegment/blurredsegment.cpp
@@ -77,6 +77,23 @@ const Pt2i BlurredSegment::getLastLeft () const
 }
 
 
+int BlurredSegment::getSquarredLength () const
+{
+  Pt2i rp = plist->backPoint ();
+  Pt2i lp = plist->frontPoint ();
+  return ((rp.x () - lp.x ()) * (rp.x () - lp.x ())
+          + (rp.y () - lp.y ()) * (rp.y () - lp.y ()));
+}
+
+
+const Pt2i BlurredSegment::getMiddle () const
+{
+  Pt2i rp = plist->backPoint ();
+  Pt2i lp = plist->frontPoint ();
+  return (Pt2i ((rp.x () + lp.x ()) / 2, (rp.y () + lp.y ()) / 2));
+}
+
+
 Vr2i BlurredSegment::getSupportVector ()
 {
   return (dss->supportVector ());
diff --git a/Code/Seg/BlurredSegment/blurredsegment.h b/Code/FBSD/BlurredSegment/blurredsegment.h
similarity index 93%
rename from Code/Seg/BlurredSegment/blurredsegment.h
rename to Code/FBSD/BlurredSegment/blurredsegment.h
index 603d214..cf65f49 100755
--- a/Code/Seg/BlurredSegment/blurredsegment.h
+++ b/Code/FBSD/BlurredSegment/blurredsegment.h
@@ -5,6 +5,7 @@
 #include "convexhull.h"
 #include "digitalstraightsegment.h"
 #include "biptlist.h"
+#include <cstdlib>
 
 using namespace std;
 
@@ -16,7 +17,6 @@ using namespace std;
  */
 class BlurredSegment
 {
-
 public:
 
   /**
@@ -120,6 +120,18 @@ public:
    */
   const Pt2i getLastLeft () const;
 
+  /**
+   * \brief Returns the squarred length of the blurred segment.
+   * Returns the squarred distance between end points.
+   */
+  int getSquarredLength () const;
+
+  /**
+   * \brief Returns the middle point of the blurred segment.
+   * Returns the middle point between end points.
+   */
+  const Pt2i getMiddle () const;
+
   /**
    * \brief Returns the start point of the last antipodal edge. 
    */
@@ -192,6 +204,5 @@ protected:
   Pt2i lape;
   /** Last known antipodal vertex. */
   Pt2i lapv;
-
 };
 #endif
diff --git a/Code/Seg/BlurredSegment/blurredsegmentproto.cpp b/Code/FBSD/BlurredSegment/blurredsegmentproto.cpp
similarity index 100%
rename from Code/Seg/BlurredSegment/blurredsegmentproto.cpp
rename to Code/FBSD/BlurredSegment/blurredsegmentproto.cpp
diff --git a/Code/Seg/BlurredSegment/blurredsegmentproto.h b/Code/FBSD/BlurredSegment/blurredsegmentproto.h
similarity index 99%
rename from Code/Seg/BlurredSegment/blurredsegmentproto.h
rename to Code/FBSD/BlurredSegment/blurredsegmentproto.h
index bcf16db..b0aa66c 100755
--- a/Code/Seg/BlurredSegment/blurredsegmentproto.h
+++ b/Code/FBSD/BlurredSegment/blurredsegmentproto.h
@@ -16,7 +16,6 @@ using namespace std;
  */
 class BlurredSegmentProto : public BlurredSegment
 {
-
 public:
 
   /**
@@ -126,6 +125,5 @@ protected:
    * @param onleft Adding direction (true for LEFT, false for RIGHT).
    */
   bool addPoint (Pt2i p, bool onleft);
-
 };
 #endif
diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/FBSD/BlurredSegment/bsdetector.cpp
similarity index 100%
rename from Code/Seg/BlurredSegment/bsdetector.cpp
rename to Code/FBSD/BlurredSegment/bsdetector.cpp
diff --git a/Code/Seg/BlurredSegment/bsdetector.h b/Code/FBSD/BlurredSegment/bsdetector.h
similarity index 99%
rename from Code/Seg/BlurredSegment/bsdetector.h
rename to Code/FBSD/BlurredSegment/bsdetector.h
index 85f352b..8d85816 100755
--- a/Code/Seg/BlurredSegment/bsdetector.h
+++ b/Code/FBSD/BlurredSegment/bsdetector.h
@@ -3,6 +3,7 @@
 
 #include "bstracker.h"
 #include "bsfilter.h"
+#include <iostream>
 
 using namespace std;
 
@@ -14,7 +15,6 @@ using namespace std;
  */
 class BSDetector
 {
-
 public:
 
   /** Version number */
@@ -195,14 +195,14 @@ public:
   /**
    * \brief Returns the threshold used for maximal gradient detection.
    */
-  inline int getGradientThreshold () const {
+  inline int getSensitivity () const {
     return (gMap->getGradientThreshold ()); }
 
   /**
    * \brief Increments the threshold used for maximal gradient detection.
    * @param inc Increment value.
    */
-  inline void incGradientThreshold (int inc) {
+  inline void incSensitivity (int inc) {
     return (gMap->incGradientThreshold (inc)); }
 
   /**
@@ -720,6 +720,5 @@ private :
    * \brief Resets the multi-selection list.
    */
   void freeMultiSelection ();
-
 };
 #endif
diff --git a/Code/Seg/BlurredSegment/bsfilter.cpp b/Code/FBSD/BlurredSegment/bsfilter.cpp
similarity index 100%
rename from Code/Seg/BlurredSegment/bsfilter.cpp
rename to Code/FBSD/BlurredSegment/bsfilter.cpp
diff --git a/Code/Seg/BlurredSegment/bsfilter.h b/Code/FBSD/BlurredSegment/bsfilter.h
similarity index 100%
rename from Code/Seg/BlurredSegment/bsfilter.h
rename to Code/FBSD/BlurredSegment/bsfilter.h
diff --git a/Code/Seg/BlurredSegment/bstracker.cpp b/Code/FBSD/BlurredSegment/bstracker.cpp
similarity index 100%
rename from Code/Seg/BlurredSegment/bstracker.cpp
rename to Code/FBSD/BlurredSegment/bstracker.cpp
diff --git a/Code/Seg/BlurredSegment/bstracker.h b/Code/FBSD/BlurredSegment/bstracker.h
similarity index 99%
rename from Code/Seg/BlurredSegment/bstracker.h
rename to Code/FBSD/BlurredSegment/bstracker.h
index 2e9e102..bb2613b 100755
--- a/Code/Seg/BlurredSegment/bstracker.h
+++ b/Code/FBSD/BlurredSegment/bstracker.h
@@ -329,6 +329,5 @@ private :
   vector <vector <Pt2i> > scanLine;
   /** Dynamical scanner record modality. */
   bool recordScans;
-
 };
 #endif
diff --git a/Code/Seg/ConvexHull/antipodal.cpp b/Code/FBSD/ConvexHull/antipodal.cpp
similarity index 99%
rename from Code/Seg/ConvexHull/antipodal.cpp
rename to Code/FBSD/ConvexHull/antipodal.cpp
index 60b70fd..9e6b4e7 100755
--- a/Code/Seg/ConvexHull/antipodal.cpp
+++ b/Code/FBSD/ConvexHull/antipodal.cpp
@@ -123,6 +123,7 @@ int Antipodal::getB () const
 }
 
 
+/*
 ostream& operator<< (ostream &os, const Antipodal &ap)
 {
   os << (ap.ix ? "AV [" : "AH [") << *(ap.vpt) << " + ("
@@ -130,6 +131,7 @@ ostream& operator<< (ostream &os, const Antipodal &ap)
   if (ap.remainder (ap.vpt) == ap.remainder (ap.ept1)) os << "--HS--";
   return os;
 }
+*/
 
 
 void Antipodal::update (CHVertex *pt)
diff --git a/Code/Seg/ConvexHull/antipodal.h b/Code/FBSD/ConvexHull/antipodal.h
similarity index 92%
rename from Code/Seg/ConvexHull/antipodal.h
rename to Code/FBSD/ConvexHull/antipodal.h
index 4983403..39ce1dd 100755
--- a/Code/Seg/ConvexHull/antipodal.h
+++ b/Code/FBSD/ConvexHull/antipodal.h
@@ -2,11 +2,16 @@
 #define ANTIPODAL_H
 
 #include "chvertex.h"
-#include <ostream>
+#include <cstdlib>
 
 using namespace std;
 
 
+/** 
+ * @class Antipodal antipodal.h
+ * \brief Antipodal pair of a convex hull.
+ * \author {P. Even}
+ */
 class Antipodal
 {
 public:
@@ -61,7 +66,7 @@ public:
   void update (CHVertex *pt);
 
   /** Returns a string that represents the antipodal pair. */
-  friend ostream& operator<< (ostream &os, const Antipodal &ap);
+  // friend ostream& operator<< (ostream &os, const Antipodal &ap);
 
 
 protected:
diff --git a/Code/Seg/ConvexHull/chvertex.cpp b/Code/FBSD/ConvexHull/chvertex.cpp
similarity index 98%
rename from Code/Seg/ConvexHull/chvertex.cpp
rename to Code/FBSD/ConvexHull/chvertex.cpp
index 95f857d..d52655b 100755
--- a/Code/Seg/ConvexHull/chvertex.cpp
+++ b/Code/FBSD/ConvexHull/chvertex.cpp
@@ -27,8 +27,10 @@ CHVertex::~CHVertex ()
 }
 
 
+/*
 ostream& operator<< (ostream &os, const CHVertex &v)
 {
   os << "(" << v.xp << ", " << v.yp << ")";
   return os;
 }
+*/
diff --git a/Code/Seg/ConvexHull/chvertex.h b/Code/FBSD/ConvexHull/chvertex.h
similarity index 85%
rename from Code/Seg/ConvexHull/chvertex.h
rename to Code/FBSD/ConvexHull/chvertex.h
index 543e35d..1ed0c06 100755
--- a/Code/Seg/ConvexHull/chvertex.h
+++ b/Code/FBSD/ConvexHull/chvertex.h
@@ -2,13 +2,16 @@
 #define CHVERTEX_H
 
 #include "pt2i.h"
-#include <iostream>
+#include <cstdlib>
 
 
-/** Chained point with two adjacent points. */
+/** 
+ * @class CHVertex chvertex.h
+ * \brief Chained point with two adjacent points.
+ * \author {P. Even}
+ */
 class CHVertex : public Pt2i
 {
- 
 public:
 
   /** Builds a default vertex. */
@@ -37,7 +40,7 @@ public:
                    return ((p2->xp - xp) * (p4->yp - p3->yp)
                            - (p4->xp - p3->xp) * (p2->yp - yp)); }
 
-  friend ostream& operator<< (ostream &os, const CHVertex &v);
+  // friend ostream& operator<< (ostream &os, const CHVertex &v);
 
 
 protected:
diff --git a/Code/Seg/ConvexHull/convexhull.cpp b/Code/FBSD/ConvexHull/convexhull.cpp
similarity index 99%
rename from Code/Seg/ConvexHull/convexhull.cpp
rename to Code/FBSD/ConvexHull/convexhull.cpp
index d93a257..9be4b4f 100755
--- a/Code/Seg/ConvexHull/convexhull.cpp
+++ b/Code/FBSD/ConvexHull/convexhull.cpp
@@ -232,6 +232,7 @@ void ConvexHull::insertDS (CHVertex *pt, bool toleft)
 }
 
 
+/*
 ostream& operator<< (ostream &os, const ConvexHull &ch)
 {
   os << "APH = " << ch.aph << endl;
@@ -258,3 +259,4 @@ ostream& operator<< (ostream &os, const ConvexHull &ch)
 
   return os;
 }
+*/
diff --git a/Code/Seg/ConvexHull/convexhull.h b/Code/FBSD/ConvexHull/convexhull.h
similarity index 96%
rename from Code/Seg/ConvexHull/convexhull.h
rename to Code/FBSD/ConvexHull/convexhull.h
index 7d54e86..c3fdff6 100755
--- a/Code/Seg/ConvexHull/convexhull.h
+++ b/Code/FBSD/ConvexHull/convexhull.h
@@ -8,9 +8,13 @@
 using namespace std;
 
 
+/** 
+ * @class ConvexHull convexhull.h
+ * \brief Convex hull of a polyline.
+ * \author {P. Even}
+ */
 class ConvexHull
 {
-
 public:
 
   /**
@@ -74,7 +78,7 @@ public:
   /**
    * Returns a string that represents the convex hull.
    */
-  friend ostream& operator<< (ostream &os, const ConvexHull &ch);
+  // friend ostream& operator<< (ostream &os, const ConvexHull &ch);
 
   /**
    * Returns the first vertex of the convex hull.
@@ -117,26 +121,6 @@ public:
   inline CHVertex *getApvEdgeEnd () const { return (apv.edgeEnd ()); }
 
 
-private:
-
-  /**
-   * Stores the convexhull features before a modification.
-   */
-  void preserve ();
-
-  /**
-   * Inserts a new point into the convex hull.
-   */
-  void insert (CHVertex *pt, bool toleft);
-
-  /**
-   * Inserts a new point into the convex hull.
-   * To be used with directional scans :
-   *   In that case, opposite ends of the polyline can never pass each other.
-   */
-  void insertDS (CHVertex *pt, bool toleft);
-
-
 protected:
 
   /** Polyline left end point. */
@@ -165,5 +149,24 @@ protected:
   /** Collection of vertices for clearance. */
   vector<CHVertex*> gbg;
 
+
+private:
+
+  /**
+   * Stores the convexhull features before a modification.
+   */
+  void preserve ();
+
+  /**
+   * Inserts a new point into the convex hull.
+   */
+  void insert (CHVertex *pt, bool toleft);
+
+  /**
+   * Inserts a new point into the convex hull.
+   * To be used with directional scans :
+   *   In that case, opposite ends of the polyline can never pass each other.
+   */
+  void insertDS (CHVertex *pt, bool toleft);
 };
 #endif
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero1.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp
similarity index 92%
rename from Code/Seg/DirectionalScanner/dynamicalscannero1.cpp
rename to Code/FBSD/DirectionalScanner/adaptivescannero1.cpp
index e8ebdd5..db8f5d3 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero1.cpp
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero1.cpp
@@ -1,10 +1,9 @@
 #include <cstdlib>
-#include <iostream>
-#include "dynamicalscannero1.h"
+#include "adaptivescannero1.h"
 
 
 
-DynamicalScannerO1::DynamicalScannerO1 (
+AdaptiveScannerO1::AdaptiveScannerO1 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
@@ -27,7 +26,7 @@ DynamicalScannerO1::DynamicalScannerO1 (
 
 
 
-DynamicalScannerO1::DynamicalScannerO1 (
+AdaptiveScannerO1::AdaptiveScannerO1 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c1, int c2,
                           int nbs, bool *steps, int cx, int cy)
@@ -71,7 +70,7 @@ DynamicalScannerO1::DynamicalScannerO1 (
 
 
 
-DynamicalScannerO1::DynamicalScannerO1 (
+AdaptiveScannerO1::AdaptiveScannerO1 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b,
                           int nbs, bool *steps, int cx, int cy, int length)
@@ -114,7 +113,7 @@ DynamicalScannerO1::DynamicalScannerO1 (
 }
 
 
-int DynamicalScannerO1::first (vector<Pt2i> &scan)
+int AdaptiveScannerO1::first (vector<Pt2i> &scan)
 {
   int x = lcx, y = lcy;      // Current position coordinates
   bool *nst = steps;         // Current step in scan direction (jpts)
@@ -136,7 +135,7 @@ int DynamicalScannerO1::first (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO1::nextOnLeft (vector<Pt2i> &scan)
+int AdaptiveScannerO1::nextOnLeft (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -176,7 +175,7 @@ int DynamicalScannerO1::nextOnLeft (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO1::nextOnRight (vector<Pt2i> &scan)
+int AdaptiveScannerO1::nextOnRight (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -215,7 +214,7 @@ int DynamicalScannerO1::nextOnRight (vector<Pt2i> &scan)
 }
 
 
-void DynamicalScannerO1::bindTo (int a, int b, int c)
+void AdaptiveScannerO1::bindTo (int a, int b, int c)
 {
   if (a < 0)
   {
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero1.h b/Code/FBSD/DirectionalScanner/adaptivescannero1.h
similarity index 70%
rename from Code/Seg/DirectionalScanner/dynamicalscannero1.h
rename to Code/FBSD/DirectionalScanner/adaptivescannero1.h
index 4756ef3..c90c1eb 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero1.h
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero1.h
@@ -1,5 +1,5 @@
-#ifndef DYNAMICAL_SCANNER_O1_H
-#define DYNAMICAL_SCANNER_O1_H
+#ifndef ADAPTIVE_SCANNER_O1_H
+#define ADAPTIVE_SCANNER_O1_H
 
 #include "directionalscanner.h"
 
@@ -8,20 +8,20 @@ using namespace std;
 
 
 /** 
- * @class DynamicalScannerO1 dynamicalscannero1.h
- * \brief Dynamical directional scanner for the 1st octant.
+ * @class Adaptive dynamicalscannero1.h
+ * \brief Adaptive directional scanner for the 1st octant.
  * \author {P. Even}
  */
-class DynamicalScannerO1 : public DirectionalScanner
+class AdaptiveScannerO1 : public DirectionalScanner
 {
 
 public:
 
   /**
-   * @fn DynamicalScanner01(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int mu2,
-   *                        int nbs, bool *steps, int sx, int sy)
-   * \brief Creates a directional scanner from pattern, start and upper bound.
+   * @fn AdaptiveScanner01(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int mu2,
+   *                       int nbs, bool *steps, int sx, int sy)
+   * \brief Creates an adaptive DS from pattern, start and upper bound.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a start point, a line pattern, and an upper bound.
    * @param xmin left border of the scan area
@@ -36,15 +36,15 @@ public:
    * @param sx abscissae of the central scan start point
    * @param sy ordinate of the central scan start point
    */
-  DynamicalScannerO1 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c,
-                        int nbs, bool *steps, int sx, int sy);
+  AdaptiveScannerO1 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c,
+                     int nbs, bool *steps, int sx, int sy);
 
   /**
-   * @fn DynamicalScanner01(int xmin, int ymin, int xmax, int ymax,
+   * @fn AdaptiveScanner01(int xmin, int ymin, int xmax, int ymax,
    *                        int a, int b, int c1, int c2,
    *                        int nbs, bool *steps, int cx, int cy)
-   * \brief Creates a directional scanner from pattern, center and bounds.
+   * \brief Creates an adaptive DS from pattern, center and bounds.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, upper and lower bounds.
    * @param xmin left border of the scan area
@@ -60,15 +60,15 @@ public:
    * @param cx abscissae of the central scan center
    * @param cy ordinate of the central scan center
    */ 
-  DynamicalScannerO1 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c1, int c2,
-                        int nbs, bool *steps, int cx, int cy);
+  AdaptiveScannerO1 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c1, int c2,
+                     int nbs, bool *steps, int cx, int cy);
 
   /**
-   * @fn DynamicalScanner01(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b,
-   *                        int nbs, bool *steps, int cx, int cy, int length)
-   * \brief Creates a directional scanner from pattern, center and length .
+   * @fn AdaptiveScanner01(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b,
+   *                       int nbs, bool *steps, int cx, int cy, int length)
+   * \brief Creates an adaptive DS from pattern, center and length .
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, and a length value.
    * @param xmin left border of the scan area
@@ -83,10 +83,10 @@ public:
    * @param cy ordinate of the central scan center
    * @param length length of a scan strip
    */
-  DynamicalScannerO1 (int xmin, int ymin, int xmax, int ymax,
-                      int a, int b,
-                      int nbs, bool *steps,
-                      int cx, int cy, int length);
+  AdaptiveScannerO1 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b,
+                     int nbs, bool *steps,
+                     int cx, int cy, int length);
 
   /**
    * @fn first(vector<Pt2i> &scan)
@@ -122,16 +122,16 @@ public:
    */
   void bindTo (int a, int b, int c);
 
+
 protected :
 
-  DynamicalScannerO1 () { }
+  AdaptiveScannerO1 () { }
   
   /** Coefficients of the template discrete support lines */
   int templ_a, templ_b, templ_nu;
 
-  /** Intercept coefficient of the discrete lower support line */
+  /** Shift coefficient of the discrete lower support line */
   int dlc1;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero2.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp
similarity index 92%
rename from Code/Seg/DirectionalScanner/dynamicalscannero2.cpp
rename to Code/FBSD/DirectionalScanner/adaptivescannero2.cpp
index bfb7a6a..839875e 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero2.cpp
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero2.cpp
@@ -1,10 +1,9 @@
 #include <cstdlib>
-#include <iostream>
-#include "dynamicalscannero2.h"
+#include "adaptivescannero2.h"
 
 
 
-DynamicalScannerO2::DynamicalScannerO2 (
+AdaptiveScannerO2::AdaptiveScannerO2 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
@@ -27,7 +26,7 @@ DynamicalScannerO2::DynamicalScannerO2 (
 
 
 
-DynamicalScannerO2::DynamicalScannerO2 (
+AdaptiveScannerO2::AdaptiveScannerO2 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c1, int c2,
                           int nbs, bool *steps, int cx, int cy)
@@ -71,7 +70,7 @@ DynamicalScannerO2::DynamicalScannerO2 (
 
 
 
-DynamicalScannerO2::DynamicalScannerO2 (
+AdaptiveScannerO2::AdaptiveScannerO2 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b,
                           int nbs, bool *steps, int cx, int cy, int length)
@@ -114,7 +113,7 @@ DynamicalScannerO2::DynamicalScannerO2 (
 }
 
 
-int DynamicalScannerO2::first (vector<Pt2i> &scan)
+int AdaptiveScannerO2::first (vector<Pt2i> &scan)
 {
   int x = lcx, y = lcy;      // Current position coordinates
   bool *nst = steps;         // Current step in scan direction (jpts)
@@ -136,7 +135,7 @@ int DynamicalScannerO2::first (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO2::nextOnLeft (vector<Pt2i> &scan)
+int AdaptiveScannerO2::nextOnLeft (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -176,7 +175,7 @@ int DynamicalScannerO2::nextOnLeft (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO2::nextOnRight (vector<Pt2i> &scan)
+int AdaptiveScannerO2::nextOnRight (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -215,7 +214,7 @@ int DynamicalScannerO2::nextOnRight (vector<Pt2i> &scan)
 }
 
 
-void DynamicalScannerO2::bindTo (int a, int b, int c)
+void AdaptiveScannerO2::bindTo (int a, int b, int c)
 {
   if (a < 0)
   {
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero2.h b/Code/FBSD/DirectionalScanner/adaptivescannero2.h
similarity index 67%
rename from Code/Seg/DirectionalScanner/dynamicalscannero2.h
rename to Code/FBSD/DirectionalScanner/adaptivescannero2.h
index e7500c3..d7588bb 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero2.h
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero2.h
@@ -1,5 +1,5 @@
-#ifndef DYNAMICAL_SCANNER_O2_H
-#define DYNAMICAL_SCANNER_O2_H
+#ifndef ADAPTIVE_SCANNER_O2_H
+#define ADAPTIVE_SCANNER_O2_H
 
 #include "directionalscanner.h"
 
@@ -8,20 +8,20 @@ using namespace std;
 
 
 /** 
- * @class DynamicalScannerO2 dynamicalscannero2.h
- * \brief Dynamical directional scanner for the 2nd octant.
- * \author {P. Even and B. Kerautret}
+ * @class AdaptiveScannerO2 adaptivescannero2.h
+ * \brief Adaptive directional scanner for the 2nd octant.
+ * \author {P. Even}
  */
-class DynamicalScannerO2 : public DirectionalScanner
+class AdaptiveScannerO2 : public DirectionalScanner
 {
 
 public:
   
   /**
-   * @fn DynamicalScanner02(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int mu2,
-   *                        int nbs, bool *steps, int sx, int sy)
-   * \brief Creates a directional scanner from pattern, start and upper bound.
+   * @fn AdaptiveScanner02(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int mu2,
+   *                       int nbs, bool *steps, int sx, int sy)
+   * \brief Creates an adaptive DS from pattern, start and upper bound.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a start point, a line pattern, and an upper bound.
    * @param xmin left border of the scan area
@@ -36,15 +36,15 @@ public:
    * @param sx abscissae of the central scan start point
    * @param sy ordinate of the central scan start point
    */
-  DynamicalScannerO2 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c,
-                        int nbs, bool *steps, int sx, int sy);
+  AdaptiveScannerO2 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c,
+                     int nbs, bool *steps, int sx, int sy);
 
   /**
-   * @fn DynamicalScanner02(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int c1, int c2,
-   *                        int nbs, bool *steps, int cx, int cy)
-   * \brief Creates a directional scanner from pattern, center and bounds.
+   * @fn AdaptiveScanner02(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int c1, int c2,
+   *                       int nbs, bool *steps, int cx, int cy)
+   * \brief Creates an adaptive DS from pattern, center and bounds.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, upper and lower bounds.
    * @param xmin left border of the scan area
@@ -60,15 +60,15 @@ public:
    * @param cx abscissae of the central scan center
    * @param cy ordinate of the central scan center
    */
-  DynamicalScannerO2 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c1, int c2,
-                        int nbs, bool *steps, int cx, int cy);
+  AdaptiveScannerO2 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c1, int c2,
+                     int nbs, bool *steps, int cx, int cy);
 
   /**
-   * @fn DynamicalScanner02(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b,
-   *                        int nbs, bool *steps, int cx, int cy, int length)
-   * \brief Creates a directional scanner from pattern, center and length.
+   * @fn AdaptiveScanner02(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b,
+   *                       int nbs, bool *steps, int cx, int cy, int length)
+   * \brief Creates an adaptive DS from pattern, center and length.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, and a length value.
    * @param xmin left border of the scan area
@@ -83,10 +83,10 @@ public:
    * @param cy ordinate of the central scan center
    * @param length length of a scan strip
    */
-  DynamicalScannerO2 (int xmin, int ymin, int xmax, int ymax,
-                      int a, int b,
-                      int nbs, bool *steps,
-                      int cx, int cy, int length);
+  AdaptiveScannerO2 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b,
+                     int nbs, bool *steps,
+                     int cx, int cy, int length);
 
   /**
    * @fn first(vector<Pt2i> &scan)
@@ -122,16 +122,16 @@ public:
    */
   void bindTo (int a, int b, int c);
 
+
 protected :
 
-  DynamicalScannerO2 () { }
+  AdaptiveScannerO2 () { }
 
   /** Coefficients of the template discrete support lines */
   int templ_a, templ_b, templ_nu;
 
-  /** Intercept coefficient of the discrete lower support line */
+  /** Shift coefficient of the discrete lower support line */
   int dlc1;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero7.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp
similarity index 92%
rename from Code/Seg/DirectionalScanner/dynamicalscannero7.cpp
rename to Code/FBSD/DirectionalScanner/adaptivescannero7.cpp
index 5e05a2b..557a1e4 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero7.cpp
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero7.cpp
@@ -1,10 +1,9 @@
 #include <cstdlib>
-#include <iostream>
-#include "dynamicalscannero7.h"
+#include "adaptivescannero7.h"
 
 
 
-DynamicalScannerO7::DynamicalScannerO7 (
+AdaptiveScannerO7::AdaptiveScannerO7 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
@@ -27,7 +26,7 @@ DynamicalScannerO7::DynamicalScannerO7 (
 
 
 
-DynamicalScannerO7::DynamicalScannerO7 (
+AdaptiveScannerO7::AdaptiveScannerO7 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c1, int c2,
                           int nbs, bool *steps, int cx, int cy)
@@ -71,7 +70,7 @@ DynamicalScannerO7::DynamicalScannerO7 (
 
 
 
-DynamicalScannerO7::DynamicalScannerO7 (
+AdaptiveScannerO7::AdaptiveScannerO7 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b,
                           int nbs, bool *steps, int cx, int cy, int length)
@@ -115,7 +114,7 @@ DynamicalScannerO7::DynamicalScannerO7 (
 
 
 
-int DynamicalScannerO7::first (vector<Pt2i> &scan)
+int AdaptiveScannerO7::first (vector<Pt2i> &scan)
 {
   int x = lcx, y = lcy;      // Current position coordinates
   bool *nst = steps;         // Current step in scan direction (jpts)
@@ -137,7 +136,7 @@ int DynamicalScannerO7::first (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO7::nextOnLeft (vector<Pt2i> &scan)
+int AdaptiveScannerO7::nextOnLeft (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -176,7 +175,7 @@ int DynamicalScannerO7::nextOnLeft (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO7::nextOnRight (vector<Pt2i> &scan)
+int AdaptiveScannerO7::nextOnRight (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -216,7 +215,7 @@ int DynamicalScannerO7::nextOnRight (vector<Pt2i> &scan)
 }
 
 
-void DynamicalScannerO7::bindTo (int a, int b, int c)
+void AdaptiveScannerO7::bindTo (int a, int b, int c)
 {
   if (a < 0)
   {
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero8.h b/Code/FBSD/DirectionalScanner/adaptivescannero7.h
similarity index 67%
rename from Code/Seg/DirectionalScanner/dynamicalscannero8.h
rename to Code/FBSD/DirectionalScanner/adaptivescannero7.h
index 5944231..ffb2bfa 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero8.h
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero7.h
@@ -1,5 +1,5 @@
-#ifndef DYNAMICAL_SCANNER_O8_H
-#define DYNAMICAL_SCANNER_O8_H
+#ifndef ADAPTIVE_SCANNER_O7_H
+#define ADAPTIVE_SCANNER_O7_H
 
 #include "directionalscanner.h"
 
@@ -8,20 +8,20 @@ using namespace std;
 
 
 /** 
- * @class DynamicalScannerO8 dynamicalscannero8.h
- * \brief Dynamical directional scanner for the 8th octant.
- * \author {P. Even and B. Kerautret}
+ * @class AdaptiveScannerO7 adaptivescannero7.h
+ * \brief Adaptive directional scanner for the 7th octant.
+ * \author {P. Even}
  */
-class DynamicalScannerO8 : public DirectionalScanner
+class AdaptiveScannerO7 : public DirectionalScanner
 {
 
 public:
   
   /**
-   * @fn DynamicalScanner08(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int mu2,
-   *                        int nbs, bool *steps, int sx, int sy)
-   * \brief Creates a directional scanner from pattern, start and upper bound.
+   * @fn AdaptiveScanner07(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int mu2,
+   *                       int nbs, bool *steps, int sx, int sy)
+   * \brief Creates an adaptive DS from pattern, start and upper bound.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a start point, a line pattern, and an upper bound.
    * @param xmin left border of the scan area
@@ -36,15 +36,15 @@ public:
    * @param sx abscissae of the central scan start point
    * @param sy ordinate of the central scan start point
    */
-  DynamicalScannerO8 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c,
-                        int nbs, bool *steps, int sx, int sy);
+  AdaptiveScannerO7 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c,
+                     int nbs, bool *steps, int sx, int sy);
 
   /**
-   * @fn DynamicalScanner08(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int c1, int c2,
-   *                        int nbs, bool *steps, int cx, int cy)
-   * \brief Creates a directional scanner from pattern, center and bounds.
+   * @fn AdaptiveScanner07(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int c1, int c2,
+   *                       int nbs, bool *steps, int cx, int cy)
+   * \brief Creates an adaptive DS from pattern, center and bounds.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, upper and lower bounds.
    * @param xmin left border of the scan area
@@ -60,15 +60,15 @@ public:
    * @param cx abscissae of the central scan center
    * @param cy ordinate of the central scan center
    */
-  DynamicalScannerO8 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c1, int c2,
-                        int nbs, bool *steps, int cx, int cy);
+  AdaptiveScannerO7 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c1, int c2,
+                     int nbs, bool *steps, int cx, int cy);
 
   /**
-   * @fn DynamicalScanner08(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b,
-   *                        int nbs, bool *steps, int cx, int cy, int length)
-   * \brief Creates a directional scanner from pattern, center and length.
+   * @fn AdaptiveScanner07(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b,
+   *                       int nbs, bool *steps, int cx, int cy, int length)
+   * \brief Creates an adaptive DS from pattern, center and length.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, and a length value.
    * @param xmin left border of the scan area
@@ -83,10 +83,10 @@ public:
    * @param cy ordinate of the central scan center
    * @param length length of a scan strip
    */
-  DynamicalScannerO8 (int xmin, int ymin, int xmax, int ymax,
-                      int a, int b,
-                      int nbs, bool *steps,
-                      int cx, int cy, int length);
+  AdaptiveScannerO7 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b,
+                     int nbs, bool *steps,
+                     int cx, int cy, int length);
 
   /**
    * @fn first(vector<Pt2i> &scan)
@@ -122,16 +122,16 @@ public:
    */
   void bindTo (int a, int b, int c);
 
+
 protected :
 
-  DynamicalScannerO8 () { }
+  AdaptiveScannerO7 () { }
 
   /** Coefficients of the template discrete support lines */
   int templ_a, templ_b, templ_nu;
 
-  /** Intercept coefficient of the discrete lower support line */
+  /** Shift coefficient of the discrete lower support line */
   int dlc1;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero8.cpp b/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp
similarity index 92%
rename from Code/Seg/DirectionalScanner/dynamicalscannero8.cpp
rename to Code/FBSD/DirectionalScanner/adaptivescannero8.cpp
index b33e4a5..83ec6e6 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero8.cpp
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero8.cpp
@@ -1,10 +1,9 @@
 #include <cstdlib>
-#include <iostream>
-#include "dynamicalscannero8.h"
+#include "adaptivescannero8.h"
 
 
 
-DynamicalScannerO8::DynamicalScannerO8 (
+AdaptiveScannerO8::AdaptiveScannerO8 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
@@ -27,7 +26,7 @@ DynamicalScannerO8::DynamicalScannerO8 (
 
 
 
-DynamicalScannerO8::DynamicalScannerO8 (
+AdaptiveScannerO8::AdaptiveScannerO8 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c1, int c2,
                           int nbs, bool *steps, int cx, int cy)
@@ -71,7 +70,7 @@ DynamicalScannerO8::DynamicalScannerO8 (
 
 
 
-DynamicalScannerO8::DynamicalScannerO8 (
+AdaptiveScannerO8::AdaptiveScannerO8 (
                           int xmin, int ymin, int xmax, int ymax,
                           int a, int b,
                           int nbs, bool *steps, int cx, int cy, int length)
@@ -115,7 +114,7 @@ DynamicalScannerO8::DynamicalScannerO8 (
 
 
 
-int DynamicalScannerO8::first (vector<Pt2i> &scan)
+int AdaptiveScannerO8::first (vector<Pt2i> &scan)
 {
   int x = lcx, y = lcy;      // Current position coordinates
   bool *nst = steps;         // Current step in scan direction (jpts)
@@ -137,7 +136,7 @@ int DynamicalScannerO8::first (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO8::nextOnLeft (vector<Pt2i> &scan)
+int AdaptiveScannerO8::nextOnLeft (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -176,7 +175,7 @@ int DynamicalScannerO8::nextOnLeft (vector<Pt2i> &scan)
 }
 
 
-int DynamicalScannerO8::nextOnRight (vector<Pt2i> &scan)
+int AdaptiveScannerO8::nextOnRight (vector<Pt2i> &scan)
 {
   // Prepares the next scan
   scan.clear ();
@@ -216,7 +215,7 @@ int DynamicalScannerO8::nextOnRight (vector<Pt2i> &scan)
 }
 
 
-void DynamicalScannerO8::bindTo (int a, int b, int c)
+void AdaptiveScannerO8::bindTo (int a, int b, int c)
 {
   if (a < 0)
   {
diff --git a/Code/Seg/DirectionalScanner/dynamicalscannero7.h b/Code/FBSD/DirectionalScanner/adaptivescannero8.h
similarity index 67%
rename from Code/Seg/DirectionalScanner/dynamicalscannero7.h
rename to Code/FBSD/DirectionalScanner/adaptivescannero8.h
index 34174fc..fe057cc 100755
--- a/Code/Seg/DirectionalScanner/dynamicalscannero7.h
+++ b/Code/FBSD/DirectionalScanner/adaptivescannero8.h
@@ -1,5 +1,5 @@
-#ifndef DYNAMICAL_SCANNER_O7_H
-#define DYNAMICAL_SCANNER_O7_H
+#ifndef ADAPTIVE_SCANNER_O8_H
+#define ADAPTIVE_SCANNER_O8_H
 
 #include "directionalscanner.h"
 
@@ -8,20 +8,19 @@ using namespace std;
 
 
 /** 
- * @class DynamicalScannerO7 controlablescannero7.h
- * \brief Dynamical directional scanner for the 7th octant.
- * \author {P. Even and B. Kerautret}
+ * @class AdaptiveScannerO8 adaptivescannero8.h
+ * \brief Adaptive directional scanner for the 8th octant.
+ * \author {P. Even}
  */
-class DynamicalScannerO7 : public DirectionalScanner
+class AdaptiveScannerO8 : public DirectionalScanner
 {
-
 public:
   
   /**
-   * @fn DynamicalScanner07(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int mu2,
-   *                        int nbs, bool *steps, int sx, int sy)
-   * \brief Creates a directional scanner from pattern, start and upper bound.
+   * @fn AdaptiveScanner08(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int mu2,
+   *                       int nbs, bool *steps, int sx, int sy)
+   * \brief Creates an adaptive DS from pattern, start and upper bound.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a start point, a line pattern, and an upper bound.
    * @param xmin left border of the scan area
@@ -36,15 +35,15 @@ public:
    * @param sx abscissae of the central scan start point
    * @param sy ordinate of the central scan start point
    */
-  DynamicalScannerO7 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c,
-                        int nbs, bool *steps, int sx, int sy);
+  AdaptiveScannerO8 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c,
+                     int nbs, bool *steps, int sx, int sy);
 
   /**
-   * @fn DynamicalScanner07(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b, int c1, int c2,
-   *                        int nbs, bool *steps, int cx, int cy)
-   * \brief Creates a directional scanner from pattern, center and bounds.
+   * @fn AdaptiveScanner08(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b, int c1, int c2,
+   *                       int nbs, bool *steps, int cx, int cy)
+   * \brief Creates an adaptive DS from pattern, center and bounds.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, upper and lower bounds.
    * @param xmin left border of the scan area
@@ -60,15 +59,15 @@ public:
    * @param cx abscissae of the central scan center
    * @param cy ordinate of the central scan center
    */
-  DynamicalScannerO7 (int xmin, int ymin, int xmax, int ymax,
-                        int a, int b, int c1, int c2,
-                        int nbs, bool *steps, int cx, int cy);
+  AdaptiveScannerO8 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b, int c1, int c2,
+                     int nbs, bool *steps, int cx, int cy);
 
   /**
-   * @fn DynamicalScanner07(int xmin, int ymin, int xmax, int ymax,
-   *                        int a, int b,
-   *                        int nbs, bool *steps, int cx, int cy, int length)
-   * \brief Creates a directional scanner from pattern, center and length.
+   * @fn AdaptiveScanner08(int xmin, int ymin, int xmax, int ymax,
+   *                       int a, int b,
+   *                       int nbs, bool *steps, int cx, int cy, int length)
+   * \brief Creates an adaptive DS from pattern, center and length.
    * The scan strip is composed of parallel scan lines, the first one being
    *   defined by a center, a line pattern, and a length value.
    * @param xmin left border of the scan area
@@ -83,10 +82,10 @@ public:
    * @param cy ordinate of the central scan center
    * @param length length of a scan strip
    */
-  DynamicalScannerO7 (int xmin, int ymin, int xmax, int ymax,
-                      int a, int b,
-                      int nbs, bool *steps,
-                      int cx, int cy, int length);
+  AdaptiveScannerO8 (int xmin, int ymin, int xmax, int ymax,
+                     int a, int b,
+                     int nbs, bool *steps,
+                     int cx, int cy, int length);
 
   /**
    * @fn first(vector<Pt2i> &scan)
@@ -122,16 +121,16 @@ public:
    */
   void bindTo (int a, int b, int c);
 
+
 protected :
 
-  DynamicalScannerO7 () { }
+  AdaptiveScannerO8 () { }
 
   /** Coefficients of the template discrete support lines */
   int templ_a, templ_b, templ_nu;
 
-  /** Intercept coefficient of the discrete lower support line */
+  /** Shift coefficient of the discrete lower support line */
   int dlc1;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/directionalscanner.cpp b/Code/FBSD/DirectionalScanner/directionalscanner.cpp
similarity index 100%
rename from Code/Seg/DirectionalScanner/directionalscanner.cpp
rename to Code/FBSD/DirectionalScanner/directionalscanner.cpp
diff --git a/Code/Seg/DirectionalScanner/directionalscanner.h b/Code/FBSD/DirectionalScanner/directionalscanner.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscanner.h
rename to Code/FBSD/DirectionalScanner/directionalscanner.h
index 40287ce..38595af 100755
--- a/Code/Seg/DirectionalScanner/directionalscanner.h
+++ b/Code/FBSD/DirectionalScanner/directionalscanner.h
@@ -17,7 +17,6 @@ using namespace std;
  */
 class DirectionalScanner
 {
-
 public:
   
   /**
@@ -112,7 +111,6 @@ protected:
              : xmin (xmini), ymin (ymini), xmax (xmaxi), ymax (ymaxi),
                nbs (nb), steps (st),
                ccx (sx), ccy (sy), lcx (sx), lcy (sy), rcx (sx), rcy (sy) { }
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/directionalscannero1.cpp b/Code/FBSD/DirectionalScanner/directionalscannero1.cpp
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero1.cpp
rename to Code/FBSD/DirectionalScanner/directionalscannero1.cpp
index 5f61fde..56cea0c 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero1.cpp
+++ b/Code/FBSD/DirectionalScanner/directionalscannero1.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "directionalscannero1.h"
 
 
diff --git a/Code/Seg/DirectionalScanner/directionalscannero1.h b/Code/FBSD/DirectionalScanner/directionalscannero1.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero1.h
rename to Code/FBSD/DirectionalScanner/directionalscannero1.h
index 05f9e13..e30df67 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero1.h
+++ b/Code/FBSD/DirectionalScanner/directionalscannero1.h
@@ -14,7 +14,6 @@ using namespace std;
  */
 class DirectionalScannerO1 : public DirectionalScanner
 {
-
 public:
   
   /**
@@ -120,6 +119,7 @@ public:
    */
   virtual Pt2i locate (const Pt2i &pt) const;
 
+
 private:
 
   /** Current step in strip direction */
@@ -127,7 +127,6 @@ private:
 
   /** State of the scan */
   bool ltransition, rtransition;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/directionalscannero2.cpp b/Code/FBSD/DirectionalScanner/directionalscannero2.cpp
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero2.cpp
rename to Code/FBSD/DirectionalScanner/directionalscannero2.cpp
index dbf43d8..7fe62fc 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero2.cpp
+++ b/Code/FBSD/DirectionalScanner/directionalscannero2.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "directionalscannero2.h"
 
 
diff --git a/Code/Seg/DirectionalScanner/directionalscannero2.h b/Code/FBSD/DirectionalScanner/directionalscannero2.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero2.h
rename to Code/FBSD/DirectionalScanner/directionalscannero2.h
index 6ac98a4..0c7948a 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero2.h
+++ b/Code/FBSD/DirectionalScanner/directionalscannero2.h
@@ -14,7 +14,6 @@ using namespace std;
  */
 class DirectionalScannerO2 : public DirectionalScanner
 {
-
 public:
   
   /**
@@ -120,6 +119,7 @@ public:
    */
   virtual Pt2i locate (const Pt2i &pt) const;
 
+
 private:
 
   /** Current step in strip direction */
@@ -127,7 +127,6 @@ private:
 
   /** State of the scan */
   bool ltransition, rtransition;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/directionalscannero7.cpp b/Code/FBSD/DirectionalScanner/directionalscannero7.cpp
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero7.cpp
rename to Code/FBSD/DirectionalScanner/directionalscannero7.cpp
index bf6ead5..c2c40de 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero7.cpp
+++ b/Code/FBSD/DirectionalScanner/directionalscannero7.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "directionalscannero7.h"
 
 
diff --git a/Code/Seg/DirectionalScanner/directionalscannero7.h b/Code/FBSD/DirectionalScanner/directionalscannero7.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero7.h
rename to Code/FBSD/DirectionalScanner/directionalscannero7.h
index 07f4948..fb3f7ae 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero7.h
+++ b/Code/FBSD/DirectionalScanner/directionalscannero7.h
@@ -14,7 +14,6 @@ using namespace std;
  */
 class DirectionalScannerO7 : public DirectionalScanner
 {
-
 public:
   
   /**
@@ -120,6 +119,7 @@ public:
    */
   virtual Pt2i locate (const Pt2i &pt) const;
 
+
 private:
 
   /** Current step in strip direction */
@@ -127,7 +127,6 @@ private:
 
   /** State of the scan */
   bool ltransition, rtransition;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/directionalscannero8.cpp b/Code/FBSD/DirectionalScanner/directionalscannero8.cpp
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero8.cpp
rename to Code/FBSD/DirectionalScanner/directionalscannero8.cpp
index 83cdc92..123b84a 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero8.cpp
+++ b/Code/FBSD/DirectionalScanner/directionalscannero8.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "directionalscannero8.h"
 
 
diff --git a/Code/Seg/DirectionalScanner/directionalscannero8.h b/Code/FBSD/DirectionalScanner/directionalscannero8.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/directionalscannero8.h
rename to Code/FBSD/DirectionalScanner/directionalscannero8.h
index a844476..b5e5486 100755
--- a/Code/Seg/DirectionalScanner/directionalscannero8.h
+++ b/Code/FBSD/DirectionalScanner/directionalscannero8.h
@@ -14,7 +14,6 @@ using namespace std;
  */
 class DirectionalScannerO8 : public DirectionalScanner
 {
-
 public:
   
   /**
@@ -120,6 +119,7 @@ public:
    */
   virtual Pt2i locate (const Pt2i &pt) const;
 
+
 private:
 
   /** Current step in strip direction */
@@ -127,7 +127,6 @@ private:
 
   /** State of the scan */
   bool ltransition, rtransition;
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/scannerprovider.cpp b/Code/FBSD/DirectionalScanner/scannerprovider.cpp
similarity index 91%
rename from Code/Seg/DirectionalScanner/scannerprovider.cpp
rename to Code/FBSD/DirectionalScanner/scannerprovider.cpp
index 163f507..dd6f8a0 100755
--- a/Code/Seg/DirectionalScanner/scannerprovider.cpp
+++ b/Code/FBSD/DirectionalScanner/scannerprovider.cpp
@@ -203,9 +203,9 @@ DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
                                 a, b, nbs, steps,
                                 centre.x (), centre.y (), length) :
                (DirectionalScanner *)
-               new DynamicalScannerO1 (xmin, ymin, xmax, ymax,
-                                       a, b, nbs, steps,
-                                       centre.x (), centre.y (), length)) :
+               new AdaptiveScannerO1 (xmin, ymin, xmax, ymax,
+                                      a, b, nbs, steps,
+                                      centre.x (), centre.y (), length)) :
               (DirectionalScanner *)
               new DirectionalScannerO1 (xmin, ymin, xmax, ymax,
                                         a, b, nbs, steps,
@@ -218,9 +218,9 @@ DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
                                 a, b, nbs, steps,
                                 centre.x (), centre.y (), length) :
                (DirectionalScanner *)
-               new DynamicalScannerO2 (xmin, ymin, xmax, ymax,
-                                       a, b, nbs, steps,
-                                       centre.x (), centre.y (), length)) :
+               new AdaptiveScannerO2 (xmin, ymin, xmax, ymax,
+                                      a, b, nbs, steps,
+                                      centre.x (), centre.y (), length)) :
               (DirectionalScanner *)
               new DirectionalScannerO2 (xmin, ymin, xmax, ymax,
                                         a, b, nbs, steps,
@@ -234,9 +234,9 @@ DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
                                 a, b, nbs, steps,
                                 centre.x (), centre.y (), length) :
                (DirectionalScanner *)
-               new DynamicalScannerO8 (xmin, ymin, xmax, ymax,
-                                       a, b, nbs, steps,
-                                       centre.x (), centre.y (), length)) :
+               new AdaptiveScannerO8 (xmin, ymin, xmax, ymax,
+                                      a, b, nbs, steps,
+                                      centre.x (), centre.y (), length)) :
               (DirectionalScanner *)
               new DirectionalScannerO8 (xmin, ymin, xmax, ymax,
                                         a, b, nbs, steps,
@@ -249,9 +249,9 @@ DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
                                 a, b, nbs, steps,
                                 centre.x (), centre.y (), length) :
                (DirectionalScanner *)
-               new DynamicalScannerO7 (xmin, ymin, xmax, ymax,
-                                       a, b, nbs, steps,
-                                       centre.x (), centre.y (), length)) :
+               new AdaptiveScannerO7 (xmin, ymin, xmax, ymax,
+                                      a, b, nbs, steps,
+                                      centre.x (), centre.y (), length)) :
               (DirectionalScanner *)
               new DirectionalScannerO7 (xmin, ymin, xmax, ymax,
                                         a, b, nbs, steps,
diff --git a/Code/Seg/DirectionalScanner/scannerprovider.h b/Code/FBSD/DirectionalScanner/scannerprovider.h
similarity index 99%
rename from Code/Seg/DirectionalScanner/scannerprovider.h
rename to Code/FBSD/DirectionalScanner/scannerprovider.h
index b184d52..ebafab9 100755
--- a/Code/Seg/DirectionalScanner/scannerprovider.h
+++ b/Code/FBSD/DirectionalScanner/scannerprovider.h
@@ -13,10 +13,10 @@ using namespace std;
  * \brief Directional scanner provider.
  * Provides ad-hoc directional scanners in the relevant octant
  *   and according to static or dynamical needs.
+ * \author {P. Even}
  */
 class ScannerProvider
 {
-
 public:
 
   /**
diff --git a/Code/Seg/DirectionalScanner/vhscannero1.cpp b/Code/FBSD/DirectionalScanner/vhscannero1.cpp
similarity index 95%
rename from Code/Seg/DirectionalScanner/vhscannero1.cpp
rename to Code/FBSD/DirectionalScanner/vhscannero1.cpp
index 0de21e9..c03abfd 100755
--- a/Code/Seg/DirectionalScanner/vhscannero1.cpp
+++ b/Code/FBSD/DirectionalScanner/vhscannero1.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "vhscannero1.h"
 
 
@@ -7,8 +6,8 @@
 VHScannerO1::VHScannerO1 (int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
-                    : DynamicalScannerO1 (xmin, ymin, xmax, ymax,
-                                          a, b, c, nbs, steps, sx, sy)
+                    : AdaptiveScannerO1 (xmin, ymin, xmax, ymax,
+                                         a, b, c, nbs, steps, sx, sy)
 {
 }
 
diff --git a/Code/Seg/DirectionalScanner/vhscannero1.h b/Code/FBSD/DirectionalScanner/vhscannero1.h
similarity index 96%
rename from Code/Seg/DirectionalScanner/vhscannero1.h
rename to Code/FBSD/DirectionalScanner/vhscannero1.h
index 9644a24..e2aac24 100755
--- a/Code/Seg/DirectionalScanner/vhscannero1.h
+++ b/Code/FBSD/DirectionalScanner/vhscannero1.h
@@ -1,7 +1,7 @@
 #ifndef VH_SCANNER_O1_H
 #define VH_SCANNER_O1_H
 
-#include "dynamicalscannero1.h"
+#include "adaptivescannero1.h"
 
 using namespace std;
 
@@ -9,12 +9,11 @@ using namespace std;
 
 /** 
  * @class VHScannerO1 vhscannero1.h
- * \brief Vertical/horizontal directional scanner for the 1st octant.
+ * \brief Vertical/horizontal adaptive DS for the 1st octant.
  * \author {P. Even}
  */
-class VHScannerO1 : public DynamicalScannerO1
+class VHScannerO1 : public AdaptiveScannerO1
 {
-
 public:
   
   /**
@@ -110,7 +109,6 @@ public:
    * @param scan vectors of points to be filled in.
    */
   int nextOnRight (vector<Pt2i> &scan);
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/vhscannero2.cpp b/Code/FBSD/DirectionalScanner/vhscannero2.cpp
similarity index 95%
rename from Code/Seg/DirectionalScanner/vhscannero2.cpp
rename to Code/FBSD/DirectionalScanner/vhscannero2.cpp
index 59eccb1..4188497 100755
--- a/Code/Seg/DirectionalScanner/vhscannero2.cpp
+++ b/Code/FBSD/DirectionalScanner/vhscannero2.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "vhscannero2.h"
 
 
@@ -7,8 +6,8 @@
 VHScannerO2::VHScannerO2 (int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
-                    : DynamicalScannerO2 (xmin, ymin, xmax, ymax,
-                                          a, b, c, nbs, steps, sx, sy)
+                    : AdaptiveScannerO2 (xmin, ymin, xmax, ymax,
+                                         a, b, c, nbs, steps, sx, sy)
 {
 }
 
diff --git a/Code/Seg/DirectionalScanner/vhscannero2.h b/Code/FBSD/DirectionalScanner/vhscannero2.h
similarity index 95%
rename from Code/Seg/DirectionalScanner/vhscannero2.h
rename to Code/FBSD/DirectionalScanner/vhscannero2.h
index b0a8e8a..2457c39 100755
--- a/Code/Seg/DirectionalScanner/vhscannero2.h
+++ b/Code/FBSD/DirectionalScanner/vhscannero2.h
@@ -1,20 +1,19 @@
 #ifndef VH_SCANNER_O2_H
 #define VH_SCANNER_O2_H
 
-#include "dynamicalscannero2.h"
+#include "adaptivescannero2.h"
 
 using namespace std;
 
 
 
 /** 
- * @class VHScannerO2 dynamicalscannero2.h
- * \brief Vertical / horizontal directional scanner for the 2nd octant.
+ * @class VHScannerO2 vhscannero2.h
+ * \brief Vertical / horizontal adpative DS for the 2nd octant.
  * \author {P. Even}
  */
-class VHScannerO2 : public DynamicalScannerO2
+class VHScannerO2 : public AdaptiveScannerO2
 {
-
 public:
   
   /**
@@ -110,7 +109,6 @@ public:
    * @param scan vectors of points to be filled in.
    */
   int nextOnRight (vector<Pt2i> &scan);
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/vhscannero7.cpp b/Code/FBSD/DirectionalScanner/vhscannero7.cpp
similarity index 95%
rename from Code/Seg/DirectionalScanner/vhscannero7.cpp
rename to Code/FBSD/DirectionalScanner/vhscannero7.cpp
index f46b883..119b714 100755
--- a/Code/Seg/DirectionalScanner/vhscannero7.cpp
+++ b/Code/FBSD/DirectionalScanner/vhscannero7.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "vhscannero7.h"
 
 
@@ -7,8 +6,8 @@
 VHScannerO7::VHScannerO7 (int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
-                    : DynamicalScannerO7 (xmin, ymin, xmax, ymax,
-                                          a, b, c, nbs, steps, sx, sy)
+                    : AdaptiveScannerO7 (xmin, ymin, xmax, ymax,
+                                         a, b, c, nbs, steps, sx, sy)
 {
 }
 
diff --git a/Code/Seg/DirectionalScanner/vhscannero7.h b/Code/FBSD/DirectionalScanner/vhscannero7.h
similarity index 96%
rename from Code/Seg/DirectionalScanner/vhscannero7.h
rename to Code/FBSD/DirectionalScanner/vhscannero7.h
index 5ad1e12..62c4445 100755
--- a/Code/Seg/DirectionalScanner/vhscannero7.h
+++ b/Code/FBSD/DirectionalScanner/vhscannero7.h
@@ -1,7 +1,7 @@
 #ifndef VH_SCANNER_O7_H
 #define VH_SCANNER_O7_H
 
-#include "dynamicalscannero7.h"
+#include "adaptivescannero7.h"
 
 using namespace std;
 
@@ -9,12 +9,11 @@ using namespace std;
 
 /** 
  * @class VHScannerO7 vhscannero7.h
- * \brief Vertical / horizontal directional scanner for the 7th octant.
+ * \brief Vertical / horizontal adaptive DS for the 7th octant.
  * \author {P. Even}
  */
-class VHScannerO7 : public DynamicalScannerO7
+class VHScannerO7 : public AdaptiveScannerO7
 {
-
 public:
   
   /**
@@ -110,7 +109,6 @@ public:
    * @param scan vectors of points to be filled in.
    */
   int nextOnRight (vector<Pt2i> &scan);
-
 };
 
 #endif
diff --git a/Code/Seg/DirectionalScanner/vhscannero8.cpp b/Code/FBSD/DirectionalScanner/vhscannero8.cpp
similarity index 95%
rename from Code/Seg/DirectionalScanner/vhscannero8.cpp
rename to Code/FBSD/DirectionalScanner/vhscannero8.cpp
index f6b8c61..7efb53d 100755
--- a/Code/Seg/DirectionalScanner/vhscannero8.cpp
+++ b/Code/FBSD/DirectionalScanner/vhscannero8.cpp
@@ -1,5 +1,4 @@
 #include <cstdlib>
-#include <iostream>
 #include "vhscannero8.h"
 
 
@@ -7,8 +6,8 @@
 VHScannerO8::VHScannerO8 (int xmin, int ymin, int xmax, int ymax,
                           int a, int b, int c,
                           int nbs, bool *steps, int sx, int sy)
-                    : DynamicalScannerO8 (xmin, ymin, xmax, ymax,
-                                          a, b, c, nbs, steps, sx, sy)
+                    : AdaptiveScannerO8 (xmin, ymin, xmax, ymax,
+                                         a, b, c, nbs, steps, sx, sy)
 {
 }
 
diff --git a/Code/Seg/DirectionalScanner/vhscannero8.h b/Code/FBSD/DirectionalScanner/vhscannero8.h
similarity index 96%
rename from Code/Seg/DirectionalScanner/vhscannero8.h
rename to Code/FBSD/DirectionalScanner/vhscannero8.h
index e05ba49..72fcc24 100755
--- a/Code/Seg/DirectionalScanner/vhscannero8.h
+++ b/Code/FBSD/DirectionalScanner/vhscannero8.h
@@ -1,7 +1,7 @@
 #ifndef VH_SCANNER_O8_H
 #define VH_SCANNER_O8_H
 
-#include "dynamicalscannero8.h"
+#include "adaptivescannero8.h"
 
 using namespace std;
 
@@ -9,12 +9,11 @@ using namespace std;
 
 /** 
  * @class VHScannerO8 vhscannero8.h
- * \brief Vertical / horizontal directional scanner for the 8th octant.
+ * \brief Vertical / horizontal adaptive DS for the 8th octant.
  * \author {P. Even}
  */
-class VHScannerO8 : public DynamicalScannerO8
+class VHScannerO8 : public AdaptiveScannerO8
 {
-
 public:
   
   /**
@@ -110,7 +109,6 @@ public:
    * @param scan vectors of points to be filled in.
    */
   int nextOnRight (vector<Pt2i> &scan);
-
 };
 
 #endif
diff --git a/Code/Seg/Seg.pro b/Code/FBSD/FBSD.pro
similarity index 86%
rename from Code/Seg/Seg.pro
rename to Code/FBSD/FBSD.pro
index 1a3b565..635c56e 100644
--- a/Code/Seg/Seg.pro
+++ b/Code/FBSD/FBSD.pro
@@ -4,7 +4,7 @@
 
 QT+=widgets
 TEMPLATE = app
-TARGET = Seg
+TARGET = FBSD
 INCLUDEPATH += . \
            BSTools \
            BlurredSegment \
@@ -25,21 +25,22 @@ HEADERS += BlurredSegment/biptlist.h \
            BSTools/bsidetview.h \
            BSTools/bsprofileitem.h \
            BSTools/bsprofileview.h \
+           BSTools/bsrandomtester.h \
            BSTools/bsstructureitem.h \
            BSTools/bsstructureview.h \
            BSTools/bswindow.h \
            ConvexHull/antipodal.h \
            ConvexHull/chvertex.h \
            ConvexHull/convexhull.h \
+           DirectionalScanner/adaptivescannero1.h \
+           DirectionalScanner/adaptivescannero2.h \
+           DirectionalScanner/adaptivescannero7.h \
+           DirectionalScanner/adaptivescannero8.h \
            DirectionalScanner/directionalscanner.h \
            DirectionalScanner/directionalscannero1.h \
            DirectionalScanner/directionalscannero2.h \
            DirectionalScanner/directionalscannero7.h \
            DirectionalScanner/directionalscannero8.h \
-           DirectionalScanner/dynamicalscannero1.h \
-           DirectionalScanner/dynamicalscannero2.h \
-           DirectionalScanner/dynamicalscannero7.h \
-           DirectionalScanner/dynamicalscannero8.h \
            DirectionalScanner/scannerprovider.h \
            DirectionalScanner/vhscannero1.h \
            DirectionalScanner/vhscannero2.h \
@@ -64,21 +65,22 @@ SOURCES += main.cpp \
            BSTools/bsidetview.cpp \
            BSTools/bsprofileitem.cpp \
            BSTools/bsprofileview.cpp \
+           BSTools/bsrandomtester.cpp \
            BSTools/bsstructureitem.cpp \
            BSTools/bsstructureview.cpp \
            BSTools/bswindow.cpp \
            ConvexHull/antipodal.cpp \
            ConvexHull/chvertex.cpp \
            ConvexHull/convexhull.cpp \
+           DirectionalScanner/adaptivescannero1.cpp \
+           DirectionalScanner/adaptivescannero2.cpp \
+           DirectionalScanner/adaptivescannero7.cpp \
+           DirectionalScanner/adaptivescannero8.cpp \
            DirectionalScanner/directionalscanner.cpp \
            DirectionalScanner/directionalscannero1.cpp \
            DirectionalScanner/directionalscannero2.cpp \
            DirectionalScanner/directionalscannero7.cpp \
            DirectionalScanner/directionalscannero8.cpp \
-           DirectionalScanner/dynamicalscannero1.cpp \
-           DirectionalScanner/dynamicalscannero2.cpp \
-           DirectionalScanner/dynamicalscannero7.cpp \
-           DirectionalScanner/dynamicalscannero8.cpp \
            DirectionalScanner/scannerprovider.cpp \
            DirectionalScanner/vhscannero1.cpp \
            DirectionalScanner/vhscannero2.cpp \
diff --git a/Code/Seg/IPOLdemo/IPOLdemo.pro b/Code/FBSD/IPOLdemo/IPOLdemo.pro
similarity index 89%
rename from Code/Seg/IPOLdemo/IPOLdemo.pro
rename to Code/FBSD/IPOLdemo/IPOLdemo.pro
index f06581c..f2e7bda 100644
--- a/Code/Seg/IPOLdemo/IPOLdemo.pro
+++ b/Code/FBSD/IPOLdemo/IPOLdemo.pro
@@ -39,10 +39,10 @@ HEADERS += ../BlurredSegment/biptlist.h \
            ../DirectionalScanner/directionalscannero2.h \
            ../DirectionalScanner/directionalscannero7.h \
            ../DirectionalScanner/directionalscannero8.h \
-           ../DirectionalScanner/dynamicalscannero1.h \
-           ../DirectionalScanner/dynamicalscannero2.h \
-           ../DirectionalScanner/dynamicalscannero7.h \
-           ../DirectionalScanner/dynamicalscannero8.h \
+           ../DirectionalScanner/adaptivescannero1.h \
+           ../DirectionalScanner/adaptivescannero2.h \
+           ../DirectionalScanner/adaptivescannero7.h \
+           ../DirectionalScanner/adaptivescannero8.h \
            ../DirectionalScanner/scannerprovider.h \
            ../DirectionalScanner/vhscannero1.h \
            ../DirectionalScanner/vhscannero2.h \
@@ -80,10 +80,10 @@ SOURCES += mainIPOL.cpp \
            ../DirectionalScanner/directionalscannero2.cpp \
            ../DirectionalScanner/directionalscannero7.cpp \
            ../DirectionalScanner/directionalscannero8.cpp \
-           ../DirectionalScanner/dynamicalscannero1.cpp \
-           ../DirectionalScanner/dynamicalscannero2.cpp \
-           ../DirectionalScanner/dynamicalscannero7.cpp \
-           ../DirectionalScanner/dynamicalscannero8.cpp \
+           ../DirectionalScanner/adaptivescannero1.cpp \
+           ../DirectionalScanner/adaptivescannero2.cpp \
+           ../DirectionalScanner/adaptivescannero7.cpp \
+           ../DirectionalScanner/adaptivescannero8.cpp \
            ../DirectionalScanner/scannerprovider.cpp \
            ../DirectionalScanner/vhscannero1.cpp \
            ../DirectionalScanner/vhscannero2.cpp \
diff --git a/Code/Seg/IPOLdemo/Input/couloir.gif b/Code/FBSD/IPOLdemo/Input/couloir.gif
similarity index 100%
rename from Code/Seg/IPOLdemo/Input/couloir.gif
rename to Code/FBSD/IPOLdemo/Input/couloir.gif
diff --git a/Code/Seg/IPOLdemo/Input/points.txt b/Code/FBSD/IPOLdemo/Input/points.txt
similarity index 100%
rename from Code/Seg/IPOLdemo/Input/points.txt
rename to Code/FBSD/IPOLdemo/Input/points.txt
diff --git a/Code/Seg/IPOLdemo/Scripts/convert.sh b/Code/FBSD/IPOLdemo/Scripts/convert.sh
similarity index 100%
rename from Code/Seg/IPOLdemo/Scripts/convert.sh
rename to Code/FBSD/IPOLdemo/Scripts/convert.sh
diff --git a/Code/Seg/IPOLdemo/Scripts/displaySegments.sh b/Code/FBSD/IPOLdemo/Scripts/displaySegments.sh
similarity index 100%
rename from Code/Seg/IPOLdemo/Scripts/displaySegments.sh
rename to Code/FBSD/IPOLdemo/Scripts/displaySegments.sh
diff --git a/Code/Seg/IPOLdemo/Scripts/displaySegmentsInteract.sh b/Code/FBSD/IPOLdemo/Scripts/displaySegmentsInteract.sh
similarity index 100%
rename from Code/Seg/IPOLdemo/Scripts/displaySegmentsInteract.sh
rename to Code/FBSD/IPOLdemo/Scripts/displaySegmentsInteract.sh
diff --git a/Code/Seg/IPOLdemo/mainIPOL.cpp b/Code/FBSD/IPOLdemo/mainIPOL.cpp
similarity index 99%
rename from Code/Seg/IPOLdemo/mainIPOL.cpp
rename to Code/FBSD/IPOLdemo/mainIPOL.cpp
index 8e7c2d8..c34e1e7 100755
--- a/Code/Seg/IPOLdemo/mainIPOL.cpp
+++ b/Code/FBSD/IPOLdemo/mainIPOL.cpp
@@ -173,7 +173,6 @@ int main (int argc, char *argv[])
   }
   else
   {
-    detector.setMaxTrials (-1);
     detector.detectAll ();
     bss = detector.getBlurredSegments ();
   }
diff --git a/Code/Seg/ImageTools/absrat.cpp b/Code/FBSD/ImageTools/absrat.cpp
similarity index 100%
rename from Code/Seg/ImageTools/absrat.cpp
rename to Code/FBSD/ImageTools/absrat.cpp
diff --git a/Code/Seg/ImageTools/absrat.h b/Code/FBSD/ImageTools/absrat.h
similarity index 99%
rename from Code/Seg/ImageTools/absrat.h
rename to Code/FBSD/ImageTools/absrat.h
index 84e2eee..d2b3cfb 100755
--- a/Code/Seg/ImageTools/absrat.h
+++ b/Code/FBSD/ImageTools/absrat.h
@@ -17,7 +17,6 @@ using namespace std;
  */
 class AbsRat
 {
-
 public:
 
   /**
@@ -177,7 +176,6 @@ protected:
   int num;
   /** Positive denominator of the rational number (might be null). */
   int den;
-
 };
 
 #endif
diff --git a/Code/Seg/ImageTools/digitalstraightline.cpp b/Code/FBSD/ImageTools/digitalstraightline.cpp
similarity index 100%
rename from Code/Seg/ImageTools/digitalstraightline.cpp
rename to Code/FBSD/ImageTools/digitalstraightline.cpp
diff --git a/Code/Seg/ImageTools/digitalstraightline.h b/Code/FBSD/ImageTools/digitalstraightline.h
similarity index 99%
rename from Code/Seg/ImageTools/digitalstraightline.h
rename to Code/FBSD/ImageTools/digitalstraightline.h
index 4b241be..64b4abf 100755
--- a/Code/Seg/ImageTools/digitalstraightline.h
+++ b/Code/FBSD/ImageTools/digitalstraightline.h
@@ -17,7 +17,6 @@ using namespace std;
  */
 class DigitalStraightLine
 {
-
 public:
 
   /** Digital line type : Thin line (width = 1). */
@@ -249,6 +248,5 @@ protected:
    * @param b Second integer.
    */
   static int pgcd (int a, int b);
-
 };
 #endif
diff --git a/Code/Seg/ImageTools/digitalstraightsegment.cpp b/Code/FBSD/ImageTools/digitalstraightsegment.cpp
similarity index 100%
rename from Code/Seg/ImageTools/digitalstraightsegment.cpp
rename to Code/FBSD/ImageTools/digitalstraightsegment.cpp
diff --git a/Code/Seg/ImageTools/digitalstraightsegment.h b/Code/FBSD/ImageTools/digitalstraightsegment.h
similarity index 99%
rename from Code/Seg/ImageTools/digitalstraightsegment.h
rename to Code/FBSD/ImageTools/digitalstraightsegment.h
index 664f67e..38c612e 100755
--- a/Code/Seg/ImageTools/digitalstraightsegment.h
+++ b/Code/FBSD/ImageTools/digitalstraightsegment.h
@@ -112,6 +112,5 @@ protected:
    * @param height Height of the area.
    */
   void adjustWorkArea (int &xmin, int &ymin, int &width, int &height) const;
-
 };
 #endif
diff --git a/Code/Seg/ImageTools/pt2i.cpp b/Code/FBSD/ImageTools/pt2i.cpp
similarity index 100%
rename from Code/Seg/ImageTools/pt2i.cpp
rename to Code/FBSD/ImageTools/pt2i.cpp
diff --git a/Code/Seg/ImageTools/pt2i.h b/Code/FBSD/ImageTools/pt2i.h
similarity index 99%
rename from Code/Seg/ImageTools/pt2i.h
rename to Code/FBSD/ImageTools/pt2i.h
index 369e46e..466e45f 100755
--- a/Code/Seg/ImageTools/pt2i.h
+++ b/Code/FBSD/ImageTools/pt2i.h
@@ -16,7 +16,6 @@ using namespace std;
  */
 class Pt2i
 {
-
 public:
 
   /**
@@ -253,7 +252,6 @@ protected:
   int xp;
   /** Point ordinate. */
   int yp;
-
 };
 
 #endif
diff --git a/Code/Seg/ImageTools/strucel.cpp b/Code/FBSD/ImageTools/strucel.cpp
similarity index 100%
rename from Code/Seg/ImageTools/strucel.cpp
rename to Code/FBSD/ImageTools/strucel.cpp
diff --git a/Code/Seg/ImageTools/strucel.h b/Code/FBSD/ImageTools/strucel.h
similarity index 98%
rename from Code/Seg/ImageTools/strucel.h
rename to Code/FBSD/ImageTools/strucel.h
index 9b90927..00844a5 100755
--- a/Code/Seg/ImageTools/strucel.h
+++ b/Code/FBSD/ImageTools/strucel.h
@@ -9,10 +9,10 @@ using namespace std;
 /** 
  * @class Strucel strucel.h
  * \brief Structuring element for morphological operations.
+ * \author {P. Even and P. Ngo}
  */
 class Strucel
 {
-
 public:
 
   /** 3x3 cross structuring element type. */
@@ -116,7 +116,6 @@ private:
   int size;
   /** Pattern of the structuring element as the list of occupied pixels. */
   Vr2i *pattern;
-
 };
 
 #endif
diff --git a/Code/Seg/ImageTools/vmap.cpp b/Code/FBSD/ImageTools/vmap.cpp
similarity index 100%
rename from Code/Seg/ImageTools/vmap.cpp
rename to Code/FBSD/ImageTools/vmap.cpp
diff --git a/Code/Seg/ImageTools/vmap.h b/Code/FBSD/ImageTools/vmap.h
similarity index 99%
rename from Code/Seg/ImageTools/vmap.h
rename to Code/FBSD/ImageTools/vmap.h
index 54236e2..34f7080 100755
--- a/Code/Seg/ImageTools/vmap.h
+++ b/Code/FBSD/ImageTools/vmap.h
@@ -10,11 +10,10 @@ using namespace std;
 /** 
  * @class VMap vmap.h
  * \brief Vector map.
- * \author {P. Even}
+ * \author {P. Even and P. Ngo}
  */
 class VMap
 {
-
 public:
 
   /** Gradient extraction method : Sobel with 3x3 kernel. */
@@ -379,7 +378,6 @@ private:
    * @param val Input values.
    */
   void sortMax (int *lmax, int n, int *val) const;
-
 };
 
 #endif
diff --git a/Code/Seg/ImageTools/vr2i.cpp b/Code/FBSD/ImageTools/vr2i.cpp
similarity index 100%
rename from Code/Seg/ImageTools/vr2i.cpp
rename to Code/FBSD/ImageTools/vr2i.cpp
diff --git a/Code/Seg/ImageTools/vr2i.h b/Code/FBSD/ImageTools/vr2i.h
similarity index 99%
rename from Code/Seg/ImageTools/vr2i.h
rename to Code/FBSD/ImageTools/vr2i.h
index a348009..03168d1 100755
--- a/Code/Seg/ImageTools/vr2i.h
+++ b/Code/FBSD/ImageTools/vr2i.h
@@ -6,12 +6,11 @@ using namespace std;
 
 /** 
  * @class Vr2i vr2i.h
- * \brief Vector in the discrete plane.
+ * \brief Vector in the digital plane.
  * \author {P. Even}
  */
 class Vr2i
 {
-
 public:
 
   /**
diff --git a/Code/Seg/main.cpp b/Code/FBSD/main.cpp
similarity index 84%
rename from Code/Seg/main.cpp
rename to Code/FBSD/main.cpp
index befb15a..98c90c2 100755
--- a/Code/Seg/main.cpp
+++ b/Code/FBSD/main.cpp
@@ -1,6 +1,7 @@
 #include <QApplication>
 #include <string>
 #include "bswindow.h"
+#include "bsrandomtester.h"
 // #include "scanwindow.h"
 
 
@@ -64,15 +65,24 @@ int main (int argc, char *argv[])
     }
     else imageName = i;
   }
-  if (random) window.setRandom ();
-  else if (imageName != 0) window.setFile (QString (argv[imageName]));
-  else window.setFile (QString ("../couloir.gif"));
-  if (testing)
+  if (random)
   {
-    window.runTest ();
+    BSRandomTester *tester = new BSRandomTester ();
+    tester->randomTest ();
+    delete tester;
     return (EXIT_SUCCESS);
   }
-  window.runOptions (); 
-  window.show ();
-  return app.exec ();
+  else
+  {
+    if (imageName != 0) window.setFile (QString (argv[imageName]));
+    else window.setFile (QString ("../couloir.gif"));
+    if (testing)
+    {
+      window.runTest ();
+      return (EXIT_SUCCESS);
+    }
+    window.runOptions (); 
+    window.show ();
+    return app.exec ();
+  }
 }
diff --git a/README.md b/README.md
deleted file mode 100644
index a986c54..0000000
--- a/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 2019-ISMM
-
-Paper and code associated to the ISMM paper.
\ No newline at end of file
-- 
GitLab