Error : assertion failed (depth ==5 || depth==6) in cv::pow,fill c:\opencv\...\mathfuncs.cpp

asked 2018-08-24 04:43:33 -0500

Samjith888 gravatar image

Getting assertion failed error ' cv::pow(sigma, double(0.5), sigma); // sigma = sqrt(sigma)' in this line.

    // compute sigma
Mat sigma = im.size(), CV_64FC1, 1);
sigma = im.mul(im); 
GaussianBlur(sigma, sigma, Size(7, 7), 1.166); // apply gaussian blur
subtract(sigma, mu_sq, sigma); // sigma = sigma - mu_sq
cv::pow(sigma, double(0.5), sigma); // sigma = sqrt(sigma)
add(sigma, Scalar(1.0/255), sigma); // to avoid DivideByZero Exception
Mat structdis(im.size(), CV_64FC1, 1);
subtract(im, mu, structdis); // structdis = im - mu
divide(structdis, sigma, structdis

Code from this website

edit retag flag offensive close merge delete

Comments

1st line already does not compile. can you update it ?

berak gravatar imageberak ( 2018-08-24 07:07:01 -0500 )edit

code is quite buggy there ;)

sigma = im.mul(im);

you're overwriting sigma with whatever type im had. and this must be double or float, but probably isn't.

berak gravatar imageberak ( 2018-08-24 07:12:14 -0500 )edit

@berak : how can i correct it ? and while debugging the errors shown in cv::pow(sigma, double(0.5), sigma); // sigma = sqrt(sigma) this line

Samjith888 gravatar imageSamjith888 ( 2018-09-03 05:20:11 -0500 )edit

can you look at the comment above, again ?

berak gravatar imageberak ( 2018-09-03 05:42:01 -0500 )edit

@berak: I can ,but i can't understand. Can u explain it by correcting the error?

Samjith888 gravatar imageSamjith888 ( 2018-09-03 05:58:33 -0500 )edit