19 int main(
int argc,
char** argv )
21 Mat src_base, hsv_base;
22 Mat src_test1, hsv_test1;
23 Mat src_test2, hsv_test2;
29 printf(
"** Error. Usage: ./compareHist_Demo <image_settings0> <image_setting1> <image_settings2>\n");
33 src_base =
imread( argv[1], 1 );
34 src_test1 =
imread( argv[2], 1 );
35 src_test2 =
imread( argv[3], 1 );
45 int h_bins = 50;
int s_bins = 60;
46 int histSize[] = { h_bins, s_bins };
49 float h_ranges[] = { 0, 180 };
50 float s_ranges[] = { 0, 256 };
52 const float* ranges[] = { h_ranges, s_ranges };
55 int channels[] = { 0, 1 };
65 calcHist( &hsv_base, 1, channels,
Mat(), hist_base, 2, histSize, ranges,
true,
false );
68 calcHist( &hsv_half_down, 1, channels,
Mat(), hist_half_down, 2, histSize, ranges,
true,
false );
71 calcHist( &hsv_test1, 1, channels,
Mat(), hist_test1, 2, histSize, ranges,
true,
false );
74 calcHist( &hsv_test2, 1, channels,
Mat(), hist_test2, 2, histSize, ranges,
true,
false );
78 for(
int i = 0; i < 4; i++ )
80 int compare_method =
i;
81 double base_base =
compareHist( hist_base, hist_base, compare_method );
82 double base_half =
compareHist( hist_base, hist_half_down, compare_method );
83 double base_test1 =
compareHist( hist_base, hist_test1, compare_method );
84 double base_test2 =
compareHist( hist_base, hist_test2, compare_method );
86 printf(
" Method [%d] Perfect, Base-Half, Base-Test(1), Base-Test(2) : %f, %f, %f, %f \n", i, base_base, base_half , base_test1, base_test2 );
convert RGB/BGR to HSV (hue saturation value), color conversions
Definition: imgproc.hpp:554
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0)
Converts an image from one color space to another.
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: mat.hpp:1865
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
double compareHist(InputArray H1, InputArray H2, int method)
Compares two histograms.
int cols
Definition: mat.hpp:1865
static Vec< _Tp, cn > normalize(const Vec< _Tp, cn > &v)
for i
Definition: modelConvert.m:63
void calcHist(const Mat *images, int nimages, const int *channels, InputArray mask, OutputArray hist, int dims, const int *histSize, const float **ranges, bool uniform=true, bool accumulate=false)
Calculates a histogram of a set of arrays.
Template class specifying a continuous subsequence (slice) of a sequence.
Definition: types.hpp:531
flag
Definition: base.hpp:176
int main(int argc, const char *argv[])
Definition: facerec_demo.cpp:67
n-dimensional dense array class
Definition: mat.hpp:726