Skip to content
Snippets Groups Projects
Commit 5277bda7 authored by even's avatar even
Browse files

Width handling

parent f8efcb82
No related branches found
No related tags found
No related merge requests found
...@@ -292,9 +292,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) ...@@ -292,9 +292,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
case Qt::Key_W : // Fast tracks max width case Qt::Key_W : // Fast tracks max width
if (event->modifiers () & Qt::ControlModifier) if (event->modifiers () & Qt::ControlModifier)
{ {
detector.switchAutoWidth (); detector.switchScanRecentering ();
cout << "Final step max width " << (detector.autoWidthOn () ? cout << "Fine tracking centered on " << (detector.isScanRecentering () ?
"fitted to initial segment" : "left unchanged") << endl; "detected segment" : "initial scan") << endl;
extract (); extract ();
} }
else else
...@@ -307,6 +307,24 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) ...@@ -307,6 +307,24 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
} }
break; break;
case Qt::Key_X :
if (event->modifiers () & Qt::ControlModifier)
{
detector.switchScanFitting ();
cout << "Fine tracking fitted to " << (detector.isScanFitting () ?
"detected segment width" : "assigned width") << endl;
extract ();
}
else
{
detector.setFastTracksMaxWidth (detector.fastTracksMaxWidth () +
(event->modifiers () & Qt::ShiftModifier ? -1 : 1));
extract ();
cout << "Fast tracks max width = "
<< detector.fastTracksMaxWidth () << endl;
}
break;
case Qt::Key_K : // Output blurred segment min size case Qt::Key_K : // Output blurred segment min size
detector.setBSminSize (detector.getBSminSize () + detector.setBSminSize (detector.getBSminSize () +
(event->modifiers () & Qt::ShiftModifier ? -1 : 1)); (event->modifiers () & Qt::ShiftModifier ? -1 : 1));
...@@ -343,14 +361,6 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) ...@@ -343,14 +361,6 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
<< (detector.isThinningActivated () ? "on" : "off") << endl; << (detector.isThinningActivated () ? "on" : "off") << endl;
break; break;
case Qt::Key_X :
detector.setFastTracksMaxWidth (detector.fastTracksMaxWidth () +
(event->modifiers () & Qt::ShiftModifier ? -1 : 1));
extract ();
cout << "Fast tracks max width = "
<< detector.fastTracksMaxWidth () << endl;
break;
case Qt::Key_S : case Qt::Key_S :
detector.switchDynamicScans (); detector.switchDynamicScans ();
cout << (detector.dynamicScansOn () ? cout << (detector.dynamicScansOn () ?
......
...@@ -38,7 +38,8 @@ BSDetector::BSDetector () ...@@ -38,7 +38,8 @@ BSDetector::BSDetector ()
edgeDirection = 0; // detects line (not only edges) edgeDirection = 0; // detects line (not only edges)
bsMinSize = DEFAULT_BS_MIN_SIZE; bsMinSize = DEFAULT_BS_MIN_SIZE;
connectMinSize = DEFAULT_CONNECT_MIN_SIZE; connectMinSize = DEFAULT_CONNECT_MIN_SIZE;
autowidth = true; recenteringOn = true;
fittingOn = false;
ccOn = true; ccOn = true;
densityTestOn = true; densityTestOn = true;
multiSelection = false; multiSelection = false;
...@@ -234,30 +235,29 @@ void BSDetector::detect (const Pt2i &p1, const Pt2i &p2, Pt2i *p0) ...@@ -234,30 +235,29 @@ void BSDetector::detect (const Pt2i &p1, const Pt2i &p2, Pt2i *p0)
return; return;
} }
// Finer detection based on gradient maxima with orientation constraint // Gradient reference selection
//--------------------------------------------------------------------- //-----------------------------
Pt2i pCenter = bsini->getCenter (); Pt2i pCenter = bsini->getCenter ();
Vr2i gRef = gMap->getValue (pCenter.x (), pCenter.y ()); Vr2i gRef = gMap->getValue (pCenter);
if (edgeDirection == -1) gRef.invert (); if (edgeDirection == -1) gRef.invert ();
int bswidth = bst1->fastTracksMaxWidth ();
int scanwidth2 = 4 * bswidth; // Scan recentering and fitting
if (autowidth) //-----------------------------
if (recenteringOn)
pCenter = bsini->getSegment()->centerOfIntersection (pt1, pt2);
int bswidth = bst1->fineTracksMaxWidth ();
if (fittingOn)
{ {
bswidth = bst1->fineTracksMaxWidth ();
/*
DigitalStraightSegment *dss = bsini->getSegment (); DigitalStraightSegment *dss = bsini->getSegment ();
if (dss != NULL) if (dss != NULL)
{ bswidth = 1 + dss->width () / dss->period ();
bswidth = (dss->width () / dss->period ());
if (bswidth < bst1->fineTracksMaxWidth ())
bswidth = bst1->fineTracksMaxWidth ();
}
*/
scanwidth2 = bswidth;
pCenter = bsini->getSegment()->centerOfIntersection (pt1, pt2);
} }
int scanwidth = bswidth + bswidth / 2;
// Finer detection based on gradient maxima with orientation constraint
//---------------------------------------------------------------------
bsf = bst2->fineTrack (pCenter, bsini->getSupportVector(), bsf = bst2->fineTrack (pCenter, bsini->getSupportVector(),
scanwidth2, bswidth, gRef); scanwidth, bswidth, gRef);
if (bsf == NULL || bsf->size () < bsMinSize) if (bsf == NULL || bsf->size () < bsMinSize)
{ {
......
...@@ -222,14 +222,24 @@ public: ...@@ -222,14 +222,24 @@ public:
} }
/** /**
* \brief Returns true if the automatic width selection is set. * \brief Returns true if the fine scan is recentred on the detected segment.
*/ */
inline bool autoWidthOn () { return autowidth; } inline bool isScanRecentering () { return recenteringOn; }
/** /**
* \brief Switches on or off the automatic width selection. * \brief Switches on or off the scan recentering modality.
*/ */
inline void switchAutoWidth () { autowidth = ! autowidth; } inline void switchScanRecentering () { recenteringOn = ! recenteringOn; }
/**
* \brief Returns true if the fine scan is fitted to the detected segment.
*/
inline bool isScanFitting () { return fittingOn; }
/**
* \brief Switches on or off the scan fitting modality.
*/
inline void switchScanFitting () { fittingOn = ! fittingOn; }
/** /**
* \brief Returns true if the multi-selection modality is set. * \brief Returns true if the multi-selection modality is set.
...@@ -433,8 +443,10 @@ private : ...@@ -433,8 +443,10 @@ private :
int bsMinSize; int bsMinSize;
/** Minimal size of the connected components to validate a blurred segment. */ /** Minimal size of the connected components to validate a blurred segment. */
int connectMinSize; int connectMinSize;
/** Automatic width selection (based on previous detection). */ /** Automatic scan recentering (based on previous detection). */
bool autowidth; bool recenteringOn;
/** Automatic scan width selection (based on previous detection). */
bool fittingOn;
/** Density test modality after initial detection. */ /** Density test modality after initial detection. */
bool densityTestOn; bool densityTestOn;
/** Segment multi-selection modality status. */ /** Segment multi-selection modality status. */
......
...@@ -196,9 +196,12 @@ BlurredSegment *BSTracker::fastTrack (const Pt2i &p1, const Pt2i &p2, ...@@ -196,9 +196,12 @@ BlurredSegment *BSTracker::fastTrack (const Pt2i &p1, const Pt2i &p2,
BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir, BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
int scanwidth2, int bswidth, int scanwidth, int bswidth,
const Vr2i &gref) const Vr2i &gref)
{ {
// Checks scan width minimal size
if (scanwidth < MIN_SCAN) scanwidth = MIN_SCAN;
// Gets detected segment normal vector // Gets detected segment normal vector
Vr2i normal = scandir.orthog (); Vr2i normal = scandir.orthog ();
if (! normal.orientedAs (gref)) normal.invert (); if (! normal.orientedAs (gref)) normal.invert ();
...@@ -207,7 +210,7 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir, ...@@ -207,7 +210,7 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
// Creation of the directional scanner and the array of candidates // Creation of the directional scanner and the array of candidates
DirectionalScanner *ds = scanp.getScanner ( DirectionalScanner *ds = scanp.getScanner (
center, normal, scanwidth2, dynamicScans, center, normal, scanwidth, dynamicScans,
0, 0, gMap->getWidth (), gMap->getHeight ()); 0, 0, gMap->getWidth (), gMap->getHeight ());
if (ds == NULL) if (ds == NULL)
{ {
...@@ -403,7 +406,6 @@ void BSTracker::switchOrthoScans () ...@@ -403,7 +406,6 @@ void BSTracker::switchOrthoScans ()
{ {
orthoScan = ! orthoScan; orthoScan = ! orthoScan;
scanp.setOrtho (orthoScan); scanp.setOrtho (orthoScan);
cout << "OrthoScan is " << (orthoScan ? "on" : "off") << endl;
} }
......
...@@ -48,12 +48,12 @@ public: ...@@ -48,12 +48,12 @@ public:
* Finer detection using gradient ridges and direction input. * Finer detection using gradient ridges and direction input.
* @param center Central point of the scan. * @param center Central point of the scan.
* @param scandir Scan direction * @param scandir Scan direction
* @param scanwidth2 Half width of the scan strip. * @param scanwidth Width of the scan strip.
* @param bswidth Initial maximal width of the blurred segment to build. * @param bswidth Initial maximal width of the blurred segment to build.
* @param gref Gradient vector reference to select candidates. * @param gref Gradient vector reference to select candidates.
*/ */
BlurredSegment *fineTrack (const Pt2i &center, const Vr2i &scandir, BlurredSegment *fineTrack (const Pt2i &center, const Vr2i &scandir,
int scanwidth2, int bswidth, int scanwidth, int bswidth,
const Vr2i &gref); const Vr2i &gref);
/** /**
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
* of (p1,p2) and aligned on (v1,v2). * of (p1,p2) and aligned on (v1,v2).
* @param centre central point * @param centre central point
* @param normal scan strip normal vector * @param normal scan strip normal vector
* @param length half length of a scan line * @param length length of a scan line
* @param controlable controlability request (true for a dynamical scanner) * @param controlable controlability request (true for a dynamical scanner)
* @param xmin left border of the scan area * @param xmin left border of the scan area
* @param xmax right border of the scan area * @param xmax right border of the scan area
......
...@@ -49,7 +49,9 @@ f && Commute le filtrage final \\ ...@@ -49,7 +49,9 @@ f && Commute le filtrage final \\
g && Commute la contrainte de connectivit\'e \\ g && Commute la contrainte de connectivit\'e \\
s && Commute l'aspect dynamique des scans \\ s && Commute l'aspect dynamique des scans \\
o && Commute l'aspect directionel des scans \\ o && Commute l'aspect directionel des scans \\
Ctrl-w && Commute l'ajustement de la consigne d'\'epaisseur \\ Ctrl-w && Commute le recentrage du scan sur le segment d\'etect\'e \\
Ctrl-x && Commute l'ajustement de la consigne d'\'epaisseur sur le segment
d\'etect\'e \\
P && Capture la fen\^etre principale \\ P && Capture la fen\^etre principale \\
1 && Commute la visu des segments (pixels) \\ 1 && Commute la visu des segments (pixels) \\
2 && Commute la visu de l'accumulateur \\ 2 && Commute la visu de l'accumulateur \\
......
...@@ -63,6 +63,7 @@ sur sur le segment d\'etect\'e. ...@@ -63,6 +63,7 @@ sur sur le segment d\'etect\'e.
\begin{itemize} \begin{itemize}
\item Balayage directionnel statique pour cr\'eer et \'etendre un segment flou \item Balayage directionnel statique pour cr\'eer et \'etendre un segment flou
\`a partir du gradient maximal trouv\'e dans la barre. \`a partir du gradient maximal trouv\'e dans la barre.
\item Consigne d'\'epaisseur : par d\'efaut 5 pixels, ajustable.
\item En phase d'extension, on applique un test de voisinage par rapport au \item En phase d'extension, on applique un test de voisinage par rapport au
dernier pixel ins\'er\'e (4 pixels). dernier pixel ins\'er\'e (4 pixels).
\item Aucun test angulaire. \item Aucun test angulaire.
...@@ -87,6 +88,12 @@ dernier pixel ins\'er\'e (4 pixels). ...@@ -87,6 +88,12 @@ dernier pixel ins\'er\'e (4 pixels).
\begin{itemize} \begin{itemize}
\item Balayage directionnel statique pour cr\'eer et \'etendre un segment flou \item Balayage directionnel statique pour cr\'eer et \'etendre un segment flou
\`a partir du gradient maximal trouv\'e dans la barre. \`a partir du gradient maximal trouv\'e dans la barre.
\item Consigne d'\'epaisseur : si la modalit\'e {\tt scanFitting} est
active, elle est cal\'ee sur l'\'epaisseur du segment d\'etect\'e \`a
l'\'etape pr\'ec\'edente. Sinon, par d\'efaut 8 pixels, ajustable.
\item Centrage : si la modalit\'e {\tt scanRecentering} est active, le
balayage est centr\'e sur le segment d\'etect\'e \`a l'\'etape pr\'ec\'edente.
Sinon, il est centr\'e sur la barre utilisateur ($P_1P_2$).
\item En phase d'extension, on applique un test de voisinage par rapport au \item En phase d'extension, on applique un test de voisinage par rapport au
dernier pixel ins\'er\'e (4 pixels). dernier pixel ins\'er\'e (4 pixels).
\item Aucun test angulaire. \item Aucun test angulaire.
......
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