diff --git a/Article/Fig_expe/autoOld.png b/Article/Fig_expe/autoOld.png new file mode 100644 index 0000000000000000000000000000000000000000..d7119d38f83a3d633a31b30aa1b53b9cc83fb518 Binary files /dev/null and b/Article/Fig_expe/autoOld.png differ diff --git a/Article/Fig_expe/outliers.readme b/Article/Fig_expe/outliers.readme new file mode 100644 index 0000000000000000000000000000000000000000..c09afb2daf2832c475098da68ac544f032e0700f --- /dev/null +++ b/Article/Fig_expe/outliers.readme @@ -0,0 +1,3 @@ +Images obtenues pas le test testOutliers.txt + +Sur gimp selection de la zone (188,150)(432,192). diff --git a/Article/Fig_expe/outliersNew_full.png b/Article/Fig_expe/outliersNew_full.png index 224e1b0d646395cdc667e7118725c15a9ca0095c..97a581c362fd81a7172200c16bb0a678a8f61f45 100644 Binary files a/Article/Fig_expe/outliersNew_full.png and b/Article/Fig_expe/outliersNew_full.png differ diff --git a/Article/Fig_expe/outliersNew_zoom.png b/Article/Fig_expe/outliersNew_zoom.png index 85ad24366cf57887f20401ac66079fff00133746..da88571fc438da4eb8514c61d5e0c314277c76e4 100644 Binary files a/Article/Fig_expe/outliersNew_zoom.png and b/Article/Fig_expe/outliersNew_zoom.png differ diff --git a/Article/Fig_expe/outliersOld_full.png b/Article/Fig_expe/outliersOld_full.png new file mode 100644 index 0000000000000000000000000000000000000000..0fdac69e0c57e48beb6b6fd86b2f744b4ad27580 Binary files /dev/null and b/Article/Fig_expe/outliersOld_full.png differ diff --git a/Article/Fig_expe/outliersOld_zoom.png b/Article/Fig_expe/outliersOld_zoom.png new file mode 100644 index 0000000000000000000000000000000000000000..8cbae862774e5c16bba4862f30010a82068fbc6d Binary files /dev/null and b/Article/Fig_expe/outliersOld_zoom.png differ diff --git a/Article/Fig_expe/testOutliers.txt b/Article/Fig_expe/testOutliers.txt new file mode 100644 index 0000000000000000000000000000000000000000..e22da569c5d0c6fcdbd73885282a1fab6ac1e65c --- /dev/null +++ b/Article/Fig_expe/testOutliers.txt @@ -0,0 +1,2 @@ +335 185 +342 155 diff --git a/Article/expe.tex b/Article/expe.tex index 6beef24ac88cab7b34629b5c76783b1c7ce6c900..8ab22e2b5a8e8c0daaf5d3bf4e0923aee64a2d16 100755 --- a/Article/expe.tex +++ b/Article/expe.tex @@ -79,7 +79,7 @@ and Y ms for the new detector. \begin{figure}[h] \center \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} \end{tabular} \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. \begin{figure}[h] \center \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} \end{tabular} \caption{Potential insertion of outliers for both detectors: diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp index e0de37e2828a560ba3dae7f77083e73e61e1a722..34b153457c4fd1ef805f7a6b4373d48ffee0fbf1 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.cpp +++ b/Code/Seg/BSTools/bsdetectionwidget.cpp @@ -495,7 +495,6 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) else { // Runs an automatic detection -cout << "AUTO" << endl; udef = false; detector.setMaxTrials (-1); extract (); @@ -735,6 +734,13 @@ cout << "AUTO" << endl; switchIdetAnalyzer (); break; + case Qt::Key_6 : + detector.switchDetector (); + cout << (detector.oldDetectorOn () ? + "Old detector set" : "Present detector set") << endl; + extract (); + break; + case Qt::Key_7 : storeUserInput (); break; diff --git a/Code/Seg/BSTools/bsidetview.cpp b/Code/Seg/BSTools/bsidetview.cpp index 731e950a2231b2dbdb2a1369c4fbab75d60d1d42..0cf49ead4add5fd39f44949762da979ff60aff90 100755 --- a/Code/Seg/BSTools/bsidetview.cpp +++ b/Code/Seg/BSTools/bsidetview.cpp @@ -57,7 +57,7 @@ bool BSIdetView::processKeyEvent (QKeyEvent *event) // QRect (QPoint (0, 0), // QSize (idet->getWidth(), idet->getHeight())) // ).toImage().save ("firstDetection.png"); - cout << "First detection window shot in capture.png" << endl; + // cout << "First detection window shot in capture.png" << endl; break; case Qt::Key_Left : diff --git a/Code/Seg/BSTools/bsprofileview.cpp b/Code/Seg/BSTools/bsprofileview.cpp index 03cbb07bd46e90ec971a0a2c48b9b98bc0aad140..45c648e3638ff170a1221bd3f2a10cc3a40c2b3a 100755 --- a/Code/Seg/BSTools/bsprofileview.cpp +++ b/Code/Seg/BSTools/bsprofileview.cpp @@ -78,7 +78,7 @@ bool BSProfileView::processKeyEvent (QKeyEvent *event) // QRect (QPoint (0, 0), // QSize (prof->getWidth(), prof->getHeight())) // ).toImage().save ("profiles.png"); - cout << "Profiles shot in capture.png" << endl; + // cout << "Profiles shot in capture.png" << endl; break; case Qt::Key_Up : diff --git a/Code/Seg/BSTools/bsstructureview.cpp b/Code/Seg/BSTools/bsstructureview.cpp index 536234816dee6e9d1351a221efe1a2380ae1fd44..e40b0f11ed683cfebf6cd2915abaf2cff4eb9d84 100755 --- a/Code/Seg/BSTools/bsstructureview.cpp +++ b/Code/Seg/BSTools/bsstructureview.cpp @@ -120,7 +120,7 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event) // QRect (QPoint (0, 0), // QSize (grid->getWidth(), grid->getHeight())) // ).toImage().save ("structure.png"); - cout << "Structure shot in capture.png" << endl; + // cout << "Structure shot in capture.png" << endl; break; case Qt::Key_Plus : // Zoom in diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/Seg/BlurredSegment/bsdetector.cpp index a34c86fb67064478733494a46fc4ba4652860379..b988af8ba1a5d9308f9566c4bf2c1f7855c3f334 100755 --- a/Code/Seg/BlurredSegment/bsdetector.cpp +++ b/Code/Seg/BlurredSegment/bsdetector.cpp @@ -35,7 +35,12 @@ BSDetector::BSDetector () bst1 = new BSTracker (); // bst1->setPixelLackTolerence (bst1->getVicinityThreshold ()); 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; lsf1 = (prefilteringOn ? new LineSpaceFilter () : NULL); filteringOn = false; @@ -81,6 +86,7 @@ void BSDetector::setGradientMap (VMap *data) if (prelimDetectionOn) bst0->setGradientMap (data); bst1->setGradientMap (data); bst2->setGradientMap (data); + bstold->setGradientMap (data); } @@ -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, bool centralp, const Pt2i &pc) { + if (oldp) + { + olddetect (p1, p2, centralp, pc); + return; + } + // Clearance //---------- resultValue = RESULT_UNDETERMINED; diff --git a/Code/Seg/BlurredSegment/bsdetector.h b/Code/Seg/BlurredSegment/bsdetector.h index c5444c0549821560a34c3e836c72781d0fa5817e..b7afd53c880ecb1424b1547b4c4b54641c3a371a 100755 --- a/Code/Seg/BlurredSegment/bsdetector.h +++ b/Code/Seg/BlurredSegment/bsdetector.h @@ -105,6 +105,25 @@ public: void detect (const Pt2i &p1, const Pt2i &p2, 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. * @param step Detection step. @@ -497,6 +516,16 @@ public: */ 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 : @@ -545,8 +574,10 @@ private : bool autodet; /** Grid resolution for the automatic extraction. */ int autoResol; - /** Result of the blurred segment extraction */ + /** Result of the blurred segment extraction. */ int resultValue; + /** Old detector (IWCIA'09) modality. */ + bool oldp; /** Last input start point. */ Pt2i prep1; @@ -578,6 +609,8 @@ private : /** Fine tracker. */ BSTracker *bst2; + /** Old detector (IWCIA'09) fine tracker. */ + BSTracker *bstold; /** Detected blurred segment (final result). */ BlurredSegment *bsf; /** Detected blurred segments in case of multi-detection (final results). */ diff --git a/Code/Seg/BlurredSegment/bstracker.h b/Code/Seg/BlurredSegment/bstracker.h index d4de005d7df2e82e6c57a8395dfec1ec108d98d8..309953ee405ba75c1122191b38a581673529aeea 100755 --- a/Code/Seg/BlurredSegment/bstracker.h +++ b/Code/Seg/BlurredSegment/bstracker.h @@ -141,11 +141,6 @@ public: vicinityThreshold += (vicinityThreshold > 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. * @param side Upper bound if set to 1, lower bound otherwise. @@ -169,13 +164,18 @@ public: */ 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. */ inline void toggleDynamicScans () { dynamicScans = ! dynamicScans; } /** - * \brief Switches the scan extent limitation.. + * \brief Switches the scan extent limitation. */ void switchScanExtent (); diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index b6596d130b53bcb0b372e6d50f1884bfe30daa14..ede83d9fab5c1afbd90c7b482764d6c709a3801d 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -64,6 +64,7 @@ Ctrl-z && Commute le contr\^ole de la consigne d'\'epaisseur \\ 2 && Commute la visu de l'accumulateur \\ 3 && Commute la visu des profils \\ 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) \\ 9 && Teste la performance sur la derni\`ere barre trac\'ee \\ 8 && Teste comparativement sur diff\'erents contextes de d\'etection \\