Engauge Digitizer  2
GridHealer.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef GRID_HEALER_H
8 #define GRID_HEALER_H
9 
10 #include <QMap>
11 #include <QPointF>
12 #include <QVector>
13 
15 class QImage;
16 
17 enum PixelState {
18  PIXEL_STATE_BACKGROUND,
19  PIXEL_STATE_FOREGROUND,
20  PIXEL_STATE_REMOVED,
21  PIXEL_STATE_ADJACENT,
22  PIXEL_STATE_HEALED,
23  NUM_PIXEL_STATES
24 };
25 
27 typedef int BoundaryGroup;
28 
30 typedef int PixelStateOrBoundaryGroup;
31 
33 typedef QMap<BoundaryGroup, QPointF> GroupNumberToPoint;
34 
38 {
39  public:
41  GridHealer(const QImage &imageBefore,
42  const DocumentModelGridRemoval &modelGridRemoval);
43 
46  void erasePixel (int xCol,
47  int yRow);
48 
50  void heal (QImage &imageToHeal);
51 
52  private:
53  GridHealer();
54 
55  void connectCloseGroups(QImage &imageToHeal);
56  void groupContiguousAdjacentPixels();
57  void recursiveSearchForAdjacentPixels (int boundaryGroup,
58  int row,
59  int col,
60  int &centroidCount,
61  double &rowCentroidSum,
62  double &colCentroidSum);
63 
64  // Mirror of original image
65  QVector<QVector<PixelStateOrBoundaryGroup> > m_pixels;
66 
67  BoundaryGroup m_boundaryGroupNext;
68 
70  GroupNumberToPoint m_groupNumberToCentroid;
71 
73  GroupNumberToPoint m_groupNumberToPixel;
74 
75  DocumentModelGridRemoval m_modelGridRemoval;
76 };
77 
78 #endif // GRID_HEALER_H
void erasePixel(int xCol, int yRow)
Remember that pixel was erased since it belongs to an grid line.
Definition: GridHealer.cpp:96
Class that &#39;heals&#39; the curves after grid lines have been removed.
Definition: GridHealer.h:37
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
void heal(QImage &imageToHeal)
Heal the broken curve lines by spanning the gaps across the newly-removed grid lines.
Definition: GridHealer.cpp:153