Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GridHealerVertical Class Reference

Subclass of GridHealerAbstractBase for vertical lines. More...

#include <GridHealerVertical.h>

Inheritance diagram for GridHealerVertical:
Inheritance graph
Collaboration diagram for GridHealerVertical:
Collaboration graph

Public Member Functions

 GridHealerVertical (GridLog &gridLog, const DocumentModelGridRemoval &modelGridRemoval)
 Single constructor.
 
virtual void applyMutualPairs (const QImage &image)
 Apply mutual pair points after all grid removal is done.
 
virtual void doHealingAcrossGaps (QImage &image)
 Guts of the algorithm in which sequences of black pixels across the gap from each other are filled in.
 
- Public Member Functions inherited from GridHealerAbstractBase
 GridHealerAbstractBase (GridLog &gridLog, const DocumentModelGridRemoval &modelGridRemoval)
 Single constructor.
 
virtual ~GridHealerAbstractBase ()
 
void addMutualPair (int x0, int y0, int x1, int y1)
 Add two points on either side of a gap. Later, after removal, the black points will be processed.
 
void healed (QImage &image)
 Return healed image after grid removal.
 

Additional Inherited Members

- Static Public Member Functions inherited from GridHealerAbstractBase
static int pixelCountInRegionThreshold (const DocumentModelGridRemoval &modelGridRemoval)
 Threshold number of pixels in a region to be considered too-small or big-enough.
 
- Protected Member Functions inherited from GridHealerAbstractBase
void fillTrapezoid (QImage &image, int xBL, int yBL, int xBR, int yBR, int xTR, int yTR, int xTL, int yTL)
 Fill trapezoid with bottom left, bottom right, top right, and top left points.
 
GridLoggridLog ()
 Logging get method.
 
double maxPointSeparation () const
 Max point separation get method.
 
DocumentModelGridRemovalmodelGridRemoval ()
 DocumentModelGridRemoval get method.
 
const MutualPairHalvesmutualPairHalvesAbove () const
 Mutual pair halves for below grid line.
 
const MutualPairHalvesmutualPairHalvesBelow () const
 Mutual pair halves for above grid line.
 
bool pointsAreGood (const QImage &image, int x0, int y0, int x1, int y1) const
 Apply blackPixelRegionIsBigEnough to regions around each of two points.
 
void saveGapSeparation (double gapSeparation)
 Gap separation set method.
 

Detailed Description

Subclass of GridHealerAbstractBase for vertical lines.

Definition at line 20 of file GridHealerVertical.h.

Constructor & Destructor Documentation

◆ GridHealerVertical()

GridHealerVertical::GridHealerVertical ( GridLog & gridLog,
const DocumentModelGridRemoval & modelGridRemoval )

Single constructor.

Definition at line 13 of file GridHealerVertical.cpp.

14 :
17{
18}
Class that 'heals' the curves after one grid line has been removed.
DocumentModelGridRemoval & modelGridRemoval()
DocumentModelGridRemoval get method.
GridLog & gridLog()
Logging get method.

Member Function Documentation

◆ applyMutualPairs()

void GridHealerVertical::applyMutualPairs ( const QImage & image)
virtual

Apply mutual pair points after all grid removal is done.

Implements GridHealerAbstractBase.

Definition at line 20 of file GridHealerVertical.cpp.

21{
22 MutualPairHalves::const_iterator itrBelow = mutualPairHalvesBelow().begin();
23 MutualPairHalves::const_iterator itrAbove = mutualPairHalvesAbove().begin();
24
25 while (itrBelow != mutualPairHalvesBelow().end() &&
27
28 QPoint p0 = *(itrBelow++);
29 QPoint p1 = *(itrAbove++);
30
31 // Save (independent,dependent) pairs
32 if (Pixels::pixelIsBlack (image, p0.x(), p0.y())) {
33 m_blackPixelsBelow [p0.y()] = p0.x();
34 }
35
36 if (Pixels::pixelIsBlack (image, p1.x(), p1.y())) {
37 m_blackPixelsAbove [p1.y()] = p1.x();
38 }
39
40 saveGapSeparation (qAbs (p1.x() - p0.x()));
41 }
42}
const int INNER_RADIUS_MIN
const MutualPairHalves & mutualPairHalvesAbove() const
Mutual pair halves for below grid line.
const MutualPairHalves & mutualPairHalvesBelow() const
Mutual pair halves for above grid line.
void saveGapSeparation(double gapSeparation)
Gap separation set method.
static bool pixelIsBlack(const QImage &image, int x, int y)
Return true if pixel is black in black and white image.
Definition Pixels.cpp:286

◆ doHealingAcrossGaps()

void GridHealerVertical::doHealingAcrossGaps ( QImage & image)
virtual

Guts of the algorithm in which sequences of black pixels across the gap from each other are filled in.

Specifically, trapezoids with endpoints separated by no more than the closest distance are filled in. A greedy algorithm is used which makes each trapezoid as big as possible

Implements GridHealerAbstractBase.

Definition at line 44 of file GridHealerVertical.cpp.

45{
46 // LOG4CPP_INFO_S is replaced by GridLog
47 GridIndependentToDependent::const_iterator itrBelow, itrAbove;
48 for (itrBelow = m_blackPixelsBelow.begin(); itrBelow != m_blackPixelsBelow.end(); itrBelow++) {
49 QPoint p (itrBelow.value(),
50 itrBelow.key());
53 }
54 for (itrAbove = m_blackPixelsAbove.begin(); itrAbove != m_blackPixelsAbove.end(); itrAbove++) {
55 QPoint p (itrAbove.value(),
56 itrAbove.key());
59 }
60
61 // Algorithm requires at least one point in each of the lists
62 if (m_blackPixelsBelow.count() > 0 &&
63 m_blackPixelsAbove.count() > 0) {
64
65 int yFirst = qMin (m_blackPixelsBelow.firstKey (),
66 m_blackPixelsAbove.firstKey ());
67 int yLast = qMax (m_blackPixelsBelow.lastKey (),
68 m_blackPixelsAbove.lastKey ());
69
70 int yBelowEnd = 0; // Used by inner loop to skip to this iterator value
71
73
74 if ((yBelowEnd < yBelowStart) &&
75 m_blackPixelsBelow.contains (yBelowStart)) {
76
77 // This could be the start of a new trapezoid. Find where the range on the same side ends
78 int yBelowOutOfBounds = yLast + 1; // Value forcing transition to out of range
79
81
82 if (!m_blackPixelsBelow.contains (yBelowEnd) || (yBelowEnd == yBelowOutOfBounds)) {
83
84 doHealingOnBelowRange (image,
88
89 // Go back to outer loop, which will skip to xBelowEnd
90 break;
91 }
92 }
93 }
94 }
95 }
96}
const double HALFWIDTH_VERTICAL
double maxPointSeparation() const
Max point separation get method.
void showInputPixel(const QPoint &p, double halfWidth)
Show pixels that are inputs to GridHealer.
Definition GridLog.cpp:68

The documentation for this class was generated from the following files: