Direct Graphical Models  v.1.7.0
Marker.h
1 // Marker Class
2 // Written by Sergey Kosov in 2008 - 2010 for MPII
3 // Adopted by Sergey Kosov in 2012 for Project X
4 // Modified by Sergey Kosov in 2015 for Project X
5 #pragma once
6 
7 #include "types.h"
8 
9 namespace DirectGraphicalModels { namespace vis
10 {
11  // Default paletes
12  const static Scalar colors24[] =
13  {
14  CV_RGB(255, 0, 0), // Red
15  CV_RGB(255, 128, 0), // Orange
16  CV_RGB(255, 255, 0), // Yellow
17  CV_RGB(128, 255, 0), // Chartreuse
18  CV_RGB(0, 255, 0), // Green
19  CV_RGB(0, 255, 128), // Spring green
20  CV_RGB(0, 255, 255), // Cyan
21  CV_RGB(0, 128, 255), //
22  CV_RGB(0, 0, 255), // Blue
23  CV_RGB(128, 0, 255), //
24  CV_RGB(255, 0, 255), // Purple
25  CV_RGB(255, 0, 128), //
26 
27  CV_RGB(128, 0, 0), // Dark Red
28  CV_RGB(128, 64, 0), // Dark Orange
29  CV_RGB(128, 128, 0), // Dark Yellow
30  CV_RGB(64, 128, 0), // Dark Chartreuse
31  CV_RGB(0, 128, 0), // Dark Green
32  CV_RGB(0, 128, 64), // Dark Spring green
33  CV_RGB(0, 128, 128), // Dark Cyan
34  CV_RGB(0, 64, 128), //
35  CV_RGB(0, 0, 128), // Dark Blue
36  CV_RGB(64, 0, 128), //
37  CV_RGB(128, 0, 128), // Dark Purple
38  CV_RGB(128, 0, 64) //
39  };
40 
56  };
61  enum mark_flags {
62  MARK_GRID = 1,
63  MARK_OVER = 2,
65  MARK_BW = 8,
67  MARK_PERCENT = 128
68  };
69 
70 
71  // ================================ Marker Class ================================
78  class CMarker
79  {
80  enum textProp
81  {
82  TP_CENTER = 0,
83  TP_LEFT = 1,
84  TP_RIGHT = 2,
85  TP_TOP = 4,
86  TP_BOTTOM = 8,
87 
88  TP_PERCENT = 128 // This flag may be mixed with the <mark_flags>
89  };
90 
91  public:
96  DllExport CMarker(default_pallete palette = DEF_PALETTE_12);
102  DllExport CMarker(const vec_nColor_t &vPalette);
103  DllExport virtual ~CMarker(void);
104 
112  DllExport void markClasses(Mat &base, const Mat &classes, byte flag = 0) const; // Does nothing on error
122  DllExport Mat drawPotentials(const Mat &potential, byte flag = 0) const;
132  DllExport Mat drawConfusionMatrix(const Mat &confusionMat, byte flag = 0) const;
133 
134 
135  protected:
137 
138 
139  private:
140  Mat drawVector(const Mat &potential, byte flag) const;
141  Mat drawMatrix(const Mat &potential, byte flag) const;
142  Mat drawVoxel (const Mat &potential, byte flag) const; // WARNING: not implemented
143 
144  template<typename T>
145  void drawSquare(Mat &img, byte x, byte y, const Scalar &color, T val, double fontScale = 1.0, byte textProp = 0) const;
146  void drawRectangle(Mat &img, Point pt1, Point pt2, const Scalar &color, float val, double fontScale = 1.0, byte textProp = TP_CENTER) const;
147  void drawRectangle(Mat &img, Point pt1, Point pt2, const Scalar &color, const std::string &str = std::string(), double fontScale = 1.0, byte textProp = TP_CENTER) const;
148 
149 
150  private:
151  static const byte bkgIntencity;
152  static const byte frgIntensity;
153  static const int ds; // size of the cell
154 
155 
156  private:
157  // Copy semantics are disabled
158  CMarker(const CMarker&) = delete;
159  const CMarker& operator=(const CMarker&) = delete;
160  };
161 
162 
163 
172  DllExport Mat drawDictionary(const Mat &dictionary, double m = 1);
173 
174 } }
175 
Mat drawVoxel(const Mat &potential, byte flag) const
Definition: Marker.cpp:259
void drawSquare(Mat &img, byte x, byte y, const Scalar &color, T val, double fontScale=1.0, byte textProp=0) const
Definition: Marker.cpp:266
Default Pallete with 3 colors.
Definition: Marker.h:43
Blends the base image.
Definition: Marker.h:63
void drawRectangle(Mat &img, Point pt1, Point pt2, const Scalar &color, float val, double fontScale=1.0, byte textProp=TP_CENTER) const
Definition: Marker.cpp:273
Default Pallete with 12 colors.
Definition: Marker.h:48
Mark per-class accuracies in the confusion matrix.
Definition: Marker.h:66
The class with index 0 will not be visualized.
Definition: Marker.h:64
Default Pallete with 24 colors.
Definition: Marker.h:49
Default Pallete with 72 colors.
Definition: Marker.h:55
static const byte bkgIntencity
Definition: Marker.h:151
std::vector< std::pair< Scalar, std::string > > vec_nColor_t
Definition: types.h:73
Default Pallete with 72 colors.
Definition: Marker.h:54
Mat drawConfusionMatrix(const Mat &confusionMat, byte flag=0) const
Visualizes a confusion matrix.
Definition: Marker.cpp:86
Default Pallete with 36 colors.
Definition: Marker.h:53
Default Pallete with 24 colors.
Definition: Marker.h:50
Default Pallete with 36 colors.
Definition: Marker.h:52
Default Pallete with 12 colors.
Definition: Marker.h:47
Visualizes only the odd pixels.
Definition: Marker.h:62
CMarker(default_pallete palette=DEF_PALETTE_12)
Constructor with a default palette.
Definition: Marker.cpp:14
Mat drawDictionary(const Mat &dictionary, double m)
Visualizes a sparse coding dictionary.
Definition: Marker.cpp:324
static const byte frgIntensity
Definition: Marker.h:152
Default Pallete with 3 colors.
Definition: Marker.h:44
void markClasses(Mat &base, const Mat &classes, byte flag=0) const
Visualizes the classes.
Definition: Marker.cpp:43
default_pallete
Default palettes.
Definition: Marker.h:42
Mat drawVector(const Mat &potential, byte flag) const
Definition: Marker.cpp:172
Default Pallete with 24 colors.
Definition: Marker.h:51
Mark in "black and white" palette.
Definition: Marker.h:65
Mat drawMatrix(const Mat &potential, byte flag) const
Definition: Marker.cpp:210
mark_flags
Visualization flags.
Definition: Marker.h:61
Default Pallete with 6 colors.
Definition: Marker.h:45
Adds percent symbol to the output text values.
Definition: Marker.h:67
Default Pallete with 6 colors.
Definition: Marker.h:46
vec_nColor_t m_vPalette
Pointer to the container with the palette.
Definition: Marker.h:136
const CMarker & operator=(const CMarker &)=delete
Mat drawPotentials(const Mat &potential, byte flag=0) const
Visualizes the potentials.
Definition: Marker.cpp:76