BitObject Class Reference

Object defined by a connected binary pixel region. More...

#include <MBARI/BitObject.H>

Collaboration diagram for BitObject:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Coords { OBJECT, IMAGE }
 

Coordinate system for return values.

More...

Public Member Functions

 BitObject ()
 default Constructor
 BitObject (const Image< byte > &img, const Point2D< int > location, const byte threshold=1)
 Constructor from a byte Image and a location.
 BitObject (const Image< byte > &img)
 Construct from a byte Image.
 BitObject (std::istream &is)
 Construct from the data contained in the input stream is.
Image< bytereset (const Image< byte > &img, const Point2D< int > location, const byte threshold=1)
 Reset to a new object.
int reset (const Image< byte > &img)
 Reset to a new object.
void freeMem ()
 delete all stored data, makes the object invalid
void writeToStream (std::ostream &os) const
 write the entire BitObject to the output stream os
void readFromStream (std::istream &is)
 read the BitObject from the input stream is
template<class T >
void setMaxMinAvgIntensity (const Image< T > &img)
 Extract the maximum, minimum and average intensity over the object shape in img.
void getMaxMinAvgIntensity (float &maxIntensity, float &minIntensity, float &avgIntensity)
 Return the maximum, minimum and average intensity.
Rectangle getBoundingBox (const Coords coords=IMAGE) const
 Returns the bounding box of the object.
Image< bytegetObjectMask (const byte value=byte(1), const Coords coords=IMAGE) const
 Returns the object as a binary mask.
Dims getObjectDims () const
 The dimensions of the bounding box of the object.
Point2D< int > getObjectOrigin () const
 The location of the upper left corner of the boundary box in the original image.
Point2D< int > getCentroid (const Coords coords=IMAGE) const
 The centroid of the object rounded to integer coordinates.
Vector2D getCentroidXY (const Coords coords=IMAGE) const
 The centroid, not rounded.
int getArea () const
 The area (number of pixels) of the object.
void getSecondMoments (float &uxx, float &uyy, float &uxy)
 Returns the second moments of the object (normalized by the area).
float getMajorAxis ()
 Returns the length of the major axis of the object.
float getMinorAxis ()
 Returns the length of the minor axis of the object.
float getElongation ()
 Returns the elongation of the object (major axis / minor axis).
float getOriAngle ()
 Returns the angle between the major axis and the x axis.
bool isValid () const
 whether the object is valid
bool doesIntersect (const BitObject &other) const
 returns the intersection of this BitObject with other
template<class T_or_RGB >
void drawShape (Image< T_or_RGB > &, const T_or_RGB &color, float opacity=1.0F)
 draw the shape of this BitObject into img with color
template<class T_or_RGB >
void drawOutline (Image< T_or_RGB > &, const T_or_RGB &color, float opacity=1.0F)
 draw the outline of this BitObject into img with color
template<class T_or_RGB >
void drawBoundingBox (Image< T_or_RGB > &, const T_or_RGB &color, float opacity=1.0F)
 draw the bounding box of this BitObject into img with color
template<class T_or_RGB >
void draw (BitObjectDrawMode mode, Image< T_or_RGB > &, const T_or_RGB &color, float opacity=1.0F)
 draw this BitObject according to mode

Detailed Description

Object defined by a connected binary pixel region.

This class extracts a connected binary pixel region from a grayscale image and analyzes a few of its properties

Definition at line 53 of file BitObject.H.


Member Enumeration Documentation

Coordinate system for return values.

These values are used to specify whether return values should be given in coordinates of the extracted object or in coordinates of the image from which the object was extracted.

Definition at line 107 of file BitObject.H.


Constructor & Destructor Documentation

BitObject::BitObject (  ) 

default Constructor

Definition at line 58 of file BitObject.C.

References freeMem().

BitObject::BitObject ( const Image< byte > &  img,
const Point2D< int >  location,
const byte  threshold = 1 
)

Constructor from a byte Image and a location.

Parameters:
img Image from which the object is extracted
location a point that is inside the object - the object is flooded starting from this seed
threshold for flooding

Definition at line 64 of file BitObject.C.

References reset().

BitObject::BitObject ( const Image< byte > &  img  ) 

Construct from a byte Image.

Parameters:
img image containing only the object the object pixels are 1, all other pixels are 0

Definition at line 71 of file BitObject.C.

References reset().

BitObject::BitObject ( std::istream &  is  ) 

Construct from the data contained in the input stream is.

Definition at line 77 of file BitObject.C.

References readFromStream().


Member Function Documentation

bool BitObject::doesIntersect ( const BitObject other  )  const

returns the intersection of this BitObject with other

if the intersection is empty, an invalid BitObject is returned

Definition at line 533 of file BitObject.C.

References Rectangle::bottomI(), getBoundingBox(), getObjectMask(), isValid(), Rectangle::left(), max(), min(), Rectangle::rightI(), sum(), takeMin(), Rectangle::tlbrI(), and Rectangle::top().

Referenced by VisualEvent::doesIntersect().

template<class T_or_RGB >
void BitObject::draw ( BitObjectDrawMode  mode,
Image< T_or_RGB > &  img,
const T_or_RGB &  color,
float  opacity = 1.0F 
) [inline]

draw this BitObject according to mode

Definition at line 696 of file BitObject.C.

References BODMbbox, BODMoutline, BODMshape, drawBoundingBox(), drawOutline(), and drawShape().

Referenced by VisualEventSet::drawTokens().

template<class T_or_RGB >
void BitObject::drawBoundingBox ( Image< T_or_RGB > &  img,
const T_or_RGB &  color,
float  opacity = 1.0F 
) [inline]
template<class T_or_RGB >
void BitObject::drawOutline ( Image< T_or_RGB > &  img,
const T_or_RGB &  color,
float  opacity = 1.0F 
) [inline]
template<class T_or_RGB >
void BitObject::drawShape ( Image< T_or_RGB > &  img,
const T_or_RGB &  color,
float  opacity = 1.0F 
) [inline]
void BitObject::freeMem (  ) 

delete all stored data, makes the object invalid

Definition at line 255 of file BitObject.C.

References Image< T >::freeMem().

Referenced by BitObject(), and reset().

int BitObject::getArea (  )  const

The area (number of pixels) of the object.

Definition at line 491 of file BitObject.C.

Referenced by VisualEvent::assign(), VisualEventSet::drawTokens(), extractBitObjects(), VisualEvent::getPropertyVector(), and VisualEvent::VisualEvent().

Rectangle BitObject::getBoundingBox ( const Coords  coords = IMAGE  )  const

Returns the bounding box of the object.

Definition at line 423 of file BitObject.C.

References Rectangle::height(), Rectangle::tlbrI(), and Rectangle::width().

Referenced by doesIntersect(), and VisualEventSet::drawTokens().

Point2D< int > BitObject::getCentroid ( const Coords  coords = IMAGE  )  const

The centroid of the object rounded to integer coordinates.

Definition at line 472 of file BitObject.C.

References getCentroidXY(), and Vector2D::getPoint2D().

Vector2D BitObject::getCentroidXY ( const Coords  coords = IMAGE  )  const

The centroid, not rounded.

Definition at line 478 of file BitObject.C.

References getObjectOrigin().

Referenced by getCentroid().

float BitObject::getElongation (  ) 

Returns the elongation of the object (major axis / minor axis).

Definition at line 516 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

float BitObject::getMajorAxis (  ) 

Returns the length of the major axis of the object.

Definition at line 502 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

void BitObject::getMaxMinAvgIntensity ( float &  maxIntensity,
float &  minIntensity,
float &  avgIntensity 
)

Return the maximum, minimum and average intensity.

See setMinMaxAvgIntensity for details

Definition at line 413 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

float BitObject::getMinorAxis (  ) 

Returns the length of the minor axis of the object.

Definition at line 509 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

Dims BitObject::getObjectDims (  )  const

The dimensions of the bounding box of the object.

Definition at line 462 of file BitObject.C.

References Image< T >::getDims().

Image< byte > BitObject::getObjectMask ( const byte  value = byte(1),
const Coords  coords = IMAGE 
) const

Returns the object as a binary mask.

Parameters:
value the value that is used for the object

Definition at line 437 of file BitObject.C.

References ASSERT, getObjectOrigin(), isValid(), pasteImage(), replaceVals(), and ZEROS.

Referenced by doesIntersect().

Point2D< int > BitObject::getObjectOrigin (  )  const

The location of the upper left corner of the boundary box in the original image.

Definition at line 466 of file BitObject.C.

References Rectangle::left(), and Rectangle::top().

Referenced by getCentroidXY(), and getObjectMask().

float BitObject::getOriAngle (  ) 

Returns the angle between the major axis and the x axis.

Definition at line 523 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

void BitObject::getSecondMoments ( float &  uxx,
float &  uyy,
float &  uxy 
)

Returns the second moments of the object (normalized by the area).

Definition at line 495 of file BitObject.C.

Referenced by VisualEvent::getPropertyVector().

bool BitObject::isValid (  )  const

whether the object is valid

This is going to be false if no object could be extracted from the image that was given at the constructor or at reset

Definition at line 529 of file BitObject.C.

References Rectangle::isValid().

Referenced by doesIntersect(), drawBoundingBox(), drawOutline(), drawShape(), VisualEventSet::drawTokens(), getObjectMask(), VisualEvent::getPropertyVector(), and setMaxMinAvgIntensity().

void BitObject::readFromStream ( std::istream &  is  ) 

read the BitObject from the input stream is

Definition at line 327 of file BitObject.C.

References PnmParser::getFrame(), and Rectangle::tlbrI().

Referenced by BitObject().

int BitObject::reset ( const Image< byte > &  img  ) 

Reset to a new object.

Parameters:
img image containing only the object the object pixels are 1, all other pixels are 0;
Returns:
the area of the extracted object; -1 if no object could be extracted - in this case the BitObject is invalid

Definition at line 133 of file BitObject.C.

References ASSERT, freeMem(), getCentroidFirstLast(), Image< T >::getDims(), Image< T >::initialized(), Vector2D::reset(), sumXY(), and Rectangle::tlbrI().

Image< byte > BitObject::reset ( const Image< byte > &  img,
const Point2D< int >  location,
const byte  threshold = 1 
)

Reset to a new object.

Parameters:
img Image from which the object is extracted
location a point that is inside the object - the object is flooded starting from this seed
threshold for flooding
Returns:
a mask of the extracted object (in IMAGE coordinates)

Definition at line 83 of file BitObject.C.

References area(), ASSERT, floodCleanBB(), freeMem(), getCentroidFirstLast(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::initialized(), Rectangle::left(), Vector2D::reset(), sumXY(), and Rectangle::top().

Referenced by BitObject(), and extractBitObjects().

template<class T >
void BitObject::setMaxMinAvgIntensity ( const Image< T > &  img  )  [inline]

Extract the maximum, minimum and average intensity over the object shape in img.

The results are stored in BitObject and can be accessed using getMaxMinAvgIntensity

Definition at line 372 of file BitObject.C.

References ASSERT, Image< T >::begin(), Rectangle::bottomO(), Image< T >::getDims(), Image< T >::getWidth(), isValid(), Rectangle::left(), Rectangle::rightO(), sum(), and Rectangle::top().

void BitObject::writeToStream ( std::ostream &  os  )  const

The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:08 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3