diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp index 026c152cbeca8b83f561c854579cbc4bdc5173eb..06f0acf65c7f63a0582ec86c7fb1592ebc85979c 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.cpp +++ b/Code/Seg/BSTools/bsdetectionwidget.cpp @@ -48,6 +48,7 @@ BSDetectionWidget::BSDetectionWidget (QWidget *parent) // Sets display parameters selectionColor = Qt::red; bsColor = Qt::blue; + //bsHighColor = Qt::black; bsHighColor = Qt::yellow; bsPointsVisible = true; boundColor = Qt::green; @@ -510,9 +511,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) extract (); nbdettrials = detector.countOfTrials (); nbmaxdettrials = 0; - cout << detector.getBlurredSegments().size () - << " blurred segments detected on " - << nbdettrials << " essais " << endl; +// cout << detector.getBlurredSegments().size () +// << " blurred segments detected on " +// << nbdettrials << " essais " << endl; } break; @@ -591,11 +592,22 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_R : - // Tunes the automatic detection grid resolution - detector.setAutoGridResolution (detector.getAutoGridResolution () + - (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); - cout << "Auto grid resolution = " - << detector.getAutoGridResolution () << " pixels" << endl; + if (event->modifiers () & Qt::ControlModifier) + { + // Switches the occupancy mask dilation modality + gMap->switchMaskDilation (); + extract (); + cout << "Occupancy mask dilation : " + << (gMap->isMaskDilationOn () ? "on" : "off") << endl; + } + else + { + // Tunes the automatic detection grid resolution + detector.setAutoGridResolution (detector.getAutoGridResolution () + + (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); + cout << "Auto grid resolution = " + << detector.getAutoGridResolution () << " pixels" << endl; + } break; case Qt::Key_S : @@ -933,13 +945,25 @@ void BSDetectionWidget::displayDetectionResult () vector<BlurredSegment *> bss = detector.getBlurredSegments (); if (! bss.empty ()) { +// cout << bss.size () << " blurred segments detected" << endl; +// double bsw = 0.; +// int bsc = 0; vector<BlurredSegment *>::const_iterator it = bss.begin (); while (it != bss.end ()) { +// if ((*it) != NULL) +// { +// DigitalStraightSegment *dss = (*it)->getSegment (); +// bsc++; +// if (dss == NULL) cout << "DSS null" << endl; +// else bsw += dss->width () / (double) dss->period (); +// } drawBlurredSegment (painter, *it, nbmaxdettrials == 0 || (*it == bss.back () && detector.isLastTrialOk ())); it++; } +// cout << bsc << " effective blurred segments" << endl; +// if (bsc != 0) cout << "Mean width is " << bsw / bsc << endl; } else drawBlurredSegment (painter, detector.getBlurredSegment ()); diff --git a/Code/Seg/ImageTools/vmap.cpp b/Code/Seg/ImageTools/vmap.cpp index a4b85a29d85d6ce1b2d9483a7189497ea77acec0..26a82eeb64b6646289bc22cdf01c9271a8b7ffc3 100755 --- a/Code/Seg/ImageTools/vmap.cpp +++ b/Code/Seg/ImageTools/vmap.cpp @@ -118,6 +118,7 @@ VMap::VMap (int width, int height, int *data, int type) mask = new bool[width * height]; for (int i = 0; i < width * height; i++) mask[i] = false; masking = false; + maskDilationOn = true; angleThreshold = NEAR_SQ_ANGLE; orientedGradient = false; } @@ -222,6 +223,7 @@ VMap::VMap (int width, int height, int **data, int type) mask = new bool[width * height]; for (int i = 0; i < width * height; i++) mask[i] = false; masking = false; + maskDilationOn = true; angleThreshold = NEAR_SQ_ANGLE; orientedGradient = false; } @@ -700,5 +702,23 @@ void VMap::setMask (const vector<Pt2i> &pts) { Pt2i pt = *it++; mask[pt.y () * width + pt.x ()] = true; + if (maskDilationOn) + { + int x = pt.x (), y = pt.y (); + if (x > 0) + { + mask[y * width + x - 1] = true; + if (y > 0) mask[(y - 1) * width + x - 1] = true; + if (y + 1 < height) mask[(y + 1) * width + x - 1] = true; + } + if (x + 1 < width) + { + mask[y * width + x + 1] = true; + if (y > 0) mask[(y - 1) * width + x + 1] = true; + if (y + 1 < height) mask[(y + 1) * width + x + 1] = true; + } + if (y > 0) mask[(y - 1) * width + x] = true; + if (y + 1 < height) mask[(y + 1) * width + x] = true; + } } } diff --git a/Code/Seg/ImageTools/vmap.h b/Code/Seg/ImageTools/vmap.h index 6e4d4829e36558286e6404ca683890073142abec..9f76483762724814589a9ce3e8ef25990a59c086 100755 --- a/Code/Seg/ImageTools/vmap.h +++ b/Code/Seg/ImageTools/vmap.h @@ -253,14 +253,24 @@ public: void setMask (const vector<Pt2i> &pts); /** - * \brief Sets mask activation on or off + * \brief Sets mask activation on or off. * @param status Required activation status. */ inline void setMasking (bool status) { masking = status; } /** - * \brief Sets mask activation on or off - * @param status Required activation status. + * \brief Retuns the mask dilation modality. + */ + inline bool isMaskDilationOn () const { return (maskDilationOn); } + + /** + * \brief Sets mask activation on or off. + */ + inline void switchMaskDilation () { maskDilationOn = ! maskDilationOn; } + + /** + * \brief Tests the occupancy of a mask cell. + * @param pt Position to test in the mask. */ inline bool isFree (const Pt2i &pt) const { return (! mask[pt.y () * width + pt.x ()]); } @@ -292,6 +302,8 @@ private: bool *mask; /** Flag indicating whether the occupancy mask is in use. */ bool masking; + /** Flag indicating whether input points should be dilated. */ + bool maskDilationOn; /** Standardized gradient threshold for highest value detection. */ int gradientThreshold; /** Gradient magnitude threshold for highest value detection. */ diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index 0c66a0e10f65cf38cd1cd7e5bfab021167cd1dce..f8abf6b414e27d2425db542ac73ef2f33df333b3 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -53,6 +53,7 @@ Ctrl-n && Commute la limitation de l'extension de la d\'etection initiale \\ Ctrl-o && Commute la directionnalit\'e des scans \\ Ctrl-p && Commute la d\'etection pr\'eliminaire \\ Ctrl-q && Commute le contr\^ole dynamique des scans \\ +Ctrl-r && Commute la dilatation du masque d'occupation \\ Ctrl-s && Commute la gestion des reprises sur interruption (1 / longueur absence) \\ Ctrl-t && Commute l'amincissement progressif \\ Ctrl-u && Commute l'affichage des bords des segments flous. \\