KSquare Utilities
GrayScaleImagesFVProducer.h
Go to the documentation of this file.
1 #if !defined(_GRAYSCALEIMAGESFVPRODUCER_)
2 #define _GRAYSCALEIMAGESFVPRODUCER_
3 
4 #include "KKBaseTypes.h"
5 #include "Raster.h"
6 #include "RunLog.h"
7 using namespace KKB;
8 
10 #include "FeatureVector.h"
12 using namespace KKMLL;
13 
14 
15 #define _GrayScaleImagesFVProducer_VersionNum_ 10
16 
17 namespace KKMLL
18 {
20  {
21  public:
22  GrayScaleImagesFVProducer (FactoryFVProducerPtr factory);
23 
24  virtual ~GrayScaleImagesFVProducer ();
25 
26 
27  virtual FeatureVectorPtr ComputeFeatureVector (const Raster& srcImage,
28  const MLClassPtr knownClass,
29  RasterListPtr intermediateImages,
30  float priorReductionFactor,
31  RunLog& runLog
32  );
33 
34  static FileDescPtr DefineFileDescStatic ();
35 
36  /**
37  *@brief Returns the 'type_info' of the Feature Vector that this instance of 'FeatureComputer' creates.
38  */
39  virtual const type_info* FeatureVectorTypeId () const;
40 
41  virtual const type_info* FeatureVectorListTypeId () const;
42 
43 
44  virtual FeatureVectorListPtr ManufacturFeatureVectorList (bool owner,
45  RunLog& runLog
46  )
47  const;
48 
50 
51  static kkint32 MaxNumOfFeatures () {return maxNumOfFeatures;}
52 
53  protected:
54  virtual FileDescPtr DefineFileDesc () const;
55 
56 
57  private:
58  void BinarizeImageByThreshold (uchar lower,
59  uchar upper,
60  const Raster& src,
61  Raster& dest
62  );
63 
64  void ReductionByMultiple (kkint32 multiple,
65  const Raster& srcRaster,
66  Raster& destRaster
67  );
68 
69  void SaveIntermediateImage (const Raster& raster,
70  const KKStr& desc,
71  RasterListPtr intermediateImages
72  );
73 
74  uchar* workRaster1Area;
75  uchar* workRaster2Area;
76  uchar* workRaster3Area;
77  uchar** workRaster1Rows;
78  uchar** workRaster2Rows;
79  uchar** workRaster3Rows;
80 
81 
82  kkint32 totPixsForMorphOps; /**< When this instance is created this is the amount of memory each
83  * raster work area will be restricted to. The Height and width will
84  * be adjusted such that the resultant dimensions will fit within this
85  * constraint.
86  */
87 
88  static kkint16 maxNumOfFeatures;
89  static const kkint32 SizeThreshold;
90 
91  static const KKStr featureNames[];
92 
93  static kkint16 SizeIndex; // 0;
94  static kkint16 Moment1Index; // 1;
95  static kkint16 Moment2Index; // 2;
96  static kkint16 Moment3Index; // 3;
97  static kkint16 Moment4Index; // 4;
98  static kkint16 Moment5Index; // 5;
99  static kkint16 Moment6Index; // 6;
100  static kkint16 Moment7Index; // 7;
101  static kkint16 Moment8Index; // 8;
102 
103  static kkint16 EdgeSizeIndex; // 9;
104  static kkint16 EdgeMoment1Index; // 10;
105  static kkint16 EdgeMoment2Index; // 11;
106  static kkint16 EdgeMoment3Index; // 12;
107  static kkint16 EdgeMoment4Index; // 13;
108  static kkint16 EdgeMoment5Index; // 14;
109  static kkint16 EdgeMoment6Index; // 15;
110  static kkint16 EdgeMoment7Index; // 16;
111  static kkint16 EdgeMoment8Index; // 17;
112 
113  static kkint16 TransparancyConvexHullIndex; // 18;
114  static kkint16 TransparancyPixelCountIndex; // 19;
115  static kkint16 TransparancyOpen3Index; // 20;
116  static kkint16 TransparancyOpen5Index; // 21;
117  static kkint16 TransparancyOpen7Index; // 22;
118  static kkint16 TransparancyOpen9Index; // 23;
119  static kkint16 TransparancyClose3Index; // 24;
120  static kkint16 TransparancyClose5Index; // 25;
121  static kkint16 TransparancyClose7Index; // 26;
122 
123  static kkint16 ConvexAreaIndex; // 27
124  static kkint16 TransparancySizeIndex; // 28
125  static kkint16 TransparancyWtdIndex; // 29
126 
127  static kkint16 WeighedMoment0Index; // 30
128  static kkint16 WeighedMoment1Index; // 31
129  static kkint16 WeighedMoment2Index; // 32
130  static kkint16 WeighedMoment3Index; // 33
131  static kkint16 WeighedMoment4Index; // 34
132  static kkint16 WeighedMoment5Index; // 35
133  static kkint16 WeighedMoment6Index; // 36
134  static kkint16 WeighedMoment7Index; // 37
135  static kkint16 WeighedMoment8Index; // 38
136 
137  static kkint16 IntensityHist1Index; // 39
138  static kkint16 IntensityHist2Index; // 40
139  static kkint16 IntensityHist3Index; // 41
140  static kkint16 IntensityHist4Index; // 42
141  static kkint16 IntensityHist5Index; // 43
142  static kkint16 IntensityHist6Index; // 44
143  static kkint16 IntensityHist7Index; // 45
144  static kkint16 DarkSpotCount0; // 46
145  static kkint16 DarkSpotCount1; // 47
146  static kkint16 DarkSpotCount2; // 48
147  static kkint16 DarkSpotCount3; // 49
148  static kkint16 DarkSpotCount4; // 50
149  static kkint16 DarkSpotCount5; // 51
150  static kkint16 DarkSpotCount6; // 52
151  static kkint16 DarkSpotCount7; // 53
152  static kkint16 DarkSpotCount8; // 54
153  static kkint16 DarkSpotCount9; // 55
154 
155  static FileDescPtr existingFileDesc;
156 
157 
158  }; /* GrayScaleImagesFVProducer */
159 
161 
162 #define _GrayScaleImagesFVProducer_Defined_
163 
164 
165 
167  {
168  typedef GrayScaleImagesFVProducerFactory* GrayScaleImagesFVProducerFactoryPtr;
169 
170  GrayScaleImagesFVProducerFactory ();
171 
172  protected:
173  /**
174  *@brief A Factory can never be deleted until the application terminates; the atexit method will perform the deletes.
175  */
177 
178  public:
179 
180  virtual FeatureFileIOPtr DefaultFeatureFileIO () const;
181 
182  virtual const type_info* FeatureVectorTypeId () const;
183 
184  virtual const type_info* FeatureVectorListTypeId () const;
185 
186  virtual FileDescPtr FileDesc () const;
187 
189 
190 
191  /**
192  *@brief Manufactures a instance of a 'LarcosFeatureVectorList' class that will own its contents.
193  */
194  virtual FeatureVectorListPtr ManufacturFeatureVectorList (bool owner,
195  RunLog& runLog
196  )
197  const;
198 
199  /**
200  *@brief Returns instance of "GrayScaleImagesFVProducerFactory" that is registered with "FactoryFVProducer::RegisterFactory".
201  *@details If instance does not exist yet out will create an instance and register it.
202  */
204 
205 
206  private:
207  /**
208  *@brief This instance of 'GrayScaleImagesFVProducerFactory' will be registered with "FactoryFVProducer::RegisterFactory".
209  *@details It will deleted by the "FactoryFVProducer::FinaleCleanUp" upon application shutdown.
210  */
211  static GrayScaleImagesFVProducerFactory* factory;
212 
213  }; /* GrayScaleImagesFVProducerFactory */
214 
215 #define _GrayScaleImagesFVProducerFactory_Defined_
216 
217 
218 } /* KKMLL */
219 
220 
221 #endif
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
virtual ~GrayScaleImagesFVProducerFactory()
A Factory can never be deleted until the application terminates; the atexit method will perform the d...
MLClass * MLClassPtr
Definition: MLClass.h:46
__int32 kkint32
Definition: KKBaseTypes.h:88
virtual const type_info * FeatureVectorTypeId() const
Returns the &#39;type_info&#39; of the Feature Vector that this instance of &#39;FeatureComputer&#39; creates...
virtual GrayScaleImagesFVProducerPtr ManufactureInstance(RunLog &runLog)
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
GrayScaleImagesFVProducer(FactoryFVProducerPtr factory)
virtual FeatureVectorListPtr ManufacturFeatureVectorList(bool owner, RunLog &runLog) const
Manufactures a instance of a derived &#39;FeatureVectorList&#39; class that is appropriate for containing ins...
#define _GrayScaleImagesFVProducer_VersionNum_
virtual FeatureVectorListPtr ManufacturFeatureVectorList(bool owner, RunLog &runLog) const
Manufactures a instance of a &#39;LarcosFeatureVectorList&#39; class that will own its contents.
KKTHread * KKTHreadPtr
RasterList * RasterListPtr
Definition: Raster.h:75
virtual const type_info * FeatureVectorListTypeId() const
Returns the &#39;type_info&#39; of the FeatureVectorList that this instance of &#39;FactoryFVProducer&#39; will creat...
virtual const type_info * FeatureVectorTypeId() const
Returns the &#39;type_info&#39; of the FeatureVector that this instance of &#39;FactoryFVProducer&#39; works with...
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
GrayScaleImagesFVProducer * GrayScaleImagesFVProducerPtr
virtual FeatureFileIOPtr DefaultFeatureFileIO() const
virtual FeatureVectorPtr ComputeFeatureVector(const Raster &srcImage, const MLClassPtr knownClass, RasterListPtr intermediateImages, float priorReductionFactor, RunLog &runLog)
Compute a FeatureVector for the supplied &#39;image&#39;.
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
virtual FileDescPtr DefineFileDesc() const
Responsible for creating a FeatureFectorProducer instance.
static GrayScaleImagesFVProducerFactory * Factory(RunLog *runLog)
Returns instance of "GrayScaleImagesFVProducerFactory" that is registered with "FactoryFVProducer::Re...
A abstract class that is meant to compute a FeatureVector from a source image.
virtual const type_info * FeatureVectorListTypeId() const
Returns the &#39;type_info&#39; of the FeatureVectorList derived class that can contain instances in &#39;Feature...