Skip to content
Snippets Groups Projects
Commit 02e8ae50 authored by even's avatar even
Browse files

Old detector integrated

parent a8446fa1
No related branches found
No related tags found
No related merge requests found
Showing
with 170 additions and 13 deletions
Article/Fig_expe/autoOld.png

115 KiB

Images obtenues pas le test testOutliers.txt
Sur gimp selection de la zone (188,150)(432,192).
Article/Fig_expe/outliersNew_full.png

94.3 KiB | W: | H:

Article/Fig_expe/outliersNew_full.png

93.1 KiB | W: | H:

Article/Fig_expe/outliersNew_full.png
Article/Fig_expe/outliersNew_full.png
Article/Fig_expe/outliersNew_full.png
Article/Fig_expe/outliersNew_full.png
  • 2-up
  • Swipe
  • Onion skin
Article/Fig_expe/outliersNew_zoom.png

23.8 KiB | W: | H:

Article/Fig_expe/outliersNew_zoom.png

7.72 KiB | W: | H:

Article/Fig_expe/outliersNew_zoom.png
Article/Fig_expe/outliersNew_zoom.png
Article/Fig_expe/outliersNew_zoom.png
Article/Fig_expe/outliersNew_zoom.png
  • 2-up
  • Swipe
  • Onion skin
Article/Fig_expe/outliersOld_full.png

93.4 KiB

Article/Fig_expe/outliersOld_zoom.png

7.99 KiB

335 185
342 155
...@@ -79,7 +79,7 @@ and Y ms for the new detector. ...@@ -79,7 +79,7 @@ and Y ms for the new detector.
\begin{figure}[h] \begin{figure}[h]
\center \center
\begin{tabular}{c@{\hspace{0.2cm}}c} \begin{tabular}{c@{\hspace{0.2cm}}c}
\includegraphics[width=0.49\textwidth]{Fig_expe/autoNew.png} & \includegraphics[width=0.49\textwidth]{Fig_expe/autoOld.png} &
\includegraphics[width=0.49\textwidth]{Fig_expe/autoNew.png} \includegraphics[width=0.49\textwidth]{Fig_expe/autoNew.png}
\end{tabular} \end{tabular}
\caption{Automatic edge detections on one of the test images with the \caption{Automatic edge detections on one of the test images with the
...@@ -100,7 +100,7 @@ and the assigned width has not been set to the detected segment minimal width. ...@@ -100,7 +100,7 @@ and the assigned width has not been set to the detected segment minimal width.
\begin{figure}[h] \begin{figure}[h]
\center \center
\begin{tabular}{c@{\hspace{0.2cm}}c} \begin{tabular}{c@{\hspace{0.2cm}}c}
\includegraphics[width=0.49\textwidth]{Fig_expe/outliersNew_zoom.png} & \includegraphics[width=0.49\textwidth]{Fig_expe/outliersOld_zoom.png} &
\includegraphics[width=0.49\textwidth]{Fig_expe/outliersNew_zoom.png} \includegraphics[width=0.49\textwidth]{Fig_expe/outliersNew_zoom.png}
\end{tabular} \end{tabular}
\caption{Potential insertion of outliers for both detectors: \caption{Potential insertion of outliers for both detectors:
......
...@@ -495,7 +495,6 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) ...@@ -495,7 +495,6 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
else else
{ {
// Runs an automatic detection // Runs an automatic detection
cout << "AUTO" << endl;
udef = false; udef = false;
detector.setMaxTrials (-1); detector.setMaxTrials (-1);
extract (); extract ();
...@@ -735,6 +734,13 @@ cout << "AUTO" << endl; ...@@ -735,6 +734,13 @@ cout << "AUTO" << endl;
switchIdetAnalyzer (); switchIdetAnalyzer ();
break; break;
case Qt::Key_6 :
detector.switchDetector ();
cout << (detector.oldDetectorOn () ?
"Old detector set" : "Present detector set") << endl;
extract ();
break;
case Qt::Key_7 : case Qt::Key_7 :
storeUserInput (); storeUserInput ();
break; break;
......
...@@ -57,7 +57,7 @@ bool BSIdetView::processKeyEvent (QKeyEvent *event) ...@@ -57,7 +57,7 @@ bool BSIdetView::processKeyEvent (QKeyEvent *event)
// QRect (QPoint (0, 0), // QRect (QPoint (0, 0),
// QSize (idet->getWidth(), idet->getHeight())) // QSize (idet->getWidth(), idet->getHeight()))
// ).toImage().save ("firstDetection.png"); // ).toImage().save ("firstDetection.png");
cout << "First detection window shot in capture.png" << endl; // cout << "First detection window shot in capture.png" << endl;
break; break;
case Qt::Key_Left : case Qt::Key_Left :
......
...@@ -78,7 +78,7 @@ bool BSProfileView::processKeyEvent (QKeyEvent *event) ...@@ -78,7 +78,7 @@ bool BSProfileView::processKeyEvent (QKeyEvent *event)
// QRect (QPoint (0, 0), // QRect (QPoint (0, 0),
// QSize (prof->getWidth(), prof->getHeight())) // QSize (prof->getWidth(), prof->getHeight()))
// ).toImage().save ("profiles.png"); // ).toImage().save ("profiles.png");
cout << "Profiles shot in capture.png" << endl; // cout << "Profiles shot in capture.png" << endl;
break; break;
case Qt::Key_Up : case Qt::Key_Up :
......
...@@ -120,7 +120,7 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event) ...@@ -120,7 +120,7 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event)
// QRect (QPoint (0, 0), // QRect (QPoint (0, 0),
// QSize (grid->getWidth(), grid->getHeight())) // QSize (grid->getWidth(), grid->getHeight()))
// ).toImage().save ("structure.png"); // ).toImage().save ("structure.png");
cout << "Structure shot in capture.png" << endl; // cout << "Structure shot in capture.png" << endl;
break; break;
case Qt::Key_Plus : // Zoom in case Qt::Key_Plus : // Zoom in
......
...@@ -35,7 +35,12 @@ BSDetector::BSDetector () ...@@ -35,7 +35,12 @@ BSDetector::BSDetector ()
bst1 = new BSTracker (); bst1 = new BSTracker ();
// bst1->setPixelLackTolerence (bst1->getVicinityThreshold ()); // bst1->setPixelLackTolerence (bst1->getVicinityThreshold ());
bst2 = new BSTracker (); bst2 = new BSTracker ();
bstold = new BSTracker ();
if (bstold->dynamicScansOn ()) bstold->toggleDynamicScans ();
if (bstold->isThinningActivated ()) bstold->toggleThinning ();
if (bstold->isThickenningOn ()) bstold->toggleThickenning ();
oldp = false;
prefilteringOn = true; prefilteringOn = true;
lsf1 = (prefilteringOn ? new LineSpaceFilter () : NULL); lsf1 = (prefilteringOn ? new LineSpaceFilter () : NULL);
filteringOn = false; filteringOn = false;
...@@ -81,6 +86,7 @@ void BSDetector::setGradientMap (VMap *data) ...@@ -81,6 +86,7 @@ void BSDetector::setGradientMap (VMap *data)
if (prelimDetectionOn) bst0->setGradientMap (data); if (prelimDetectionOn) bst0->setGradientMap (data);
bst1->setGradientMap (data); bst1->setGradientMap (data);
bst2->setGradientMap (data); bst2->setGradientMap (data);
bstold->setGradientMap (data);
} }
...@@ -165,9 +171,115 @@ bool BSDetector::runMultiDetection (const Pt2i &p1, const Pt2i &p2) ...@@ -165,9 +171,115 @@ bool BSDetector::runMultiDetection (const Pt2i &p1, const Pt2i &p2)
} }
void BSDetector::olddetect (const Pt2i &p1, const Pt2i &p2,
bool centralp, const Pt2i &pc)
{
// Clearance
//----------
resultValue = RESULT_UNDETERMINED;
bst1->clear ();
bst2->clear ();
if (bsini != NULL) delete bsini;
bsini = NULL;
if (bsf != NULL) delete bsf;
bsf = NULL;
lastTrialOk = false;
if (p1.equals (p2)) return;
inip1.set (p1);
inip2.set (p2);
inicentralp = centralp;
inipc.set (pc);
// Initial detection based on highest gradient without orientation constraint
//---------------------------------------------------------------------------
bsini = bst1->fastTrack (inip1, inip2, inicentralp, inipc);
if (bsini == NULL || bsini->size () < bsMinSize)
{
resultValue = (bsini == NULL ? RESULT_INITIAL_NO_DETECTION
: RESULT_INITIAL_TOO_FEW);
return;
}
// Density test
//-------------
/*
if (densityTestOn)
{
DigitalStraightLine mydsl (inip1, inip2, DigitalStraightLine::DSL_NAIVE);
int mydrlf = mydsl.manhattan (bsini->getLastRight ())
- mydsl.manhattan (bsini->getLastLeft ());
if (mydrlf < 0) mydrlf = -mydrlf; // Case of horizontal P1P2
int expansion = 1 + mydrlf;
if (bsini->size () < expansion / 2)
{
resultValue = RESULT_INITIAL_TOO_SPARSE;
return;
}
}
*/
// Gradient reference selection
//-----------------------------
Pt2i pCenter = bsini->getCenter ();
Vr2i gRef = gMap->getValue (pCenter);
if (edgeDirection == -1) gRef.invert ();
// Scan recentering and fitting
//-----------------------------
if (recenteringOn)
pCenter = bsini->getSegment()->centerOfIntersection (inip1, inip2);
int bswidth = bst1->fastTracksMaxWidth ();
int scanwidth = 4 * bswidth;
// Finer detection based on gradient maxima with orientation constraint
//---------------------------------------------------------------------
bsf = bstold->fineTrack (pCenter, bsini->getSupportVector(),
scanwidth, bswidth, gRef);
if (bsf == NULL || bsf->size () < bsMinSize)
{
resultValue = (bsf == NULL ? RESULT_FINAL_NO_DETECTION
: RESULT_FINAL_TOO_FEW);
return;
}
// Scan recentering and fitting
//-----------------------------
pCenter = bsini->getCenter ();
if (recenteringOn)
pCenter = bsf->getSegment()->centerOfIntersection (inip1, inip2);
// Third detection based on gradient maxima with orientation constraint
//---------------------------------------------------------------------
BlurredSegment *bsf2 = bstold->fineTrack (pCenter, bsf->getSupportVector(),
scanwidth, bswidth, gRef);
if (bsf2 == NULL || bsf2->size () < bsMinSize)
{
resultValue = (bsf2 == NULL ? RESULT_FINAL_NO_DETECTION
: RESULT_FINAL_TOO_FEW);
if (bsf2 != NULL) delete bsf2;
return;
}
else
{
delete bsf;
bsf = bsf2;
}
lastTrialOk = true;
resultValue = RESULT_OK;
}
void BSDetector::detect (const Pt2i &p1, const Pt2i &p2, void BSDetector::detect (const Pt2i &p1, const Pt2i &p2,
bool centralp, const Pt2i &pc) bool centralp, const Pt2i &pc)
{ {
if (oldp)
{
olddetect (p1, p2, centralp, pc);
return;
}
// Clearance // Clearance
//---------- //----------
resultValue = RESULT_UNDETERMINED; resultValue = RESULT_UNDETERMINED;
......
...@@ -105,6 +105,25 @@ public: ...@@ -105,6 +105,25 @@ public:
void detect (const Pt2i &p1, const Pt2i &p2, void detect (const Pt2i &p1, const Pt2i &p2,
bool centralp = false, const Pt2i &pc = Pt2i ()); bool centralp = false, const Pt2i &pc = Pt2i ());
/**
* \brief Detects a blurred segment between two input points.
* Step 1: For each scan line, one candidate is selected
* based on the gradient norm only (no direction test).
* Step 2: For each scan line, local candidates are detected
* on top of gradient ridges with closest direction.
* The first candidates that prolongates the segment are retained.
* The directional scan is oriented on the segment of step 1.
* Step 3: id. step 2.
* The directional scan is oriented on the segment of step 2.
* Note : Multi-detection along a stroke requires an initial start point.
* @param p1 First input point.
* @param p2 Second input point.
* @param centralp Set to true if the central point is provided.
* @param pc Initial central point.
*/
void olddetect (const Pt2i &p1, const Pt2i &p2,
bool centralp = false, const Pt2i &pc = Pt2i ());
/** /**
* \brief Returns the detected blurred segment at given step. * \brief Returns the detected blurred segment at given step.
* @param step Detection step. * @param step Detection step.
...@@ -497,6 +516,16 @@ public: ...@@ -497,6 +516,16 @@ public:
*/ */
void getScanInput (int step, Pt2i &p1, Pt2i &p2, int &width, Pt2i &pc) const; void getScanInput (int step, Pt2i &p1, Pt2i &p2, int &width, Pt2i &pc) const;
/**
* \brief Retuns whether the old detector (IWCIA '09) is used.
*/
inline bool oldDetectorOn () { return oldp; }
/**
* \brief Toggles the detector used (between IWCIA '09 and present).
*/
inline void switchDetector () { oldp = ! oldp; }
private : private :
...@@ -545,8 +574,10 @@ private : ...@@ -545,8 +574,10 @@ private :
bool autodet; bool autodet;
/** Grid resolution for the automatic extraction. */ /** Grid resolution for the automatic extraction. */
int autoResol; int autoResol;
/** Result of the blurred segment extraction */ /** Result of the blurred segment extraction. */
int resultValue; int resultValue;
/** Old detector (IWCIA'09) modality. */
bool oldp;
/** Last input start point. */ /** Last input start point. */
Pt2i prep1; Pt2i prep1;
...@@ -578,6 +609,8 @@ private : ...@@ -578,6 +609,8 @@ private :
/** Fine tracker. */ /** Fine tracker. */
BSTracker *bst2; BSTracker *bst2;
/** Old detector (IWCIA'09) fine tracker. */
BSTracker *bstold;
/** Detected blurred segment (final result). */ /** Detected blurred segment (final result). */
BlurredSegment *bsf; BlurredSegment *bsf;
/** Detected blurred segments in case of multi-detection (final results). */ /** Detected blurred segments in case of multi-detection (final results). */
......
...@@ -141,11 +141,6 @@ public: ...@@ -141,11 +141,6 @@ public:
vicinityThreshold += (vicinityThreshold > NO_VICINITY ? vicinityThreshold += (vicinityThreshold > NO_VICINITY ?
- NO_VICINITY : NO_VICINITY); } - NO_VICINITY : NO_VICINITY); }
/**
* \brief Returns if the dynamic scans are used.
*/
inline bool dynamicScansOn () { return dynamicScans; }
/** /**
* \brief Returns the registered upper bounds of the final scan lines. * \brief Returns the registered upper bounds of the final scan lines.
* @param side Upper bound if set to 1, lower bound otherwise. * @param side Upper bound if set to 1, lower bound otherwise.
...@@ -169,13 +164,18 @@ public: ...@@ -169,13 +164,18 @@ public:
*/ */
inline void setScanRecord (bool status) { recordScans = status; } inline void setScanRecord (bool status) { recordScans = status; }
/**
* \brief Returns if the dynamic scans are used.
*/
inline bool dynamicScansOn () { return dynamicScans; }
/** /**
* \brief Toggles the dynamic scans use. * \brief Toggles the dynamic scans use.
*/ */
inline void toggleDynamicScans () { dynamicScans = ! dynamicScans; } inline void toggleDynamicScans () { dynamicScans = ! dynamicScans; }
/** /**
* \brief Switches the scan extent limitation.. * \brief Switches the scan extent limitation.
*/ */
void switchScanExtent (); void switchScanExtent ();
......
...@@ -64,6 +64,7 @@ Ctrl-z && Commute le contr\^ole de la consigne d'\'epaisseur \\ ...@@ -64,6 +64,7 @@ Ctrl-z && Commute le contr\^ole de la consigne d'\'epaisseur \\
2 && Commute la visu de l'accumulateur \\ 2 && Commute la visu de l'accumulateur \\
3 && Commute la visu des profils \\ 3 && Commute la visu des profils \\
4 && Commute la visu de la d\'etection initiale \\ 4 && Commute la visu de la d\'etection initiale \\
6 && Commute l'ancien et le nouveau d\'etecteur \\
0 && Teste avec la derni\`ere barre enregistr\'ee (test.txt) \\ 0 && Teste avec la derni\`ere barre enregistr\'ee (test.txt) \\
9 && Teste la performance sur la derni\`ere barre trac\'ee \\ 9 && Teste la performance sur la derni\`ere barre trac\'ee \\
8 && Teste comparativement sur diff\'erents contextes de d\'etection \\ 8 && Teste comparativement sur diff\'erents contextes de d\'etection \\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment