Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnPixelNeighbourContrasts.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnPixelNeighbourContrasts.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 #include "Eigen/Core"
15 
16 #include "cv.h"
17 
18 using namespace std;
19 using namespace Eigen;
20 
21 // drwnPixelNeighbourContrasts class ----------------------------------------
29 
31 protected:
32  MatrixXd _horzContrast;
33  MatrixXd _vertContrast;
34  MatrixXd _nwContrast;
35  MatrixXd _swContrast;
36 
37 public:
41  drwnPixelNeighbourContrasts(const cv::Mat& img);
42  virtual ~drwnPixelNeighbourContrasts();
43 
44  // i/o
45  const char *type() const { return "drwnPixelNeighbourContrasts"; }
47 
49  virtual void clear();
51  virtual void initialize(const cv::Mat& img);
52 
53  bool save(drwnXMLNode& xml) const;
54  bool load(drwnXMLNode& xml);
55 
57  int width() const { return _horzContrast.rows(); }
59  int height() const { return _horzContrast.cols(); }
60 
61  // access
63  double contrastN(int x, int y) const { return _vertContrast(x, y); }
65  double contrastS(int x, int y) const { return _vertContrast(x, y + 1); }
67  double contrastE(int x, int y) const { return _horzContrast(x + 1, y); }
69  double contrastW(int x, int y) const { return _horzContrast(x, y); }
71  double contrastNW(int x, int y) const { return _nwContrast(x, y); }
73  double contrastSW(int x, int y) const { return _swContrast(x, y); }
75  double contrastNE(int x, int y) const { return _swContrast(x + 1, y - 1); }
77  double contrastSE(int x, int y) const { return _nwContrast(x + 1, y + 1); }
78 
79  // visualization
82  cv::Mat visualize(bool bComposite = true) const;
83 
84 protected:
85  static double pixelContrast(const cv::Mat& img, const cv::Point &p, const cv::Point& q);
86 };
int width() const
width of the image (in pixels)
Definition: drwnPixelNeighbourContrasts.h:57
double contrastNE(int x, int y) const
return the contrast weight between pixels (x,y) and (x+1,y-1)
Definition: drwnPixelNeighbourContrasts.h:75
int height() const
height of the image (in pixels)
Definition: drwnPixelNeighbourContrasts.h:59
MatrixXd _horzContrast
contrast between (x, y) and (x - 1, y)
Definition: drwnPixelNeighbourContrasts.h:32
Convenience class for holding pixel contrast weights.
Definition: drwnPixelNeighbourContrasts.h:30
drwnPixelNeighbourContrasts * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnPixelNeighbourContrasts.h:46
double contrastS(int x, int y) const
return the contrast weight between pixels (x,y) and (x,y+1)
Definition: drwnPixelNeighbourContrasts.h:65
MatrixXd _vertContrast
contrast between (x, y) and (x, y - 1)
Definition: drwnPixelNeighbourContrasts.h:33
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnPixelNeighbourContrasts.h:45
double contrastNW(int x, int y) const
return the contrast weight between pixels (x,y) and (x-1,y-1)
Definition: drwnPixelNeighbourContrasts.h:71
MatrixXd _swContrast
(south-west) contrast between (x, y) and (x - 1, y + 1)
Definition: drwnPixelNeighbourContrasts.h:35
double contrastW(int x, int y) const
return the contrast weight between pixels (x,y) and (x-1,y)
Definition: drwnPixelNeighbourContrasts.h:69
double contrastN(int x, int y) const
return the contrast weight between pixels (x,y) and (x,y-1)
Definition: drwnPixelNeighbourContrasts.h:63
double contrastSE(int x, int y) const
return the contrast weight between pixels (x,y) and (x+1,y+1)
Definition: drwnPixelNeighbourContrasts.h:77
double contrastSW(int x, int y) const
return the contrast weight between pixels (x,y) and (x-1,y+1)
Definition: drwnPixelNeighbourContrasts.h:73
MatrixXd _nwContrast
(north-west) contrast between (x, y) and (x - 1, y - 1)
Definition: drwnPixelNeighbourContrasts.h:34
standard Darwin object interface (cloneable and writeable)
Definition: drwnInterfaces.h:72
double contrastE(int x, int y) const
return the contrast weight between pixels (x,y) and (x+1,y)
Definition: drwnPixelNeighbourContrasts.h:67