KSquare Utilities
ContourFollower.h
Go to the documentation of this file.
1 /* ContourFollower.h -- Used to find the contour of image in a Raster object.
2  * Copyright (C) 1994-2011 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _CONTOURFOLLOWER_
6 #define _CONTOURFOLLOWER_
7 
8 #include <complex>
9 #include "KKBaseTypes.h"
10 #include "RunLog.h"
11 
12 namespace KKB
13 {
14  #ifndef _POINT_
15  class Point;
16  typedef Point* PointPtr;
17  class PointList;
18  typedef PointList* PointListPtr;
19  #endif
20 
21 
22 
23  #ifndef _RASTER_
24  class Raster;
25  typedef Raster* RasterPtr;
26  #endif
27 
28 
29  typedef std::complex<double> ComplexDouble;
30 
31 
33  {
34  public:
35  ContourFollower (Raster& _raster,
36  RunLog& _log
37  );
38 
40 
41  PointListPtr CreatePointListFromFourier (std::vector<ComplexDouble> fourier,
42  PointList& origPointList
43  );
44 
45  PointListPtr GenerateContourList ();
46 
47  kkint32 FollowContour (float* countourFreq,
48  float fourierDescriptors[15],
49  kkint32 totalPixels,
50  bool& successful
51  );
52 
53  kkint32 FollowContour2 (float* countourFreq,
54  bool& successful
55  );
56 
58  float* countourFreq,
59  bool& successful
60  );
61 
62  void HistogramDistanceFromAPointOfEdge (float pointRow,
63  float pointCol,
64  kkint32 numOfBuckets,
65  kkint32* buckets,
66  float& minDistance,
67  float& maxDistance,
68  kkint32& numOfEdgePixels
69  );
70 
71 
72  private:
73 
74  void GetFirstPixel (kkint32& row,
75  kkint32& col
76  );
77 
78  void GetNextPixel (kkint32& row,
79  kkint32& col
80  );
81 
82  kkint32 PixelCountIn9PixelNeighborhood (kkint32 row,
83  kkint32 col
84  );
85 
86  uchar PixelValue (kkint32 row,
87  kkint32 col
88  );
89 
90  uchar backgroundPixelTH; /**< Will come from the raster instance that we are processing. */
91  kkint32 curCol;
92  kkint32 curRow;
93  kkint32 fromDir;
94  kkint32 height;
95  kkint32 lastDir;
96  RunLog& log;
97  Raster& raster;
98  uchar** rows;
99  kkint32 width;
100  }; /* ContourFollower*/
101 
102 } /* namespace KKB; */
103 
104 #endif
kkint32 FollowContour2(float *countourFreq, bool &successful)
__int32 kkint32
Definition: KKBaseTypes.h:88
std::vector< ComplexDouble > CreateFourierFromPointList(const PointList &points)
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
kkint32 CreateFourierDescriptorBySampling(kkint32 numOfBuckets, float *countourFreq, bool &successful)
Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image...
Definition: Point.h:20
std::complex< double > ComplexDouble
KKTHread * KKTHreadPtr
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
void HistogramDistanceFromAPointOfEdge(float pointRow, float pointCol, kkint32 numOfBuckets, kkint32 *buckets, float &minDistance, float &maxDistance, kkint32 &numOfEdgePixels)
ContourFollower(Raster &_raster, RunLog &_log)
Used for logging messages.
Definition: RunLog.h:49
Container object used to maintaining a list of pixel locations.
Definition: Point.h:75
kkint32 FollowContour(float *countourFreq, float fourierDescriptors[15], kkint32 totalPixels, bool &successful)
PointListPtr GenerateContourList()
PointListPtr CreatePointListFromFourier(std::vector< ComplexDouble > fourier, PointList &origPointList)