Ask Your Question
0

minMaxLoc, maxVal always is 1

asked 2016-10-20 05:45:10 -0600

pawkolodziej gravatar image

Hi everyone

When i use minMaxLoc, to find the best score of matchtemplating, in maxVal i have always value 1.

My code:

void MatchingMethod(int, void*)

{

Mat img_display;
img.copyTo(img_display);
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create(result_rows, result_cols, CV_32F);
matchTemplate(img_display, templ, result, CV_TM_SQDIFF);
normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat());
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;Point matchLoc;
minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
scores = maxVal;

if (scores > 0.0)
{
    printf("\nWynik:%\F", minVal);
    printf("  %\F", maxVal);
    printf(" %\F", minLoc);
    printf(" %\F", maxLoc);
};

if someone can help me?

edit retag flag offensive close merge delete

Comments

why the normalize() ?

berak gravatar imageberak ( 2016-10-20 05:59:00 -0600 )edit
pawkolodziej gravatar imagepawkolodziej ( 2016-10-20 06:03:29 -0600 )edit
1

do you understand, what the normalize() does ?

berak gravatar imageberak ( 2016-10-20 07:05:49 -0600 )edit

I thnk so. Normalize the values in array to defined range?

pawkolodziej gravatar imagepawkolodziej ( 2016-10-20 07:55:06 -0600 )edit

I want to see the result from funkction minMaxLoc, in range 0.0 - 1.0 where 1.0 is the best score.

pawkolodziej gravatar imagepawkolodziej ( 2016-10-20 07:59:03 -0600 )edit
1

so, the maximal value after that is 1, and the minimal value is 0.

again, if you don't want that, you'd have to remove the normalize() call.

berak gravatar imageberak ( 2016-10-20 07:59:48 -0600 )edit
1

btw, printf(" %f", maxLoc); (there's no escape sequence like \F anywhere in c/c++)

berak gravatar imageberak ( 2016-10-20 08:03:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-10-20 08:03:31 -0600

pawkolodziej gravatar image

ok, now i understand. I removed normalize(). Thx for explain.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-20 05:45:10 -0600

Seen: 1,257 times

Last updated: Oct 20 '16