28 QPoint p0 = *(itrBelow++);
29 QPoint p1 = *(itrAbove++);
33 m_blackPixelsBelow [p0.x()] = p0.y();
37 m_blackPixelsAbove [p1.x()] = p1.y();
47 GridIndependentToDependent::const_iterator itrBelow, itrAbove;
48 for (itrBelow = m_blackPixelsBelow.begin(); itrBelow != m_blackPixelsBelow.end(); itrBelow++) {
49 QPoint p (itrBelow.key(),
54 for (itrAbove = m_blackPixelsAbove.begin(); itrAbove != m_blackPixelsAbove.end(); itrAbove++) {
55 QPoint p (itrAbove.key(),
62 if (m_blackPixelsBelow.count() > 0 &&
63 m_blackPixelsAbove.count() > 0) {
65 int xFirst = qMin (m_blackPixelsBelow.firstKey (),
66 m_blackPixelsAbove.firstKey ());
67 int xLast = qMax (m_blackPixelsBelow.lastKey (),
68 m_blackPixelsAbove.lastKey ());
72 for (
int xBelowStart = xFirst; xBelowStart <= xLast; xBelowStart++) {
74 if ((xBelowEnd < xBelowStart) &&
75 m_blackPixelsBelow.contains (xBelowStart)) {
78 int xBelowOutOfBounds = xLast + 1;
80 for (xBelowEnd = xBelowStart + 1; xBelowEnd <= xBelowOutOfBounds; xBelowEnd++) {
82 if (!m_blackPixelsBelow.contains (xBelowEnd) || (xBelowEnd == xBelowOutOfBounds)) {
84 doHealingOnBelowRange (image,
98void GridHealerHorizontal::doHealingOnBelowAndAboveRangePair (QImage &image,
106 int x0 = xBelowStart;
109 int x3 = xAboveStart;
110 int y0 = m_blackPixelsBelow [xBelowStart];
111 int y1 = m_blackPixelsBelow [xBelowEnd ];
112 int y2 = m_blackPixelsAbove [xAboveEnd ];
113 int y3 = m_blackPixelsAbove [xAboveStart];
131void GridHealerHorizontal::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_HORIZONTAL
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.
GridHealerHorizontal(GridLog &gridLog, const DocumentModelGridRemoval &modelGridRemoval)
Single constructor.
virtual void doHealingAcrossGaps(QImage &image)
Guts of the algorithm in which sequences of black pixels across the gap from each other are filled in...
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.