1、模板匹配
/// 载入原图像和模板块
img = imread( argv[1], 1 );
templ = imread( argv[2], 1 );
/// 创建输出结果的矩阵
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create( result_cols, result_rows, CV_32FC1 );
/// 进行匹配和标准化
matchTemplate( img, templ, result, match_method );
normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );//result存放每一次匹配的匹配度,如果img与templ,则result为1*1
/// 通过函数 minMaxLoc 定位最匹配的位置
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
2、直方图匹配
Mat histogram[10];//256个,范围是0,255.
//for (i = 0; i < 10; i++)
//{
string name = num2str(i) + ".jpg";
string name_w = num2str(i) +