Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
drwnPixelNeighbourContrasts Class Reference

Convenience class for holding pixel contrast weights. More...

Inheritance diagram for drwnPixelNeighbourContrasts:
drwnStdObjIface drwnWriteable drwnCloneable drwnTypeable

Public Member Functions

 drwnPixelNeighbourContrasts ()
 default constructor
 
 drwnPixelNeighbourContrasts (const cv::Mat &img)
 construct and cache pixel contrast weights for the given image
 
const char * type () const
 returns object type as a string (e.g., Foo::type() { return "Foo"; })
 
drwnPixelNeighbourContrastsclone () const
 returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); }
 
virtual void clear ()
 clear all cached contrast weights
 
virtual void initialize (const cv::Mat &img)
 cache contrast weights for the given image
 
bool save (drwnXMLNode &xml) const
 write object to XML node (see also write)
 
bool load (drwnXMLNode &xml)
 read object from XML node (see also read)
 
int width () const
 width of the image (in pixels)
 
int height () const
 height of the image (in pixels)
 
double contrastN (int x, int y) const
 return the contrast weight between pixels (x,y) and (x,y-1)
 
double contrastS (int x, int y) const
 return the contrast weight between pixels (x,y) and (x,y+1)
 
double contrastE (int x, int y) const
 return the contrast weight between pixels (x,y) and (x+1,y)
 
double contrastW (int x, int y) const
 return the contrast weight between pixels (x,y) and (x-1,y)
 
double contrastNW (int x, int y) const
 return the contrast weight between pixels (x,y) and (x-1,y-1)
 
double contrastSW (int x, int y) const
 return the contrast weight between pixels (x,y) and (x-1,y+1)
 
double contrastNE (int x, int y) const
 return the contrast weight between pixels (x,y) and (x+1,y-1)
 
double contrastSE (int x, int y) const
 return the contrast weight between pixels (x,y) and (x+1,y+1)
 
cv::Mat visualize (bool bComposite=true) const
 Visualize the strength of the contrast term. If bComposite is false then the contrast is visualized in each direction separately.
 
- Public Member Functions inherited from drwnWriteable
bool write (const char *filename) const
 write object to file (calls save)
 
bool read (const char *filename)
 read object from file (calls load)
 
void dump () const
 print object's current state to standard output (for debugging)
 

Static Protected Member Functions

static double pixelContrast (const cv::Mat &img, const cv::Point &p, const cv::Point &q)
 

Protected Attributes

MatrixXd _horzContrast
 contrast between (x, y) and (x - 1, y)
 
MatrixXd _vertContrast
 contrast between (x, y) and (x, y - 1)
 
MatrixXd _nwContrast
 (north-west) contrast between (x, y) and (x - 1, y - 1)
 
MatrixXd _swContrast
 (south-west) contrast between (x, y) and (x - 1, y + 1)
 

Detailed Description

Convenience class for holding pixel contrast weights.

These are used in various CRF image segmentation models (see drwnSegImageInstance) with pairwise neighbourhood penalties taking the form $\frac{1}{d_{pq}} exp\left(-\frac{\beta}{2} * \left|p - q\right|^2\right)$ where $\beta$ is the mean square-difference between neighbouring pixel colours and $d_{pq}$ is the distance between pixels p and q.


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