You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- You can give full path to an image in command line
24
-
@code{.cpp}
25
-
CommandLineParser parser(argc, argv, keys);
24
+
@snippet histo3D.cpp command_line_parser
26
25
27
-
if (parser.has("help"))
28
-
{
29
-
parser.printMessage();
30
-
return 0;
31
-
}
32
-
String nomFic = parser.get<String>(0);
33
-
Mat img;
34
-
if (nomFic.length() != 0)
35
-
{
36
-
img = imread(nomFic, IMREAD_COLOR);
37
-
if (img.empty())
38
-
{
39
-
cout << "Image does not exist!";
40
-
return 0;
41
-
}
42
-
}
43
-
@endcode
44
-
or without path, a synthetic image is generated with pixel values are a gaussian distribution center(60+/-10,40+/-5,50+/-20) in first quadrant,
26
+
or without path, a synthetic image is generated with pixel values are a gaussian distribution @ref cv::RNG::fill center(60+/-10,40+/-5,50+/-20) in first quadrant,
45
27
(160+/-20,10+/-5,50+/-10) in second quadrant, (90+/-10,100+/-20,50+/-20) in third quadrant, (100+/-10,10+/-5,150+/-40) in last quadrant.
channel are 2, 1 and 0 to synchronise color with Viz axis color in objetc viz::WCoordinateSystem.
28
+
@snippet histo3D.cpp synthetic_image
29
+
Image tridimensional histogram is calculated using opencv @ref cv::calcHist and @ref cv::normalize between 0 and 100.
30
+
@snippet histo3D.cpp calchist_for_histo3d
31
+
channel are 2, 1 and 0 to synchronise color with Viz axis color in objetc cv::viz::WCoordinateSystem.
70
32
71
33
A slidebar is inserted in image window. Init slidebar value is 90, it means that only histogram cell greater than 9/100000.0 (23 pixels for an 512X512 pixels) will be display.
We are ready to open a viz window with a callback function to capture keyboard event in viz window. Using Viz::spinonce enable keyboard event to be capture in imshow window too.
The function DrawHistogram3D processes histogram Mat to display it in a Viz window. Number of plan, row and column in three dimensional Mat ca be found using this code :
To get histogram value at a specific location we use at method with three arguments k, i and j where k is plane number, i row number and j column number.
105
-
@code{.cpp}
106
-
for (int k = 0; k < plans; k++)
107
-
{
108
-
for (int i = 0; i < rows; i++)
109
-
{
110
-
for (int j = 0; j < cols; j++)
111
-
{
112
-
double x = h.histogram.at<float>(k, i, j);
113
-
if (x >= h.threshold)
114
-
{
115
-
double r=std::max(x/h.maxH,0.1);
116
-
viz::WCube s(Point3d(k - r / 2, i - r / 2, j - r / 2), Point3d(k + r / 2, i + r / 2, j + r / 2), false, viz::Color(j / double(plans) * 255, i / double(rows) * 255, k / double(cols) * 255));
We are ready to open a viz window with a callback function to capture keyboard event in viz window. Using @ref cv::viz::Viz3d::spinOnce enable keyboard event to be capture in @ref cv::imshow window too.
36
+
@snippet histo3D.cpp manage_viz_imshow_window
37
+
The function DrawHistogram3D processes histogram Mat to display it in a Viz window. Number of plan, row and column in (three dimensional Mat)[http://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#details] can be found using this code :
38
+
@snippet histo3D.cpp get_cube_size
39
+
To get histogram value at a specific location we use @ref cv::Mat::at(int i0,int i1, int i2) method with three arguments k, i and j where k is plane number, i row number and j column number.
40
+
@snippet histo3D.cpp get_cube_values
123
41
124
42
- Callback function
125
-
Principle are as mouse callback function. Key code pressed is in field code of class viz::KeyboardEvent.
0 commit comments