Ask Your Question
0

minVal of minmaxLoc is not what I read by direct reading at matchLoc point

asked May 23 '14

Following the tutorial I created the result matrix:

/// Create the result matrix int result_cols = img.cols - templ.cols + 1; int result_rows = img.rows - templ.rows + 1; result.create( result_cols, result_rows, CV_64F );

Then I call machTemplate (with match_metod = 0) and normalize

matchTemplate( img, templ, result, match_method ); normalize( result, result, 0., 1., NORM_MINMAX, -1, Mat() );

Then I search the minimum by minmaxLoc

minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

cout << " minVal = " << minVal << endl; returns the value minVal = 4.54747e-13

Conversely printing the corresponding matrix element with

cout << "result(j,i) = " << (result.at(double)(matchLoc.x,matchLoc.y)) << endl; I get result(j,i) = 4.19707e-07

Am I reading the matrix element rightly? Otherwise how should read (and write) the element of result matrix?

Thank you for the help.

Preview: (hide)

Comments

1

Mat.at<sometype>(y,x); // row,col here !

also, look here, the result type is probably float , not double

berak gravatar imageberak (May 23 '14)edit

1 answer

Sort by » oldest newest most voted
0

answered May 26 '14

Thank you berak! The problem was due to the different type of the matrix result (float) and minVal and maxVal in matchTemplate, which are double.

Preview: (hide)

Question Tools

Stats

Asked: May 23 '14

Seen: 331 times

Last updated: May 26 '14