KSquare Utilities
KKB::MorphOpDilation Class Reference

#include <MorphOpDilation.h>

+ Inheritance diagram for KKB::MorphOpDilation:

Public Member Functions

 MorphOpDilation (StructureType _structure, kkuint16 _structureSize)
 
virtual ~MorphOpDilation ()
 
kkint32 MemoryConsumedEstimated ()
 
virtual OperationType Operation () const
 
virtual RasterPtr PerformOperation (RasterConstPtr _image)
 
- Public Member Functions inherited from KKB::MorphOpStruct
 MorphOpStruct (StructureType _structure, kkuint16 _structureSize)
 
virtual ~MorphOpStruct ()
 
void BackgroundCountTH (kkint32 _backgroundCountTH)
 
void ForegroundCountTH (kkint32 _foregroundCountTH)
 
kkint32 MemoryConsumedEstimated ()
 
- 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::MorphOpStruct
bool Fit (kkint32 row, kkint32 col) const
 
bool FitBackgroundCount (kkint32 row, kkint32 col) const
 
uchar HitForegroundCount (kkint32 row, kkint32 col) const
 
- 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::MorphOpStruct
kkint32 backgroundCountTH
 
kkint32 foregroundCountTH
 
StructureType structure
 
kkuint16 structureSize
 
- 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 MorphOpDilation.h.

Constructor & Destructor Documentation

MorphOpDilation::MorphOpDilation ( StructureType  _structure,
kkuint16  _structureSize 
)

Definition at line 22 of file MorphOpDilation.cpp.

References KKB::MorphOpStruct::MorphOpStruct().

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

24  :
25  MorphOpStruct (_structure, _structureSize)
26 {
27 }
MorphOpStruct(StructureType _structure, kkuint16 _structureSize)
MorphOpDilation::~MorphOpDilation ( )
virtual

Definition at line 31 of file MorphOpDilation.cpp.

32 {
33 }

Member Function Documentation

kkint32 MorphOpDilation::MemoryConsumedEstimated ( )

Definition at line 37 of file MorphOpDilation.cpp.

38 {
39  return sizeof (*this);
40 }
virtual OperationType KKB::MorphOpDilation::Operation ( ) const
inlinevirtual

Reimplemented from KKB::MorphOpStruct.

Definition at line 33 of file MorphOpDilation.h.

References KKB::MorphOp::Dilation.

RasterPtr MorphOpDilation::PerformOperation ( RasterConstPtr  _image)
virtual

Implements KKB::MorphOpStruct.

Definition at line 45 of file MorphOpDilation.cpp.

References KKB::MorphOp::BackgroundPixel(), KKB::MorphOp::ForegroundPixel(), KKB::Raster::ForegroundPixelCount(), KKB::Raster::Green(), KKB::MorphOpStruct::HitForegroundCount(), KKB::Raster::Raster(), KKB::MorphOp::SetSrcRaster(), KKB::MorphOp::srcGreen, KKB::MorphOp::srcHeight, KKB::MorphOp::srcRaster, and KKB::MorphOp::srcWidth.

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

46 {
47  this->SetSrcRaster (_image);
48 
49  kkint32 r = 0;
50  kkint32 c = 0;
51 
52  kkint32 erodedForegroundPixelCount = srcRaster->ForegroundPixelCount ();
53 
54  RasterPtr resultRaster = new Raster (*srcRaster);
55 
56  uchar* srcRow = NULL;
57  uchar** destGreen = resultRaster->Green ();
58  uchar* destRow = NULL;
59 
60  kkint32 forgroundPixelCount = srcRaster->ForegroundPixelCount ();
61 
62  for (r = 0; r < srcHeight; r++)
63  {
64  destRow = destGreen[r];
65  srcRow = srcGreen[r];
66 
67  for (c = 0; c < srcWidth; c++)
68  {
69  if (BackgroundPixel (srcRow[c]))
70  {
71  uchar pixel = HitForegroundCount (r, c);
72  if (ForegroundPixel (pixel))
73  ++forgroundPixelCount;
74  destRow[c] = pixel;
75  }
76  } /* for (c) */
77  } /* for (r) */
78 
79  resultRaster->ForegroundPixelCount (forgroundPixelCount);
80 
81  return resultRaster;
82 } /* 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
bool BackgroundPixel(uchar pixel) const
Definition: MorphOp.cpp:171
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 *const * srcGreen
Definition: MorphOp.h:119
RasterConstPtr srcRaster
Definition: MorphOp.h:112
bool ForegroundPixel(uchar pixel) const
Definition: MorphOp.cpp:195
uchar ** Green() const
Definition: Raster.h:327
uchar HitForegroundCount(kkint32 row, kkint32 col) const

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