I am currently working on implementing the function of CImg, which is get_gradientXY, using the interface of OpenCV. And I found that cvSobel in OpenCV may have the same effect of get_gradientXY, but after experimenting on a sample graph, the output graph is totally different. I am stuck with this.
Here is my testing code:
imgCv.Load("1.jpg");
imgCimg.Load("1.jpg");
IplImage* pSrcImage = imgCv.GetOpenCVImpPtr();//get pointer of src graph
IplImage* grad_x = cvCreateImage(cvGetSize(pSrcImage), pSrcImage->depth, 3);
IplImage* grad_y = cvCreateImage(cvGetSize(pSrcImage), pSrcImage->depth, 3);
cvSobel(pSrcImage,grad_x,1,0,3);
cvSobel(pSrcImage,grad_y,0,1,3);
std::string filename1 = "gradcvx.jpg";
std::string filename2 = "gradcvy.jpg";
cvSaveImage(filename1.data(), grad_x);
cvSaveImage(filename2.data(), grad_y);
//*****
cimg_library::CImgList<unsigned char> gradImages = imgCimg.GetCImg().get_gradientXY(2);
gradImages[0].save("gradcimgx.jpg");
gradImages[1].save("gradcimgy.jpg");
And gradcvx.jpg is totally different with gradcimgx.jpg. I am wondering why. Thank you.