KSquare Utilities
FlatFieldCorrection.h
Go to the documentation of this file.
1 /* FlatFieldCorrection.h --
2  * Copyright (C) 2011-2013 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in LarcosCounterUnManaged.txt
4  */
5 #if !defined(_FLATFIELDCORRECTION_)
6 #define _FLATFIELDCORRECTION_
7 
8 #include "KKBaseTypes.h"
9 #include "GoalKeeper.h"
10 #include "KKQueue.h"
11 #include "Raster.h"
12 #include "RunLog.h"
13 
14 
15 namespace KKLSC
16 {
17  /**
18  *@details It is assumed that sample data provided via 'AddSampleLine' will be the data from a camera
19  * such that 255 is background and 0 is foreground. The data that will result from 'ApplyFlatFieldCorrection'
20  * will have 0 as foreground and 255 as background.
21  */
23  {
24  public:
25  FlatFieldCorrection (kkint32 _numSampleLines,
26  kkint32 _lineWidth,
27  const uchar* _compensationTable
28  );
29 
31 
32  bool Enabled () const {return enabled;}
33  kkint32 LineWidth () const {return lineWidth;}
34  kkint32 NumSampleLines () const {return numSampleLines;}
35  kkint32 NumSampleLinesAdded () const {return numSampleLinesAdded;}
36 
37  void CompensationTable (const uchar* _compensationTable);
38 
39  void Enabled (bool _enabled) {enabled = _enabled;}
40 
41 
42  /**
43  *@brief Provide sample of one scan line as from the camera; where 0 = foreground and 255 = background.
44  */
45  void AddSampleLine (const uchar* sampleLine);
46 
47  void ApplyFlatFieldCorrection (uchar* scanLine);
48 
49  void ApplyFlatFieldCorrection (uchar* srcScanLine,
50  uchar* destScanLine
51  );
52 
54 
55  /**
56  *@brief Will return the high point for each pixel from the last 'n' sample lines taken.
57  *@param[in] n The number of Sample lines to locate high point; ex: n = 2 means check the last two sample lines.
58  */
60 
61  const uchar** LookUpTable (uchar**& lookUpTable);
62 
63  private:
64  void ReComputeLookUpForColumn (kkint32 col);
65 
66  const uchar* compensationTable; /**< From ScannerFile::ConpensationTable(); used to compensate for the effects of ScannerFile compression. */
67 
68  bool enabled; /**< When set to 'true' will apply flat field correction otherwise ignore. */
69  uchar* highPoint; /**< Highest pixel value in history for the respective column. */
70  kkint32* highPointLastSeen; /**< The number of Samplings since high point was last seen. */
71  uchar** history; /**< 2D array (_numSampleLines x _lineWidth); each row represents a scan-line. */
72  kkint32 lastHistoryIdxAdded; /**< Index of last history line to be added by 'AddSampleLine' */
73  kkint32 lineWidth;
74  uchar** lookUpTable; /**< 2D array (lineWidth x 256) lookup table for each scan-line pixel location. *
75  * Each column will be the look up table for the respective scan line pixel. *
76  * Every time a new high point s seen for a pixel location that column will get *
77  * recomputed. *
78  */
79  kkint32 numSampleLines; /* Number of history scan lines that are to be kept. */
80  kkint32 numSampleLinesAdded; /* Total number of sample lines kept. */
81  kkint32* totalLine;
82  };
83 
85 
86 } /* FlatFieldCorrection */
87 
88 #endif
void ApplyFlatFieldCorrection(uchar *scanLine)
__int32 kkint32
Definition: KKBaseTypes.h:88
FlatFieldCorrection(kkint32 _numSampleLines, kkint32 _lineWidth, const uchar *_compensationTable)
void CompensationTable(const uchar *_compensationTable)
VectorUcharPtr CameraHighPoints() const
void AddSampleLine(const uchar *sampleLine)
Provide sample of one scan line as from the camera; where 0 = foreground and 255 = background...
const uchar ** LookUpTable(uchar **&lookUpTable)
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
Contains Classes that are specific to Cameras physical characteristics.
VectorUchar * VectorUcharPtr
Definition: KKBaseTypes.h:152
kkint32 NumSampleLinesAdded() const
FlatFieldCorrection * FlatFieldCorrectionPtr
VectorUcharPtr CameraHighPointsFromLastNSampleLines(kkint32 n) const
Will return the high point for each pixel from the last &#39;n&#39; sample lines taken.
void ApplyFlatFieldCorrection(uchar *srcScanLine, uchar *destScanLine)