Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. src image search image

thnx in advance :)

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. src image search image

thnx in advance :)

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;

}

double hsvToHist( Mat src_base, Mat src_test1, int method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;

}

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. src image search image

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;

}

0; } double hsvToHist( Mat src_base, Mat src_test1, int method){

method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;
}

}thanx :)

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. thanx :)

src image search image

Code

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;  
}


double hsvToHist( Mat src_base, Mat  src_test1, int method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;
}

thanx :)

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. thanx in avance :)

src image search image

Code

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;  
}


double hsvToHist( Mat src_base, Mat  src_test1, int method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;
}

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. thanx in avance :)

src image search imageC:\fakepath\src.png C:\fakepath\test.png

Code

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;  
}


double hsvToHist( Mat src_base, Mat  src_test1, int method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;
}
click to hide/show revision 7
None

updated 2017-10-05 05:08:48 -0600

berak gravatar image

compareHist is returning very low value incase of Bhattacharyya method

hello,

I have come to a problem comparing two .png images using compareHist. I have used Bhattacharyya, (method 3). but it is returning value close to 0.64. Can anyone help me with the reason and possible solution to make it work??

i have attached here two images here. thanx :)

C:\fakepath\src.png C:\fakepath\test.pngsrc image search image

Code

int main(){
src_base = imread("images/src.jpg",-1);
src_test1 = imread("images/test.png",-1);
double base_test1 = hsvToHist(src_base, src_test1,3);
cout<< " Bhattacharyya template  Base-Test(1) : "<< base_test1<<endl;

return 0;  
}


double hsvToHist( Mat src_base, Mat  src_test1, int method){

Mat hsv_base, hsv_test1;
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );

/// initialization to calculate histograms (Using 50 bins for hue, 60 for saturation)
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges };
int channels[] = { 0, 1 };

/// Histograms
Mat hist_base, hist_test1;

/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );


calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );

///'3' for Bhattacharyya
double base_test1 = compareHist( hist_base, hist_test1, method );
return base_test1;
}