#include <iostream>
enum MyShape{MyCIRCLE=0,MyRECTANGLE,MyELLIPSE};
struct ParamColorMap {
int iColormap;
};
static const String ColorMaps[] = {
"Autumn",
"Bone",
"Jet",
"Winter",
"Rainbow",
"Ocean",
"Summer",
"Spring",
"Cool", "HSV", "Pink", "Hot", "Parula", "Magma", "Inferno", "Plasma", "Viridis",
"Cividis", "Twilight", "Twilight Shifted", "Turbo", "Deep Green", "User defined (random)" };
static void TrackColorMap(int x, void *r)
{
ParamColorMap *p = (ParamColorMap*)r;
p->iColormap= x;
{
}
else
}
static Mat DrawMyImage(
int thickness,
int nbShape)
{
int offsetx = 50, offsety = 25;
int lineLength = 50;
for (int i=0;i<256;i++)
line(img,
Point(thickness*i+ offsetx, offsety),
Point(thickness*i+ offsetx, offsety+ lineLength),
Scalar(i), thickness);
int radius;
int width,height;
int angle;
for (int i=1;i<=nbShape;i++)
{
int typeShape = r.
uniform(MyCIRCLE, MyELLIPSE+1);
switch (typeShape) {
case MyCIRCLE:
break;
case MyRECTANGLE:
rc =
Rect(center-
Point(width ,height )/2, center +
Point(width , height )/2);
break;
case MyELLIPSE:
break;
}
}
return img;
}
int main(
int argc,
char** argv)
{
cout << "This program demonstrates the use of applyColorMap function.\n\n";
ParamColorMap p;
if (argc > 1)
else
img = DrawMyImage(2,256);
p.img=img;
p.iColormap=0;
TrackColorMap(0, (void*)&p);
cout << "Press a key to exit" << endl;
return 0;
}
n-dimensional dense array class
Definition mat.hpp:812
static CV_NODISCARD_STD MatExpr zeros(int rows, int cols, int type)
Returns a zero array of the specified size and type.
int cols
Definition mat.hpp:2138
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2138
Random Number Generator.
Definition core.hpp:2889
int uniform(int a, int b)
returns uniformly distributed integer random number from [a,b) range
void randu(InputOutputArray dst, InputArray low, InputArray high)
Generates a single uniformly-distributed random number or an array of random numbers.
void min(InputArray src1, InputArray src2, OutputArray dst)
Calculates per-element minimum of two arrays or an array and a scalar.
Rect2i Rect
Definition types.hpp:489
Point2i Point
Definition types.hpp:209
std::string String
Definition cvstd.hpp:151
Size2i Size
Definition types.hpp:370
Scalar_< double > Scalar
Definition types.hpp:702
#define CV_8UC1
Definition interface.h:88
#define CV_8UC3
Definition interface.h:90
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
void setTrackbarPos(const String &trackbarname, const String &winname, int pos)
Sets the trackbar position.
void setTrackbarMax(const String &trackbarname, const String &winname, int maxval)
Sets the trackbar maximum position.
void setTrackbarMin(const String &trackbarname, const String &winname, int minval)
Sets the trackbar minimum position.
int createTrackbar(const String &trackbarname, const String &winname, int *value, int count, TrackbarCallback onChange=0, void *userdata=0)
Creates a trackbar and attaches it to the specified window.
@ IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image (codec internal conversion).
Definition imgcodecs.hpp:70
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
void applyColorMap(InputArray src, OutputArray dst, int colormap)
Applies a GNU Octave/MATLAB equivalent colormap on a given image.
@ COLORMAP_AUTUMN
Definition imgproc.hpp:4444
@ COLORMAP_DEEPGREEN
Definition imgproc.hpp:4465
void rectangle(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a simple, thick, or filled up-right rectangle.
void ellipse(InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a simple or thick elliptic arc or fills an ellipse sector.
void putText(InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false)
Draws a text string.
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
void circle(InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a circle.
@ FONT_HERSHEY_SIMPLEX
normal size sans-serif font
Definition imgproc.hpp:901
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
"black box" representation of the file storage associated with a file on disk.
Definition core.hpp:102