#include <iostream>
using namespace cv;
using namespace std;
int bins = 25;
void Hist_and_Backproj(int, void* );
int main(
int,
char** argv )
{
hue.create( hsv.size(), hsv.depth() );
int ch[] = { 0, 0 };
const char* window_image = "Source image";
createTrackbar(
"* Hue bins: ", window_image, &bins, 180, Hist_and_Backproj );
Hist_and_Backproj(0, 0);
return 0;
}
void Hist_and_Backproj(int, void* )
{
MatND hist;
int histSize =
MAX( bins, 2 );
float hue_range[] = { 0, 180 };
const float* ranges = { hue_range };
calcHist( &hue, 1, 0,
Mat(), hist, 1, &histSize, &ranges,
true,
false );
MatND backproj;
imshow(
"BackProj", backproj );
int w = 400; int h = 400;
int bin_w =
cvRound( (
double) w / histSize );
for( int i = 0; i < bins; i ++ )
imshow(
"Histogram", histImg );
}