Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
iimg::CScanlineMask Class Reference

Representation of a 2D-region as container of bitmap line scans. More...

#include <CScanlineMask.h>

Inheritance diagram for iimg::CScanlineMask:
i2d::CObject2dBase iimg::IRasterImage i2d::IObject2d i2d::IObject2d iser::IObject i2d::ICalibrationProvider iser::IObject i2d::ICalibrationProvider iser::ISerializable istd::IChangeable iser::ISerializable istd::IChangeable istd::IChangeable istd::IPolymorphic istd::IChangeable istd::IPolymorphic istd::IPolymorphic istd::IPolymorphic

Public Types

typedef i2d::CObject2dBase BaseClass
 
typedef QList< istd::CIntRangesRangesContainer
 
typedef std::vector< int > Scanlines
 
- Public Types inherited from i2d::IObject2d
enum  ChangeFlags { CF_OBJECT_POSITION = 0x6ba340 }
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0, CF_ALL_DATA, CF_ANY, CF_DESTROYING,
  CF_DELEGATED, CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0, SO_OBSERVE = 1 << 0, SO_COPY = 1 << 1, SO_CLONE = 1 << 2,
  SO_COMPARE = 1 << 3, SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT, CM_WITHOUT_REFS, CM_WITH_REFS, CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 

Public Member Functions

 CScanlineMask ()
 
bool IsBitmapRegionEmpty () const
 Check if region is empty. More...
 
i2d::CRect GetBoundingRect () const
 Get rectangle containing all active pixels. More...
 
void ResetScanlines (const istd::CIntRange &verticalRange)
 Set this mask to empty set for some vertical range. More...
 
const istd::CIntRangesGetPixelRanges (int lineIndex) const
 Get the list of pixel ranges per given line. More...
 
void CreateFilled (const i2d::CRect &clipArea)
 Create filled 2D-region clipped to rectangle area. More...
 
bool CreateFromGeometry (const i2d::IObject2d &geometry, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from some geometrical object. More...
 
void CreateFromCircle (const i2d::CCircle &circle, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from circle. More...
 
void CreateFromRectangle (const i2d::CRectangle &rect, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from rectangle. More...
 
void CreateFromAnnulus (const i2d::CAnnulus &annulus, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from annulus. More...
 
void CreateFromPolygon (const i2d::CPolygon &polygon, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from polygon. More...
 
void CreateFromTube (const i2d::CTubePolyline &tube, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from tube. More...
 
void CreateFromBitmap (const iimg::IBitmap &bitmap, const i2d::CRect *clipAreaPtr=NULL)
 Create 2D-region from a bitmap. More...
 
void GetInverted (const i2d::CRect &clipArea, CScanlineMask &result) const
 Get inverted mask. More...
 
void Invert (const i2d::CRect &clipArea)
 Invert mask on place. More...
 
CScanlineMask GetUnion (const CScanlineMask &mask) const
 Get union of two masks. More...
 
void GetUnion (const CScanlineMask &mask, CScanlineMask &result) const
 Get union of two masks. More...
 
void Union (const CScanlineMask &mask)
 Calculate union of this mask and the other one. More...
 
CScanlineMask GetIntersection (const CScanlineMask &mask) const
 Get intersection of two masks. More...
 
void GetIntersection (const CScanlineMask &mask, CScanlineMask &result) const
 Get intersection of two masks. More...
 
void Intersection (const CScanlineMask &mask)
 Calculate intersection of this mask and the other one. More...
 
CScanlineMask GetTranslated (int dx, int dy) const
 Calculate translated (moved) mask. More...
 
void GetTranslated (int dx, int dy, CScanlineMask &result) const
 Calculate translated (moved) mask. More...
 
void Translate (int dx, int dy)
 Translated (move) this mask. More...
 
void Erode (int leftValue, int rightValue, int topValue, int bottomValue)
 Calculate erosion of this range list with rectangle structured element. More...
 
void Dilate (int leftValue, int rightValue, int topValue, int bottomValue)
 Calculate dilatation of this range list with rectangle structured element. More...
 
virtual i2d::CVector2d GetCenter () const
 Returns center of this 2D-object. More...
 
virtual void MoveCenterTo (const i2d::CVector2d &position)
 Move object to position position. More...
 
virtual i2d::CRectangle GetBoundingBox () const
 Get bounding box of this shape. More...
 
virtual bool IsEmpty () const
 Return true if this image is empty. More...
 
virtual void ResetImage ()
 Reset this image. More...
 
virtual void ClearImage ()
 Cleat this image. More...
 
virtual istd::CIndex2d GetImageSize () const
 Get size of this raster image. More...
 
virtual int GetComponentsCount () const
 Get number of color components. More...
 
virtual icmm::CVarColor GetColorAt (const istd::CIndex2d &position) const
 Get color at specified pixel. More...
 
virtual bool SetColorAt (const istd::CIndex2d &position, const icmm::CVarColor &color)
 Set color at specified pixel. More...
 
virtual bool Serialize (iser::IArchive &archive)
 Load or store state of this object as a archive stream. More...
 
virtual int GetSupportedOperations () const
 Get set of flags for supported operations. More...
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one. More...
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state. More...
 
bool operator== (const CScanlineMask &mask) const
 
bool operator!= (const CScanlineMask &mask) const
 
- Public Member Functions inherited from i2d::CObject2dBase
 CObject2dBase ()
 
 CObject2dBase (const CObject2dBase &object2d)
 
virtual const ICalibration2dGetCalibration () const
 Get access to transformation object, which transforms a local logical coordinate system to global one. More...
 
virtual void SetCalibration (const ICalibration2d *calibrationPtr, bool releaseFlag=false)
 Set calibration of this object. More...
 
virtual bool Transform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
 Transform this object using some transformation. More...
 
virtual bool InvTransform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
 Do inverse transformation of this object. More...
 
virtual bool GetTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
 Calulate transformation of the object into second one. More...
 
virtual bool GetInvTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
 Calulate inverse transformation of the object into second one. More...
 
- Public Member Functions inherited from iser::IObject
virtual QByteArray GetFactoryId () const
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data. More...
 
- Public Member Functions inherited from istd::IChangeable
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object. More...
 
virtual IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object. More...
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction. More...
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction. More...
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes. More...
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes. More...
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Member Functions

void EnsureBoundingBoxValid () const
 
void CalcBoundingBox () const
 
void InitFromBoundingBox (const i2d::CRectangle &objectBoundingBox, const i2d::CRect *clipAreaPtr)
 
template<typename PixelType >
void CalculateMaskFromBitmap (const iimg::IBitmap &bitmap, const i2d::CRect *clipAreaPtr=NULL)
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event. More...
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event. More...
 

Friends

uint qHash (const CScanlineMask &key, uint seed)
 

Additional Inherited Members

- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes. More...
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set. More...
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set. More...
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set. More...
 
- Static Protected Attributes inherited from i2d::CObject2dBase
static const ChangeSet s_objectMovedChange
 
static const ChangeSet s_objectModifiedChange
 

Detailed Description

Representation of a 2D-region as container of bitmap line scans.

Definition at line 29 of file CScanlineMask.h.

Member Typedef Documentation

Definition at line 34 of file CScanlineMask.h.

Definition at line 35 of file CScanlineMask.h.

typedef std::vector<int> iimg::CScanlineMask::Scanlines

Definition at line 36 of file CScanlineMask.h.

Constructor & Destructor Documentation

iimg::CScanlineMask::CScanlineMask ( )

Member Function Documentation

void iimg::CScanlineMask::CalcBoundingBox ( ) const
protected

Referenced by EnsureBoundingBoxValid().

template<typename PixelType >
void iimg::CScanlineMask::CalculateMaskFromBitmap ( const iimg::IBitmap bitmap,
const i2d::CRect clipAreaPtr = NULL 
)
protected
virtual void iimg::CScanlineMask::ClearImage ( )
virtual

Cleat this image.

After this operation all the image pixels will be set to the default value (black by default).

Implements iimg::IRasterImage.

virtual bool iimg::CScanlineMask::CopyFrom ( const istd::IChangeable object,
CompatibilityMode  mode = CM_WITHOUT_REFS 
)
virtual

Copy this object from another one.

Default implementation in istd::IChangeable does nothing.

Reimplemented from i2d::CObject2dBase.

void iimg::CScanlineMask::CreateFilled ( const i2d::CRect clipArea)

Create filled 2D-region clipped to rectangle area.

Parameters
clipAreaclipping area.
void iimg::CScanlineMask::CreateFromAnnulus ( const i2d::CAnnulus annulus,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from annulus.

Parameters
annulusannulus object.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::CreateFromBitmap ( const iimg::IBitmap bitmap,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from a bitmap.

Parameters
bitmapMask bitmap. Non-zero pixels of the image represent the object in the resulting mask.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::CreateFromCircle ( const i2d::CCircle circle,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from circle.

Parameters
circlecircle object.
clipAreaPtroptional clipping area.
bool iimg::CScanlineMask::CreateFromGeometry ( const i2d::IObject2d geometry,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from some geometrical object.

Parameters
geometrysome geometrical object.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::CreateFromPolygon ( const i2d::CPolygon polygon,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from polygon.

Parameters
polygonpolygon object.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::CreateFromRectangle ( const i2d::CRectangle rect,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from rectangle.

Parameters
rectrectangle object.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::CreateFromTube ( const i2d::CTubePolyline tube,
const i2d::CRect clipAreaPtr = NULL 
)

Create 2D-region from tube.

Parameters
tubetube object.
clipAreaPtroptional clipping area.
void iimg::CScanlineMask::Dilate ( int  leftValue,
int  rightValue,
int  topValue,
int  bottomValue 
)

Calculate dilatation of this range list with rectangle structured element.

Result is stored in this object.

void iimg::CScanlineMask::EnsureBoundingBoxValid ( ) const
inlineprotected

Definition at line 248 of file CScanlineMask.h.

References CalcBoundingBox().

void iimg::CScanlineMask::Erode ( int  leftValue,
int  rightValue,
int  topValue,
int  bottomValue 
)

Calculate erosion of this range list with rectangle structured element.

Result is stored in this object.

virtual i2d::CRectangle iimg::CScanlineMask::GetBoundingBox ( ) const
virtual

Get bounding box of this shape.

Please note, this bounding box is in logical units, the calibration will not be considered.

Implements i2d::IObject2d.

i2d::CRect iimg::CScanlineMask::GetBoundingRect ( ) const

Get rectangle containing all active pixels.

If this mask is infinite, it returns i2d::CRect::GetInvalid() rectangle. Agains the method GetBoundingBox() from i2d::IObject2d it returns integer rectangle.

virtual i2d::CVector2d iimg::CScanlineMask::GetCenter ( ) const
virtual

Returns center of this 2D-object.

Implements i2d::IObject2d.

virtual icmm::CVarColor iimg::CScanlineMask::GetColorAt ( const istd::CIndex2d position) const
virtual

Get color at specified pixel.

Parameters
positionpixel position, must be inside of returned size.

Implements iimg::IRasterImage.

virtual int iimg::CScanlineMask::GetComponentsCount ( ) const
virtual

Get number of color components.

Implements iimg::IRasterImage.

virtual istd::CIndex2d iimg::CScanlineMask::GetImageSize ( ) const
virtual

Get size of this raster image.

Implements iimg::IRasterImage.

CScanlineMask iimg::CScanlineMask::GetIntersection ( const CScanlineMask mask) const

Get intersection of two masks.

void iimg::CScanlineMask::GetIntersection ( const CScanlineMask mask,
CScanlineMask result 
) const

Get intersection of two masks.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void iimg::CScanlineMask::GetInverted ( const i2d::CRect clipArea,
CScanlineMask result 
) const

Get inverted mask.

Parameters
clipAreaclipping area.
resultresult object, will be filled with inverted mask.
const istd::CIntRanges* iimg::CScanlineMask::GetPixelRanges ( int  lineIndex) const

Get the list of pixel ranges per given line.

virtual int iimg::CScanlineMask::GetSupportedOperations ( ) const
virtual

Get set of flags for supported operations.

See Also
SupportedOperations

Reimplemented from istd::IChangeable.

CScanlineMask iimg::CScanlineMask::GetTranslated ( int  dx,
int  dy 
) const

Calculate translated (moved) mask.

void iimg::CScanlineMask::GetTranslated ( int  dx,
int  dy,
CScanlineMask result 
) const

Calculate translated (moved) mask.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

CScanlineMask iimg::CScanlineMask::GetUnion ( const CScanlineMask mask) const

Get union of two masks.

void iimg::CScanlineMask::GetUnion ( const CScanlineMask mask,
CScanlineMask result 
) const

Get union of two masks.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void iimg::CScanlineMask::InitFromBoundingBox ( const i2d::CRectangle objectBoundingBox,
const i2d::CRect clipAreaPtr 
)
protected

Referenced by CalculateMaskFromBitmap().

void iimg::CScanlineMask::Intersection ( const CScanlineMask mask)

Calculate intersection of this mask and the other one.

Result is stored in this object.

void iimg::CScanlineMask::Invert ( const i2d::CRect clipArea)

Invert mask on place.

Parameters
clipAreaclipping area.
bool iimg::CScanlineMask::IsBitmapRegionEmpty ( ) const

Check if region is empty.

virtual bool iimg::CScanlineMask::IsEmpty ( ) const
virtual

Return true if this image is empty.

Implements iimg::IRasterImage.

virtual void iimg::CScanlineMask::MoveCenterTo ( const i2d::CVector2d position)
virtual

Move object to position position.

Implements i2d::IObject2d.

bool iimg::CScanlineMask::operator!= ( const CScanlineMask mask) const
inline

Definition at line 240 of file CScanlineMask.h.

References operator==().

bool iimg::CScanlineMask::operator== ( const CScanlineMask mask) const

Referenced by operator!=().

virtual bool iimg::CScanlineMask::ResetData ( CompatibilityMode  mode = CM_WITHOUT_REFS)
virtual

Reset data to its default state.

Default implementation in istd::IChangeable does nothing.

Returns
true if the operation was successful, and false otherwise.

Reimplemented from i2d::CObject2dBase.

virtual void iimg::CScanlineMask::ResetImage ( )
virtual

Reset this image.

After this operation image is set to initial state.

Implements iimg::IRasterImage.

Referenced by CalculateMaskFromBitmap().

void iimg::CScanlineMask::ResetScanlines ( const istd::CIntRange verticalRange)

Set this mask to empty set for some vertical range.

virtual bool iimg::CScanlineMask::Serialize ( iser::IArchive archive)
virtual

Load or store state of this object as a archive stream.

Type of operation is depending on archive type.

See Also
iser::IArchive

Implements iser::ISerializable.

virtual bool iimg::CScanlineMask::SetColorAt ( const istd::CIndex2d position,
const icmm::CVarColor color 
)
virtual

Set color at specified pixel.

Parameters
positionpixel position, must be inside of returned size.
colorcolor of pixel will be set.
Returns
true, if pixel color was changed.

Implements iimg::IRasterImage.

void iimg::CScanlineMask::Translate ( int  dx,
int  dy 
)

Translated (move) this mask.

void iimg::CScanlineMask::Union ( const CScanlineMask mask)

Calculate union of this mask and the other one.

Result is stored in this object.

Friends And Related Function Documentation

uint qHash ( const CScanlineMask key,
uint  seed 
)
friend

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

© 2007-2017 Witold Gantzke and Kirill Lepskiy