Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative values in normalize #6125

Closed
irinagit opened this issue Feb 16, 2016 · 5 comments
Closed

Negative values in normalize #6125

irinagit opened this issue Feb 16, 2016 · 5 comments

Comments

@irinagit
Copy link

I'm using Ubuntu 13.10 64 Bit, OpenCV master branch.

I get negative values in normalize() function for this example:

    cv::Mat m = (cv::Mat_<float>(20,1)<<
     1888,
     1692,
     369,
     263,
     199,
     280,
     326,
     129,
     143,
     126,
     233,
     221,
     130,
     126,
     150,
     249,
     575,
     574,
     63,
     12);

    cv::normalize(m, m, 0, 400, cv::NORM_MINMAX, CV_32F );
    std::cout << m <<std::endl;

The output is:

[400;
358.20895;
76.119408;
53.518124;
39.872066;
57.142857;
66.950958;
24.946693;
27.931768;
24.307035;
47.121532;
44.562901;
25.159914;
24.307035;
29.424307;
50.533047;
120.04265;
119.82943;
10.8742;
-2.3841858e-07]

@mshabunin
Copy link
Contributor

Possibly rounding problem, try to use double.

@Aravind-Suresh
Copy link
Contributor

Using output format CV_64F also gives the correct/expected output.

@abhiravredox
Copy link

I would like to work on this bug. please help me get started as this is my 1st bug!

@Aravind-Suresh
Copy link
Contributor

I tried working on this bug. Let me know if it is correct.

@ysolovyov
Copy link
Contributor

it is still broken

res.create(res_rows, res_cols, CV_64FC1);

cv::matchTemplate(src, tmplResized, res, cfg_.matchingMethod);
cv::normalize(res, res, 0, 1, cv::NORM_MINMAX, -1, cv::Mat());

res contains negative values like -1.19209e-07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants