OpenCV: Multiply Images in C++ and C

自古美人都是妖i 提交于 2020-01-17 05:37:11

问题


I've just used the multiply functions using C api (cvMul) and C++ api (mul and multiply). But I get a different result from the C function and the C++ ones

  • Result of cvMul (it is a white image)
  • Result of mul and multiply

Here is the code I use for both implementations:

C

IplImage * gh = cvCreateImage(cvGetSize(input),IPL_DEPTH_32F,1) ;
cvSobel(input,gh,1,0) ;

IplImage * gh2 = cvCreateImage(cvGetSize(input),IPL_DEPTH_32F,1) ;
cvMul(gh,gh,gh2) ;

C++

Mat gh = Mat (input.size(), CV_32FC1);
Sobel(input, gh, CV_32FC1, 1, 0);

Mat gh2 = Mat (input.size(), CV_32FC1);
gh2 = gh.mul(gh); // multiply (gh, gh, gh2);  

The input image is the same, and when I check the horizontal gradient it is also the same for both implementations, so why would the multiplication give different results? (I am interested in getting the result of the C implementation)

来源:https://stackoverflow.com/questions/33601241/opencv-multiply-images-in-c-and-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!