From d8422a04a3a18fb360bf709f1f0ac7daf0b998b8 Mon Sep 17 00:00:00 2001
From: even <philippe.even@loria.fr>
Date: Wed, 19 Dec 2018 19:02:55 +0100
Subject: [PATCH] Article: supervised mode revisited

---
 Article/method.tex                     | 160 +++++++++++++++----------
 Code/Seg/BlurredSegment/bsdetector.cpp |   4 +-
 Code/Seg/BlurredSegment/bstracker.cpp  |   2 +-
 3 files changed, 98 insertions(+), 68 deletions(-)

diff --git a/Article/method.tex b/Article/method.tex
index 304df28..c58b4b5 100755
--- a/Article/method.tex
+++ b/Article/method.tex
@@ -211,16 +211,57 @@ dragging and the output blurred segment is displayed on-the-fly.
 
 The method is quite sensitive to the local conditions of the initial detection
 so that the output blurred segment may be quite unstable.
-In order to temper this undesirable behavior for particular applications,
+In order to temper this undesirable behavior for interactive applications,
 the initial detection can be optionally run twice, the second fast scan being
 aligned on the first detection output.
 This strategy provides a first quick analysis of the local context before
 extracting the segment and contributes to notably stabilize the overall
 process.
 
+When selecting candidates for the fine detection stage, an option is left
+to also reject points with a gradient vector in an opposite direction to
+the gradient vector of the blurred segment start point.
+In that case, called {\it edge selection mode}, all the blurred segment
+points have the same direction.
+If they are not rejected, points with opposite gradients are aggregated
+into a same blurred segment, allowing the detection of the two opposite
+edges of a thin straight object. This is called {\it line selection mode}.
+This distinction is illustrated on \RefFig{fig:edgeDir}.
+
+\begin{figure}[h]
+\center
+  \begin{tabular}{c@{\hspace{0.2cm}}c}
+    \includegraphics[width=0.48\textwidth]{Fig_method/multiStroke_zoom.png} &
+    \includegraphics[width=0.48\textwidth]{Fig_method/multiEdge_zoom.png}
+  \end{tabular}
+  \begin{picture}(1,1)(0,0)
+    {\color{dwhite}{
+      \put(-260,-17.5){\circle*{8}}
+      \put(-86,-17.5){\circle*{8}}
+    }}
+    \put(-262.5,-20){a}
+    \put(-89,-20){b}
+  \end{picture}
+  \caption{Blurred segment obtained in line selection mode (a) and in
+           edge selection mode (b) as a result of the test of the gradient
+           direction of added points.
+           In line selection mode, a thick blurred segment is built and
+           extended up to four tiles.
+           In edge selection mode, a thin blurred segment is built along
+           one of the two tile join edges.
+           Both join edges, drawn with distinct colors, are detected with
+           the multi-selection option.
+           They are much shorter than the whole join detected in line
+           selection mode, because the tiles are not perfectly aligned.}
+  \label{fig:edgeDir}
+\end{figure}
+
 Another option, called multi-detection allows the detection of all the
 segments crossed by the input stroke $AB$.
 The multi-detection algorithm is displayed below.
+
+\input{Fig_method/algoMulti}
+
 First the positions $M_j$ of the local maxima of the gradient magnitude found
 under the stroke are sorted from the highest to the lowest.
 For each of them the main detection process is run with three modifications:
@@ -233,71 +274,60 @@ detection;
 iii) points marked as occupied are rejected when selecting candidates for the
 blurred segment extension in the fine tracking step.
 
-\input{Fig_method/algoMulti}
-
-Beyond the possible detection of a large set of edges at once, the
-multi-detection allows the detection of some unaccessible edges in
-classical single detection mode. This is particularly the case of edges
-that are quite close to a more salient edge with a higher gradient,
-as illustrated in \RefFig{fig:voisins}.
-The multi-detection detects both edges and the user may then select
-the awaited one.
-
-\begin{figure}[h]
-\center
-  \begin{tabular}{c@{\hspace{0.2cm}}c@{\hspace{0.2cm}}c@{\hspace{0.2cm}}c}
-    \includegraphics[width=0.22\textwidth]{Fig_method/voisinImage_zoom.png} &
-    \includegraphics[width=0.22\textwidth]{Fig_method/voisinGrad_zoom.png} &
-    \includegraphics[width=0.22\textwidth]{Fig_method/voisinSingle_zoom.png} &
-    \includegraphics[width=0.22\textwidth]{Fig_method/voisinMulti_zoom.png} \\
-    \parbox{0.22\textwidth}{\centering{\scriptsize{a)}}} &
-    \parbox{0.22\textwidth}{\centering{\scriptsize{b)}}} &
-    \parbox{0.22\textwidth}{\centering{\scriptsize{c)}}} &
-    \parbox{0.22\textwidth}{\centering{\scriptsize{d)}}}
-  \end{tabular}
-  \caption{Detection of close edges with different sharpness:
-    a) input selection across the edges,
-    b) gradient map,
-    c) in single mode, detection of only the edge with the higher gradient,
-    d) in multi-detection mode, detection of both edges. }
-  \label{fig:voisins}
-\end{figure}
-
-This detection procedure can be used to detect as well straight edges
-as thin straight objects. In the first case, the gradient vectors of all
-edge points are assumed to be oriented in the same direction. But if the
-sign of the gradient direction is not considered, points with gradient in
-opposite directions are merged to build the same blurred segment, allowing
-the detection of both edges of a thin linear structure, like for instance
-the tile joins of \RefFig{fig:edgeDir}.
-
-\begin{figure}[h]
-\center
-  \begin{tabular}{c@{\hspace{0.2cm}}c}
-    \includegraphics[width=0.46\textwidth]{Fig_method/multiStroke_zoom.png} &
-    \includegraphics[width=0.46\textwidth]{Fig_method/multiEdge_zoom.png} \\
-    \parbox{0.46\textwidth}{\centering{\scriptsize{a)
-            Detection of straight lines}}} &
-    \parbox{0.46\textwidth}{\centering{\scriptsize{b)
-            Detection of straight edges}}}
-  \end{tabular}
-  \caption{Testing the gradient direction to detect as well edges as
-           linear structures from the same input stroke.}
-  \label{fig:edgeDir}
-\end{figure}
+In edge selection mode (\RefFig{fig:edgeDir} b), the multi-detection
+algorithm is executed twice.
+In the second run, the start point is rejected and only candidate points
+with opposite gradient direction are considered to extend the blurred
+segment.
+
+%Beyond the possible detection of a large set of edges at once, the
+%multi-detection allows the detection of some unaccessible edges in
+%classical single detection mode. This is particularly the case of edges
+%that are quite close to a more salient edge with a higher gradient,
+%as illustrated in \RefFig{fig:voisins}.
+%The multi-detection detects both edges and the user may then select
+%the awaited one.
+%
+%\begin{figure}[h]
+%\center
+%  \begin{tabular}{c@{\hspace{0.2cm}}c@{\hspace{0.2cm}}c@{\hspace{0.2cm}}c}
+%    \includegraphics[width=0.22\textwidth]{Fig_method/voisinImage_zoom.png} &
+%    \includegraphics[width=0.22\textwidth]{Fig_method/voisinGrad_zoom.png} &
+%    \includegraphics[width=0.22\textwidth]{Fig_method/voisinSingle_zoom.png} &
+%    \includegraphics[width=0.22\textwidth]{Fig_method/voisinMulti_zoom.png} \\
+%    \parbox{0.22\textwidth}{\centering{\scriptsize{a)}}} &
+%    \parbox{0.22\textwidth}{\centering{\scriptsize{b)}}} &
+%    \parbox{0.22\textwidth}{\centering{\scriptsize{c)}}} &
+%    \parbox{0.22\textwidth}{\centering{\scriptsize{d)}}}
+%  \end{tabular}
+%  \caption{Detection of close edges with different sharpness:
+%    a) input selection across the edges,
+%    b) gradient map,
+%    c) in single mode, detection of only the edge with the higher gradient,
+%    d) in multi-detection mode, detection of both edges. }
+%  \label{fig:voisins}
+%\end{figure}
 
-On that example, when a straight feature detection is run
-(\RefFig{fig:edgeDir} a),
-a thick blurred segment which extends up to four tiles is provided.
-When a straight edge detection is run, a very thin blurred segment is
-built to follow only one join edge.
-The multi-detection can also be applied to both thin object or edge detection.
-In the latter case, the detection algorithm is run twice using opposite
-directions, so that in the exemple of figure (\RefFig{fig:edgeDir} b),
-both edges (in different colors) are highlighted.
-These two thin blurred segments are much shorter, probably because the
-tiles are not perfectly aligned.
-This example illustrates the versatility of the new detector.
+%This detection procedure can be used to detect as well straight edges
+%as thin straight objects. In the first case, the gradient vectors of all
+%edge points are assumed to be oriented in the same direction. But if the
+%sign of the gradient direction is not considered, points with gradient in
+%opposite directions are merged to build the same blurred segment, allowing
+%the detection of both edges of a thin linear structure, like for instance
+%the tile joins of \RefFig{fig:edgeDir}.
+
+%On that example, when a straight feature detection is run
+%(\RefFig{fig:edgeDir} a),
+%a thick blurred segment which extends up to four tiles is provided.
+%When a straight edge detection is run, a very thin blurred segment is
+%built to follow only one join edge.
+%The multi-detection can also be applied to both thin object or edge detection.
+%In the latter case, the detection algorithm is run twice using opposite
+%directions, so that in the exemple of figure (\RefFig{fig:edgeDir} b),
+%both edges (in different colors) are highlighted.
+%These two thin blurred segments are much shorter, probably because the
+%tiles are not perfectly aligned.
+%This example illustrates the versatility of the new detector.
 
 \subsection{Automatic blurred segment detection}
 
diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/Seg/BlurredSegment/bsdetector.cpp
index 5313898..27510ed 100755
--- a/Code/Seg/BlurredSegment/bsdetector.cpp
+++ b/Code/Seg/BlurredSegment/bsdetector.cpp
@@ -42,14 +42,14 @@ BSDetector::BSDetector ()
   if (bstold->isThickenningOn ()) bstold->toggleThickenning ();
 
   oldp = false;
-  prefilteringOn = true;
+  prefilteringOn = false;
   lsf1 = (prefilteringOn ? new LineSpaceFilter () : NULL);
   filteringOn = false;
   lsf2 = (filteringOn ? new LineSpaceFilter () : NULL);
 
   edgeDirection = 0;   // detects strokes (not only edges)
   bsMinSize = DEFAULT_BS_MIN_SIZE;
-  ccOn = true;
+  ccOn = false;
   ccMinSize = DEFAULT_CONNECT_MIN_SIZE;
   recenteringOn = true;
   fittingOn = false;
diff --git a/Code/Seg/BlurredSegment/bstracker.cpp b/Code/Seg/BlurredSegment/bstracker.cpp
index 4462ab3..b4c4b4f 100755
--- a/Code/Seg/BlurredSegment/bstracker.cpp
+++ b/Code/Seg/BlurredSegment/bstracker.cpp
@@ -4,7 +4,7 @@
 
 
 const int BSTracker::DEFAULT_FAST_TRACK_MAX_WIDTH = 5;
-const int BSTracker::DEFAULT_FINE_TRACK_MAX_WIDTH = 8;
+const int BSTracker::DEFAULT_FINE_TRACK_MAX_WIDTH = 3;
 const int BSTracker::DEFAULT_ACCEPTED_LACKS = 5;
 const int BSTracker::NO_VICINITY = 10000;
 const int BSTracker::DEFAULT_VICINITY_THRESHOLD = 10;
-- 
GitLab