Skip to content
Snippets Groups Projects
Commit 7af2bb78 authored by even's avatar even
Browse files

Detection widget revisited

parent 238e49b8
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -148,31 +148,37 @@ protected:
private:
/** Sensitiveness of segment max width parameter. */
static const int MAX_WIDTH_TUNING;
/** Sensitiveness of detection lacks parameter. */
static const int DETECTION_LACKS_TUNING;
/** Default value for pen width. */
static const int DEFAULT_PEN_WIDTH;
/** Initial scan end points */
Pt2i p1, p2;
/** Flag indicating if the stroke is completely defined. */
bool fixed;
/** Flag indicating whether extraction result should be displayed. */
bool verbose;
/** Flag indicating whether extraction result should be captured. */
bool capture;
/** Flag indicating whether no background should be displayed. */
bool paintItBlack;
/** Activation of alternate comparative tests (F8). */
int alternate;
/** Flag indicating if the detection is user defined. */
bool udef;
/** Index of the examined blurred segment in a multi-selection. */
int exam;
/** Activation of alternate comparative tests (F8). */
int alternate;
/** Color of user selections. */
QColor selectionColor;
/** Color of blurred segments. */
QColor bsColor;
/** Color of highlighted blurred segments. */
QColor bsHighColor;
/** Flag indicating whether blurred segments points are visible. */
bool bsPointsVisible;
/** Color of blurred segments bounds. */
QColor boundColor;
/** Color of highlighted blurred segments bounds. */
QColor boundHighColor;
/** Flag indicating whether blurred segments bounds are visible. */
bool bsBoundsVisible;
/** Flag indicating whether no background should be displayed. */
bool paintItBlack;
/** Flag indicating whether detection result should be output. */
bool verbose;
/** Presently loaded image. */
QImage loadedImage;
......@@ -184,92 +190,122 @@ private:
int width;
/** Height of the present image. */
int height;
/** Blurred segment detector. */
BSDetector detector;
/** Scanned profile graphics view. */
BSProfileView *profileview;
/** Filter accumulator view. */
BSAccumulatorView *accuview;
/** Blurred segment contents view. */
BSStructureView *strucview;
/** Aggregation of segment extraction results with initial conditions. */
struct ExtractedSegment
{
/** Extracted blurred segment. */
BlurredSegment *bs;
/** Selected strock start point. */
/** Selection stroke start point. */
Pt2i p1;
/** Selected stroke end point. */
/** Selection stroke end point. */
Pt2i p2;
};
/** List of registred blurred segments. */
vector<ExtractedSegment> extractedSegments;
/** Scanned profile graphics view. */
BSProfileView *profileview;
/** Filter accumulator view. */
BSAccumulatorView *accuview;
/** Blurred segment contents view. */
BSStructureView *strucview;
/**
* \brief Draws a list of points with the given color.
* @param painter Drawing device.
* @param pts List of points to be drawn.
* @param color Drawing color.
*/
void drawListOfPixels (vector<Pt2i> vectPixels,
QColor color, QPainter &painter);
void drawPoints (QPainter &painter,
vector<Pt2i> pts, QColor color);
/**
* \brief Draws a list of image pixels.
* @param painter Drawing device.
* @param pix List of pixels to be drawn.
*/
void drawListOfPixels (vector<Pt2i> vectPixels,
QPainter &painter);
void drawPixels (QPainter &painter, vector<Pt2i> pix);
/**
* \brief Draws the line joining two points.
* @param painter Drawing device.
* @param from Line start position.
* @param to Line reach position.
* @param color Drawing color.
*/
void drawLine (const Pt2i from, const Pt2i to,
QColor color, QPainter &painter);
void drawLine (QPainter &painter,
const Pt2i from, const Pt2i to, QColor color);
/**
* \brief Registers the last extracted blurred segment.
* \brief Draws a user selection.
* @param painter Drawing device.
* @param from Selection line start position.
* @param to Selection line reach position.
*/
void storeExtractedSegment ();
void drawSelection (QPainter &painter, const Pt2i from, const Pt2i to);
/**
* \brief Displays the registred blurred segments.
* \brief Draws a blurred segment.
* @param painter Drawing device.
* @param bs Reference to the blurred segment to be drawn.
* @param high Flag indicated whether the blurred segment is highlighted.
*/
void displayExtractedSegments ();
void drawBlurredSegment (QPainter &painter,
BlurredSegment *bs, bool high = false);
/**
* \brief Clears off the already extracted segments.
* \brief Displays the window background (no detection).
*/
void clearExtractedSegments ();
void displayBackground ();
/**
* \brief Displays the last extraction result.
* \brief Displays the result of a detection.
* @param aux Indicates if auxiliary views should be displayed.
* @param hnum Highlighted segment index (-1 if none).
*/
void displayExtractionResult ();
void displayDetectionResult (bool aux, int hnum = -1);
/**
* \brief Detects a blurred segment under the selected stroke.
* @param withAllDisplay Indicates if all information about the extraction
* should be displayed.
* \brief Highlights the next blurred segment in multi-selection mode.
* @param dir Increment in the multi-selection.
*/
void extract (bool withAllDisplay);
void displayNext (int dir);
/**
* \brief Detects and displays a blurred segment under the selected stroke.
* \brief Displays the saved blurred segments.
*/
void extract ();
void displaySavedSegments ();
/**
* \brief Detects and displays all the blurred segment in the picture.
* \brief Registers the last extracted blurred segment.
*/
void extractAll ();
void saveExtractedSegment ();
/**
* \brief Highlights the next blurred segment in multi-selection mode.
* @param dir Increment in the multi-selection.
* \brief Clears off the saved blurred segments.
*/
void displayNext (int dir);
void clearSavedSegments ();
/**
* \brief Outputs the last detection result.
*/
void writeDetectionResult ();
/**
* \brief Detects and displays a blurred segment under the selected stroke.
* @param updateAll Indicates if the extraction result should be displayed.
*/
void extract (bool updateAll = true);
/**
* \brief Detects and displays all the blurred segment in the picture.
*/
void extractAll ();
};
#endif
......@@ -75,27 +75,9 @@ void BSDetector::setGradientMap (VMap *data)
}
void BSDetector::freeMultiSelection ()
{
vector<BlurredSegment *>::iterator it = mbsini.begin ();
while (it != mbsini.end ()) delete (*it++);
mbsini.clear ();
it = mbsf.begin ();
while (it != mbsf.end ()) delete (*it++);
mbsf.clear ();
}
void BSDetector::detectAll ()
{
// Deletes former blurred segments
vector<BlurredSegment *>::iterator it = mbsini.begin ();
while (it != mbsini.end ()) delete (*it++);
mbsini.clear ();
it = mbsf.begin ();
while (it != mbsf.end ()) delete (*it++);
mbsf.clear ();
freeMultiSelection ();
gMap->setMasking (true);
int width = gMap->getWidth ();
......@@ -114,20 +96,28 @@ void BSDetector::detectAll ()
}
void BSDetector::multidetect (const Pt2i &p1, const Pt2i &p2)
void BSDetector::detectSelection (const Pt2i &p1, const Pt2i &p2)
{
freeMultiSelection ();
if (multiSelection)
{
gMap->setMasking (true);
runMultiDetection (p1, p2, p1.vectorTo (p2));
gMap->clearMask ();
gMap->setMasking (false);
}
else detect (p1, p2);
}
void BSDetector::freeMultiSelection ()
{
// Deletes former blurred segments
vector<BlurredSegment *>::iterator it = mbsini.begin ();
while (it != mbsini.end ()) delete (*it++);
mbsini.clear ();
it = mbsf.begin ();
while (it != mbsf.end ()) delete (*it++);
mbsf.clear ();
gMap->setMasking (true);
runMultiDetection (p1, p2, p1.vectorTo (p2));
gMap->clearMask ();
gMap->setMasking (false);
}
......@@ -168,6 +158,7 @@ void BSDetector::detect (const Pt2i &p1, const Pt2i &p2, Pt2i *p0)
bsini = NULL;
if (bsf != NULL) delete bsf;
bsf = NULL;
if (p1.equals (p2)) return;
Pt2i pt1 (p1);
Pt2i pt2 (p2);
......
......@@ -69,11 +69,11 @@ public:
void detectAll ();
/**
* \brief Detects all blurred segments between two input points.
* \brief Detects blurred segments between two input points.
* @param p1 First input point.
* @param p2 Second input point.
*/
void multidetect (const Pt2i &p1, const Pt2i &p2);
void detectSelection (const Pt2i &p1, const Pt2i &p2);
/**
* \brief Detects a blurred segment between two input points.
......@@ -106,14 +106,14 @@ public:
return (step == 0 ? mbsini : mbsf); }
/**
* \brief Resets the multi-selection list.
* \brief Avoids the deletion of the last extracted blurred segment.
*/
void freeMultiSelection ();
inline void preserveFormerBlurredSegment () { bsf = NULL; }
/**
* \brief Avoids the deletion of the last extracted blurred segent.
* \brief Avoids the deletion of the last extracted blurred segments.
*/
inline void preserveFormerBlurredSegment () { bsf = NULL; }
inline void preserveFormerBlurredSegments () { mbsf.clear (); }
/**
* \brief Returns the input maximal width of the initial segment.
......@@ -474,5 +474,10 @@ private :
void runMultiDetection (const Pt2i &p1, const Pt2i &p2,
const Vr2i &dir);
/**
* \brief Resets the multi-selection list.
*/
void freeMultiSelection ();
};
#endif
......@@ -25,6 +25,8 @@
\multicolumn{3}{|l|}{Contr\^ole de l'extraction :} \\
u & \spa & Actualiser \\
v && Afficher le r\'esultat \\
a && Commute l'affichage des points des segments flous. \\
A && Commute l'affichage des bords des segments flous. \\
w && Consigne initiale d'\'epaisseur du segment flou \\
h && Longueur tol\'er\'ee pour les sauts de d\'etection \\
k && Taille minimale des segments d\'etect\'es \\
......@@ -47,7 +49,7 @@ g && Commute la contrainte de connectivit\'e \\
s && Commute l'aspect dynamique des scans \\
o && Commute l'aspect directionel des scans \\
x && Commute l'ajustement de la consigne d'\'epaisseur \\
P && Demande la capture de la prochaine extraction \\
P && Capture la fen\^etre principale \\
1 && Commute la visu des segments (pixels) \\
2 && Commute la visu de l'accumulateur \\
3 && Commute la visu des profils \\
......
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