c++ - How to get similarity percentage in images using openCv? -
I used Opansivi library to achieve equality percent images I used openCv library of interest ceremony worth repeating There, the name of the different method (int value) is passed in this ceremony and each Mehod has different results. How to decide on these double values now ???
mat src_base, hsv_base; Mat src_test1, hsv_test1; // mat src_test2, hsv_test2; Matt HSV_Half_Down; String base impedance = [base image path UTF 8 string]; String first CmpImgPath = [firstCmpImagePath UTF8String]; // compare with image path src_base = imread (baseImgPath, 1); Read the source image src_test1 = imread (firstCmpImgPath, 1); Read compared image / src_test2 = imread (secondCmpImgPath, 1); If (! Src_base.data ||! Src_test1.data /*|||src_test2.data*/) {return zero; } CvtColor (src_base, hsv_base, COLOR_BGR2HSV); CvtColor (src_test1, hsv_test1, COLOR_BGR2HSV); // cvtColor (src_test2, hsv_test2, COLOR_BGR2HSV); hsv_half_down = hsv_base (range (hsv_base.rows / 2, hsv_base.rows - 1), range (0, hsv_base.cols - 1)); Use 50 coaches for /// color and int h_bins = 50 for 60 saturation; Int s_bins = 60; Int histSize [] = {h_bins, s_bins}; // color changes from 0 to 179, saturation 0 to 255 float h_ranges [] = {0, 180}; Float s_ranges [] = {0, 256}; Const Float * Category [] = {h_ranges, s_ranges}; // Use o-th and 1-channel channels [] = {0, 1}; /// Histogram Matt Hist_base; Matt Hist_Half_Down; Matte hist_teath1; Matte hist_tast2; (; Mat (), hist_base, 2, histSize, ranges, true, false hsv_base, 1, calculation of HSV images calcHist histogram for the channel, & amp) ///; Normal (hist_base, hist_base, 0, 1, NORM_MINMAX, -1, mat ()); Calhahaast (& amp; hsv_alph_down, 1, channel, mate (), hist_half_down, 2, hist size, categories, truth, wrong); Normal (hist_half_down, hist_half_down, 0, 1, NORM_MINMAX, -1, mat ()); Calcihist (and HSV_text1, 1, channel, mate), hist_teast1, 2, hist size, category, truth, wrong); Normal (hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, mat ()); For {int i = 0; i <4; i ++} {int compare_method = i; Double bass_test -1 = comparative (hist_base, hist_tist1, comparison_use); } Compares way CV_COMP_CORREL, CV_COMP_CHISQR, CV_COMP_INTERSECT, CV_COMP_BHATTACHARYYA reference link http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.html
Text after "
This simulation metric for a bitmap B is an image that makes defining a target calculates the percentage of pixels in different image.
However, when you are using a bitmap / image histogram, this metric is understandable because you already have that image ( or a feature removed ) already Stats has been created. From this point, to compute equality, you compare the features of 2 images in your case with compare . A higher distance means another different image and distance 0 means that the images are 100% identical. Now it depends on whether the algorithm can actually produce 0. However, the distance 0.5 does not mean that the images are equal to 50%.
Although you can artificially create the degree percentile of the similarity measured. You may consider the following: - There is a 0% similarity between the two images ( maximum distance ) with the lowest degree of equality between them; You can use this distance to have a pure black image and a pure white image :)
- Distance 0 is equal to 100%.
Depending on these assumptions, you draw the measured similarity in percentage based on your computeHist distance.
Comments
Post a Comment