28 QPoint p0 = *(itrBelow++);
29 QPoint p1 = *(itrAbove++);
33 m_blackPixelsBelow [p0.y()] = p0.x();
37 m_blackPixelsAbove [p1.y()] = p1.x();
47 GridIndependentToDependent::const_iterator itrBelow, itrAbove;
48 for (itrBelow = m_blackPixelsBelow.begin(); itrBelow != m_blackPixelsBelow.end(); itrBelow++) {
49 QPoint p (itrBelow.value(),
54 for (itrAbove = m_blackPixelsAbove.begin(); itrAbove != m_blackPixelsAbove.end(); itrAbove++) {
55 QPoint p (itrAbove.value(),
62 if (m_blackPixelsBelow.count() > 0 &&
63 m_blackPixelsAbove.count() > 0) {
65 int yFirst = qMin (m_blackPixelsBelow.firstKey (),
66 m_blackPixelsAbove.firstKey ());
67 int yLast = qMax (m_blackPixelsBelow.lastKey (),
68 m_blackPixelsAbove.lastKey ());
72 for (
int yBelowStart = yFirst; yBelowStart <= yLast; yBelowStart++) {
74 if ((yBelowEnd < yBelowStart) &&
75 m_blackPixelsBelow.contains (yBelowStart)) {
78 int yBelowOutOfBounds = yLast + 1;
80 for (yBelowEnd = yBelowStart + 1; yBelowEnd <= yBelowOutOfBounds; yBelowEnd++) {
82 if (!m_blackPixelsBelow.contains (yBelowEnd) || (yBelowEnd == yBelowOutOfBounds)) {
84 doHealingOnBelowRange (image,
98void GridHealerVertical::doHealingOnBelowAndAboveRangePair (QImage &image,
106 int x0 = m_blackPixelsBelow [yBelowStart];
107 int x1 = m_blackPixelsBelow [yBelowEnd ];
108 int x2 = m_blackPixelsAbove [yAboveEnd ];
109 int x3 = m_blackPixelsAbove [yAboveStart];
110 int y0 = yBelowStart;
113 int y3 = yAboveStart;
131void GridHealerVertical::doHealingOnBelowRange (QImage &image,
145 int xAboveOutOfBounds = xBelowEnd + maxHorSep + 1;
149 for (
int xAboveStart = xBelowStart - maxHorSep; xAboveStart <= xAboveOutOfBounds; xAboveStart++) {
151 if ((xAboveEnd < xAboveStart) &&
152 m_blackPixelsAbove.contains (xAboveStart) &&
153 (xAboveStart < xAboveOutOfBounds)) {
155 for (xAboveEnd = xAboveStart + 1; xAboveEnd <= xAboveOutOfBounds; xAboveEnd++) {
157 if (!m_blackPixelsAbove.contains (xAboveEnd) || (xAboveEnd == xAboveOutOfBounds)) {
159 int xBelowStartNearEnough = qMax (xBelowStart, xAboveStart - maxHorSep);
160 int xBelowEndNearEnough = qMin (xBelowEnd - 1, xAboveEnd + maxHorSep);
161 int xAboveEndInclusive = xAboveEnd - 1;
163 if (xBelowStartNearEnough <= xBelowEndNearEnough) {
165 doHealingOnBelowAndAboveRangePair (image,
166 xBelowStartNearEnough,
const double HALFWIDTH_VERTICAL
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval.
DocumentModelGridRemoval & modelGridRemoval()
DocumentModelGridRemoval get method.
bool pointsAreGood(const QImage &image, int x0, int y0, int x1, int y1) const
Apply blackPixelRegionIsBigEnough to regions around each of two points.
const MutualPairHalves & mutualPairHalvesAbove() const
Mutual pair halves for below grid line.
const MutualPairHalves & mutualPairHalvesBelow() const
Mutual pair halves for above grid line.
GridHealerAbstractBase(GridLog &gridLog, const DocumentModelGridRemoval &modelGridRemoval)
Single constructor.
GridLog & gridLog()
Logging get method.
double maxPointSeparation() const
Max point separation get method.
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.
void saveGapSeparation(double gapSeparation)
Gap separation set method.
virtual void doHealingAcrossGaps(QImage &image)
Guts of the algorithm in which sequences of black pixels across the gap from each other are filled in...
GridHealerVertical(GridLog &gridLog, const DocumentModelGridRemoval &modelGridRemoval)
Single constructor.
virtual void applyMutualPairs(const QImage &image)
Apply mutual pair points after all grid removal is done.
Class that does special logging for GridLog and GridRemoval classes.
void showOutputTrapezoid(const QPoint &p0, const QPoint &p1, const QPoint &p2, const QPoint &p3)
Show trapezoids that are intermediate results in GridHealer.
void showInputPixel(const QPoint &p, double halfWidth)
Show pixels that are inputs to GridHealer.
static bool pixelIsBlack(const QImage &image, int x, int y)
Return true if pixel is black in black and white image.