Ask Your Question
0

Assertion erro in log operation

asked 2018-08-21 09:47:06 -0500

neto gravatar image

updated 2018-08-21 09:52:48 -0500

My code for calculate the log of all pixels in an image:

int main(int argc, char** argv)
{


    //ABRE A IMAGEM->CINZA e MOSTRA
    Mat img = imread("img.jpg", IMREAD_GRAYSCALE);
    Mat dest;

    cv::log(img, dest);
    namedWindow("t");
    imshow("t", dest);
    if (waitKey(0) == 27) destroyAllWindows();
    return 0;
}

Output:

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(3.4.2) Error: Assertion failed (depth == 5 || depth == 6) in cv::log, file c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\mathfuncs.cpp, line 701
edit retag flag offensive close merge delete

Comments

you forgot the error.

berak gravatar imageberak ( 2018-08-21 09:50:32 -0500 )edit
1

ops, sorry

neto gravatar imageneto ( 2018-08-21 09:52:10 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-08-21 09:55:43 -0500

berak gravatar image

Assertion failed (depth == 5 || depth == 6)

means, you need float or double data as input, not uchar.

src.convertTo(src, CV_32F);
log(src, dst);
dst.convertTo(dst, CV_8U);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-21 09:47:06 -0500

Seen: 97 times

Last updated: Aug 21 '18