00001
00002
00003
00004
00005
00006
00007 #ifndef GRID_HEALER_H
00008 #define GRID_HEALER_H
00009
00010 #include <QMap>
00011 #include <QPointF>
00012 #include <QVector>
00013
00014 class DocumentModelGridRemoval;
00015 class QImage;
00016
00017 enum PixelState {
00018 PIXEL_STATE_BACKGROUND,
00019 PIXEL_STATE_FOREGROUND,
00020 PIXEL_STATE_REMOVED,
00021 PIXEL_STATE_ADJACENT,
00022 PIXEL_STATE_HEALED,
00023 NUM_PIXEL_STATES
00024 };
00025
00027 typedef int BoundaryGroup;
00028
00030 typedef int PixelStateOrBoundaryGroup;
00031
00033 typedef QMap<BoundaryGroup, QPointF> GroupNumberToPoint;
00034
00037 class GridHealer
00038 {
00039 public:
00041 GridHealer(const QImage &imageBefore,
00042 const DocumentModelGridRemoval &modelGridRemoval);
00043
00046 void erasePixel (int xCol,
00047 int yRow);
00048
00050 void heal (QImage &imageToHeal);
00051
00052 private:
00053 GridHealer();
00054
00055 void connectCloseGroups(QImage &imageToHeal);
00056 void groupContiguousAdjacentPixels();
00057 void recursiveSearchForAdjacentPixels (int boundaryGroup,
00058 int row,
00059 int col,
00060 int ¢roidCount,
00061 double &rowCentroidSum,
00062 double &colCentroidSum);
00063
00064
00065 QVector<QVector<PixelStateOrBoundaryGroup> > m_pixels;
00066
00067 BoundaryGroup m_boundaryGroupNext;
00068
00070 GroupNumberToPoint m_groupNumberToCentroid;
00071
00073 GroupNumberToPoint m_groupNumberToPixel;
00074
00075 DocumentModelGridRemoval m_modelGridRemoval;
00076 };
00077
00078 #endif // GRID_HEALER_H