KSquare Utilities
KKB::MorphOpMaskExclude Class Reference

#include <MorphOpMaskExclude.h>

+ Inheritance diagram for KKB::MorphOpMaskExclude:

Public Member Functions

 MorphOpMaskExclude (MaskTypes _mask)
 
virtual ~MorphOpMaskExclude ()
 
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 35 of file MorphOpMaskExclude.h.

Constructor & Destructor Documentation

MorphOpMaskExclude::MorphOpMaskExclude ( MaskTypes  _mask)

Definition at line 22 of file MorphOpMaskExclude.cpp.

References KKB::MorphOp::MorphOp().

22  :
23  MorphOp (),
24  mask (_mask)
25 {
26 }
MorphOpMaskExclude::~MorphOpMaskExclude ( )
virtual

Definition at line 30 of file MorphOpMaskExclude.cpp.

31 {
32 }

Member Function Documentation

kkint32 MorphOpMaskExclude::MemoryConsumedEstimated ( )

Definition at line 36 of file MorphOpMaskExclude.cpp.

37 {
38  kkint32 result = sizeof (*this);
39  return result;
40 }
__int32 kkint32
Definition: KKBaseTypes.h:88
virtual OperationType KKB::MorphOpMaskExclude::Operation ( ) const
inlinevirtual
RasterPtr MorphOpMaskExclude::PerformOperation ( RasterConstPtr  _image)
virtual

Definition at line 44 of file MorphOpMaskExclude.cpp.

References KKB::Raster::BlueArea(), KKB::Raster::Dilation(), KKB::Raster::GreenArea(), KKB::Raster::Opening(), KKB::Raster::Raster(), KKB::Raster::RedArea(), KKB::MorphOp::SetSrcRaster(), KKB::MorphOp::srcBlueArea, KKB::MorphOp::srcColor, KKB::MorphOp::srcGreenArea, KKB::MorphOp::srcHeight, KKB::MorphOp::srcRedArea, and KKB::MorphOp::srcWidth.

45 {
46  SetSrcRaster (_image);
47 
48  kkint32 totalPixels = srcHeight * srcWidth;
49 
50  RasterPtr maskImage = new Raster (*_image);
51 
52  maskImage->Opening ((KKB::MaskTypes)mask);
53  //maskImage->ConnectedComponent();
54  maskImage->Dilation ((KKB::MaskTypes)mask);
55 
56  RasterPtr result = new Raster (srcHeight, srcWidth, srcColor);
57 
58  uchar const* srcImageRedPtr = srcRedArea;
59  uchar const* srcImageGreenPtr = srcGreenArea;
60  uchar const* srcImageBluePtr = srcBlueArea;
61 
62  uchar* resultRedPtr = result->RedArea ();
63  uchar* resultGreenPtr = result->GreenArea ();
64  uchar* resultBluePtr = result->BlueArea ();
65 
66  uchar* maskPtr = maskImage->GreenArea ();
67  for (kkint32 x = 0; x < totalPixels; ++x)
68  {
69  if (*maskPtr == 0)
70  {
71  *resultGreenPtr = *srcImageGreenPtr;
72  if (srcColor)
73  {
74  *resultRedPtr = *srcImageRedPtr;
75  *resultBluePtr = *srcImageBluePtr;
76  }
77  }
78  ++maskPtr;
79  ++srcImageGreenPtr;
80  ++resultGreenPtr;
81  if (srcColor)
82  {
83  ++srcImageRedPtr;
84  ++resultRedPtr;
85  ++srcImageBluePtr;
86  ++resultBluePtr;
87  }
88  }
89 
90  delete maskImage;
91  maskImage = NULL;
92 
93  return result;
94 } /* PerformOperation */
void SetSrcRaster(RasterConstPtr _srcRaster)
Definition: MorphOp.cpp:149
void Opening()
Definition: Raster.cpp:2944
__int32 kkint32
Definition: KKBaseTypes.h:88
void Dilation()
Definition: Raster.cpp:1681
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
bool srcColor
Definition: MorphOp.h:122
kkint32 srcHeight
Definition: MorphOp.h:123
kkint32 srcWidth
Definition: MorphOp.h:124
uchar const * srcBlueArea
Definition: MorphOp.h:116
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * RedArea() const
Definition: Raster.h:329
uchar * GreenArea() const
Definition: Raster.h:330
uchar * BlueArea() const
Definition: Raster.h:331
uchar const * srcGreenArea
Definition: MorphOp.h:115
uchar const * srcRedArea
Definition: MorphOp.h:114

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