KSquare Utilities
KKB::MorphOpBinarize Class Reference

#include <MorphOpBinarize.h>

+ Inheritance diagram for KKB::MorphOpBinarize:

Public Member Functions

 MorphOpBinarize (kkuint16 _pixelValueMin, kkuint16 _pixelValueMax)
 
virtual ~MorphOpBinarize ()
 
kkint32 MemoryConsumedEstimated ()
 
virtual OperationType Operation () const
 
virtual RasterPtr PerformOperation (RasterConstPtr _image)
 
- Public Member Functions inherited from KKB::MorphOp
 MorphOp ()
 
virtual ~MorphOp ()
 
OperationType OperationTypeFromStr (const KKB::KKStr &_operationStr)
 
KKB::KKStr OperationTypeToStr (OperationType _operation)
 
virtual RasterPtr PerformOperation (Raster const *_image)=0
 

Additional Inherited Members

- Public Types inherited from KKB::MorphOp
enum  MaskTypes : int {
  MaskTypes::CROSS3 = 0, MaskTypes::CROSS5 = 1, MaskTypes::SQUARE3 = 2, MaskTypes::SQUARE5 = 3,
  MaskTypes::SQUARE7 = 4, MaskTypes::SQUARE9 = 5, MaskTypes::SQUARE11 = 6
}
 
enum  OperationType {
  OperationType::Null, OperationType::Binarize, OperationType::BmiFiltering, OperationType::ConvexHull,
  OperationType::Dilation, OperationType::Erosion, OperationType::MaskExclude, OperationType::SobelEdgeDetection,
  OperationType::Stretcher
}
 
enum  StructureType : int { StructureType::Null, StructureType::stCross, StructureType::stSquare }
 
- Static Public Member Functions inherited from KKB::MorphOp
static kkint32 Biases (MaskTypes mt)
 
static StructureType MaskShapes (MaskTypes mt)
 
- Protected Member Functions inherited from KKB::MorphOp
bool BackgroundPixel (uchar pixel) const
 
bool BackgroundPixel (kkint32 row, kkint32 col) const
 
bool ForegroundPixel (uchar pixel) const
 
bool ForegroundPixel (kkint32 row, kkint32 col) const
 
void SetSrcRaster (RasterConstPtr _srcRaster)
 
- Protected Attributes inherited from KKB::MorphOp
uchar backgroundPixelTH
 
uchar backgroundPixelValue
 
uchar *const * srcBlue
 
uchar const * srcBlueArea
 
bool srcColor
 
uchar *const * srcGreen
 
uchar const * srcGreenArea
 
kkint32 srcHeight
 
RasterConstPtr srcRaster
 
uchar *const * srcRed
 
uchar const * srcRedArea
 
kkint32 srcWidth
 
- Static Protected Attributes inherited from KKB::MorphOp
static kkint32 biases []
 
static StructureType maskShapes []
 

Detailed Description

Definition at line 24 of file MorphOpBinarize.h.

Constructor & Destructor Documentation

MorphOpBinarize::MorphOpBinarize ( kkuint16  _pixelValueMin,
kkuint16  _pixelValueMax 
)

Definition at line 22 of file MorphOpBinarize.cpp.

References KKB::MorphOp::MorphOp().

Referenced by KKB::Raster::BinarizeByThreshold().

24  :
25  MorphOp (),
26  pixelValueMin (_pixelValueMin),
27  pixelValueMax (_pixelValueMax)
28 {
29 }
MorphOpBinarize::~MorphOpBinarize ( )
virtual

Definition at line 33 of file MorphOpBinarize.cpp.

34 {
35 }

Member Function Documentation

kkint32 MorphOpBinarize::MemoryConsumedEstimated ( )

Definition at line 39 of file MorphOpBinarize.cpp.

40 {
41  return sizeof (*this);
42 }
virtual OperationType KKB::MorphOpBinarize::Operation ( ) const
inlinevirtual
RasterPtr MorphOpBinarize::PerformOperation ( RasterConstPtr  _image)
virtual

Definition at line 62 of file MorphOpBinarize.cpp.

References KKB::Raster::BackgroundPixelValue(), KKB::Raster::ForegroundPixelCount(), KKB::Raster::Green(), KKB::Raster::Height(), KKB::Raster::Raster(), KKB::MorphOp::SetSrcRaster(), KKB::MorphOp::srcGreen, KKB::MorphOp::srcHeight, KKB::MorphOp::srcRaster, KKB::MorphOp::srcWidth, and KKB::Raster::Width().

Referenced by KKB::Raster::BinarizeByThreshold().

63 {
64  SetSrcRaster (_image);
65 
66  kkint32 r = 0;
67  kkint32 c = 0;
68 
69  kkint32 binarizedForegroundPixelCount = 0;
70 
71  RasterPtr binarizedRaster = new Raster (srcRaster->Height (), srcRaster->Width ());
72 
73  uchar* srcRow = NULL;
74  uchar** destGreen = binarizedRaster->Green ();
75  uchar* destRow = NULL;
76 
77  uchar backgroundPixelValue = srcRaster->BackgroundPixelValue ();
78 
79  for (r = 0; r < srcHeight; r++)
80  {
81  destRow = destGreen[r];
82  srcRow = srcGreen[r];
83 
84  for (c = 0; c < srcWidth; c++)
85  {
86  uchar srcCh = srcRow[c];
87  if ((srcCh >= pixelValueMin) && (srcCh <= pixelValueMax))
88  {
89  destRow[c] = srcCh;
90  ++binarizedForegroundPixelCount;
91  }
92  else
93  {
94  destRow[c] = backgroundPixelValue;
95  }
96  } /* for (c) */
97  } /* for (r) */
98 
99  binarizedRaster->ForegroundPixelCount (binarizedForegroundPixelCount);
100 
101  return binarizedRaster;
102 } /* PerformOperation */
void SetSrcRaster(RasterConstPtr _srcRaster)
Definition: MorphOp.cpp:149
__int32 kkint32
Definition: KKBaseTypes.h:88
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
kkint32 srcHeight
Definition: MorphOp.h:123
kkint32 srcWidth
Definition: MorphOp.h:124
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
kkint32 ForegroundPixelCount() const
Definition: Raster.h:317
uchar backgroundPixelValue
Definition: MorphOp.h:110
uchar *const * srcGreen
Definition: MorphOp.h:119
RasterConstPtr srcRaster
Definition: MorphOp.h:112
uchar ** Green() const
Definition: Raster.h:327

The documentation for this class was generated from the following files: